Skip to content

Fix webapi returns variables in JSON using snake case and I need camelCase #25180

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed

Conversation

jayankaghosh
Copy link
Contributor

@jayankaghosh jayankaghosh commented Oct 21, 2019

Description (*)

Added objectKeyMap which accepts parameters from di.xml to modify data object keys
We can now modify the keys of any accessor on any class used in the rendering of the REST API, using the following (or similar) snippet in the di.xml of the webapi_rest directory.

<type name="Magento\Framework\Reflection\DataObjectProcessor">
        <arguments>
            <argument name="objectKeyMap" xsi:type="array">
                <item name="Magento\Cms\Api\Data\PageInterface" xsi:type="array"> <!-- Change the accessors keys of this class -->
                    <item name="page_layout" xsi:type="string">PageLayout</item> <!-- page_layout should be shown as PageLayout in the ouput -->
                </item>
            </argument>
        </arguments>
    </type>

Fixed Issues (if relevant)

  1. Fixes webapi returns variables in JSON using snake case and I need camelCase #24681 : webapi returns variables in JSON using snake case and I need camelCase

Manual testing scenarios (*)

  1. Add a di.xml inside webapi_rest directory of any module and inject object key names to it, similar to the following
<type name="Magento\Framework\Reflection\DataObjectProcessor">
        <arguments>
            <argument name="objectKeyMap" xsi:type="array">
                <item name="Magento\Cms\Api\Data\PageInterface" xsi:type="array">
                    <item name="page_layout" xsi:type="string">PageLayout</item>
                </item>
            </argument>
        </arguments>
    </type>
  1. Call the REST API and observe the new keys reflecting.

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds are green)

@jayankaghosh jayankaghosh requested a review from YevSent as a code owner October 21, 2019 07:21
@m2-assistant
Copy link

m2-assistant bot commented Oct 21, 2019

Hi @jayankaghosh. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.3-develop instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Guide documentation.

@sidolov sidolov changed the base branch from 2.3-develop to 2.4-develop December 5, 2019 17:17
@sidolov sidolov added Priority: P4 No current plan to fix. Fixing can be deferred as a logical part of more important work. Severity: S4 Affects aesthetics, professional look and feel, “quality” or “usability”. labels Aug 18, 2020
@ihor-sviziev ihor-sviziev changed the title Fixes Issue 24681 Fix webapi returns variables in JSON using snake case and I need camelCase Sep 11, 2020
@ihor-sviziev ihor-sviziev self-assigned this Oct 28, 2020
@ihor-sviziev
Copy link
Contributor

@magento run all tests

@ihor-sviziev
Copy link
Contributor

Hi @jayankaghosh,
Thank you for your contribution! I'm really sorry that no one reviewed this PR earlier.

I'll take this PR and will provide my feedback soon.

From the first look - in general changes looks good to me, but some adjustments definitely will be required.

@ihor-sviziev
Copy link
Contributor

Oh... I see that the branch from which was created this PR was already removed, so we basically can't accept this PR.

Unfortunately I have to close this PR due to that reason. If you're still interesting in contributing this improvement - please create a new PR with the same changes, I'll try to take it as fast as possible.

@m2-assistant
Copy link

m2-assistant bot commented Oct 28, 2020

Hi @jayankaghosh, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

@ghost ghost removed the Progress: review label Oct 28, 2020
@tuyennn
Copy link
Member

tuyennn commented Nov 20, 2020

@jayankaghosh could you create a new pull request base on current one.

@jayankaghosh
Copy link
Contributor Author

@tuyennn Oh my. I forgot I've even made this PR. Lol.

Sure. I'll create a new PR at the earliest.

@jayankaghosh
Copy link
Contributor Author

@ihor-sviziev @tuyennn Here's the new PR

#31001

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Reflection Priority: P4 No current plan to fix. Fixing can be deferred as a logical part of more important work. Release Line: 2.4 Severity: S4 Affects aesthetics, professional look and feel, “quality” or “usability”. Squashtoberfest 2019
Projects
None yet
Development

Successfully merging this pull request may close these issues.

webapi returns variables in JSON using snake case and I need camelCase
5 participants