User tests: Successful: Unsuccessful:
Pull Request for Issue #39495 .
Fixes linked bug
In a webservice plugin (either custom or in a core one in the core add the following lines to the onBeforeApiRoute
event (i used the content webservice plugin - but any will do)
\JFactory::getApplication()->addFormatMap('application/ld+json', 'jsonld');
$router->addRoute(
new Route(['GET'], 'v1/format', '', [], ['format' => ['application/vnd.api+json', 'application/ld+json'], 'component' => 'com_content'])
);
Then in the libraries/src/Application/ApiApplication.php add var_dump($this->input->get('format'), $this->input->get('option'));die; after this foreach loop (both before and after testing)
Generate a Bearer token and curl the url e.g. curl -H "Authentication: Bearer <bearer_token>" -H "Accept: application/ld+json" http://localhost/joomla-cms/api/index.php/v1/format
array(2) {
[0]=>
string(22) "applicationvnd.apijson"
[1]=>
string(17) "applicationldjson"
}
string(11) "com_content"
string(7) "jsonld"
string(11) "com_content"
i.e. the second dump (the component) is unchanged and the former (the format) now contains the Joomla format and not the array of possible options from the plugin
Please select:
Documentation link for docs.joomla.org:
No documentation changes for docs.joomla.org needed
Pull Request link for manual.joomla.org:
No documentation changes for manual.joomla.org needed
Category | ⇒ | Libraries |
Status | New | ⇒ | Pending |
I re-read my test description and it's⦠unclear. What I meant to say is that if you do not follow George's instruction to use addFormatMap
you will get the "wrong" format, which is the expected behaviour in the Joomla API application. Even though there's this little gotcha, since it's an expected and documented gotcha, it does not affect me on marking this test successful.
I'm gonna go get some coffee now.
I have tested this item
Using a custom component and only adding 'format' => ['application/json']
Status | Pending | ⇒ | Ready to Commit |
Labels |
Added:
?
|
RTC
Labels |
Added:
?
|
Status | Ready to Commit | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2022-12-28 19:10:36 |
Closed_By | ⇒ | roland-d |
Thank you
I have tested this itemā
successfully on 83ac935
It works!
Just note that if you have
Accept: application/ld+json
you get the formatapplicationldjson
instead of the expectedjsonld
.To fix that, the plugin needs to have the following in its onBeforeApiRoute handler (where routes are registered):
Since this is the expected behaviour of ApiApplication I consider my test successful. Thank you, George!
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/39498.