Open
Description
Precondition (*)
Magento 2.3.x
Summary (*)
I want to return JSON in camelCase in my custom webapi.xml and interface that I have created.
There is no way to configure in webapi.xml the format that you wish to use.
By default M2 will return data like so: server_transaction_id but my third party JavaScript is expecting serverTransactionId for example.
Secondly, It is also rather annoying to have to create an interface to do this instead of just being able to use json_encode the data. Using json_encode is not the solution as you end up with \ in the format.
See below:
Examples (*)
interface Check3dsVersionInterface
{
/**
* @return string
*/
public function getServerTransactionId();
/**
* @param string $serverTransactionId
* @return $this
*/
public function setServerTransactionId($serverTransactionId);
webapi.xml:
<route url="/V1/xx-payments/:cartId/check-3ds-version" method="POST">
<service class="xx\xx\Api\xxServiceInterface" method="check3dsVersion"/>
<resources>
<resource ref="anonymous" />
</resources>
</route>
Proposed solution
In webapi.xml, it would be useful to specify the format of the json, for example to return as camelCase or as it is currently which is underscores
Metadata
Metadata
Assignees
Labels
Use with concrete module component label E.g. "Component: Webapi" + "Catalog"Gate 2 Passed. Manual verification of the issue description passedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedGate 1 Passed. Automatic verification of issue format passedGate 4. Acknowledged. Issue is added to backlog and ready for developmentNo current plan to fix. Fixing can be deferred as a logical part of more important work.The issue has been reproduced on latest 2.3 releaseAffects aesthetics, professional look and feel, “quality” or “usability”.Issue related to Developer Experience and needs help with Triage to Confirm or Reject it
Type
Projects
Status
Pull Request in Progress