-
-
Notifications
You must be signed in to change notification settings - Fork 887
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
Custom dto output return tons of @context #6810
Comments
mark your DTO as an API Resource to avoid that, I'll check if we can do something. |
I encountered a similar issue, and I managed to resolve it by adding the #[ApiPlatform\Metadata\ApiResource] attribute to my DTO and registering it in the api_platform.yaml configuration file under the mapping section. After making these changes, everything worked as expected. |
Wow, thanks. It works. I configured @soyuka maybe add it to doc if this change persist ? :) |
@soyuka @Gist-race so.. i just tested it again and i mentioned context is correct but now documentation is not correct. DTO is now as resource in doc which is wrong. For fix it need write |
let's keep that as a bug I need to investigate but it's not that easy to fix, we need to host this context and refer to it on the api |
@HrjSnz I was not able to reproduce your issue, could you help with a full reproducer? see soyuka@f97eaed it does return:
I'm using the last 4.x version available. |
@soyuka Hello, i am sorry lack of time. I will try it tomorrow. Just what i see in your test you use
but my problem is with output on
I will try it tomorrow and provide more information. Thanks |
@soyuka Hello, i think i found problem. Reason why test is without error is in There is default value core/tests/Fixtures/app/AppKernel.php Lines 277 to 279 in de3bed2
In core/src/Symfony/Bundle/DependencyInjection/Configuration.php Lines 145 to 150 in de3bed2
false
So all test run with Place where is wrong set context is here core/src/JsonLd/ContextBuilder.php Lines 187 to 189 in de3bed2
There in test in $this->defaultContext[self::HYDRA_CONTEXT_HAS_PREFIX] is true but in app is default false so result is opposite in real app instead in test.
another indicator is api_platform.yaml. In my api_platform.yaml if let it default so getting this wrong context. If i use
so problem gone and it return correct context And it started in 4.0.7 because #6765 has changed context from one line to full array. Before it always jumped wrong but got one line context. |
I also ran in to the same issue. What I usually do is instead of marking it as an complete This way it won't be shown in the docs and calling the endpoint returns a not found :) |
@SherinBloemendaal yes, but before it works without it. And write additional endpoint and close it is in my opinion bad practice. As i mentioned above, i probably found the error, but then no one responds to it. Problem is not context itself but if statement which is called wrong. |
I managed to reproduce I'm looking into this. |
API Platform version(s) affected: 4.0.7 +
Description
With custom resource and use parameter "output" for custom dto return in response full "@ context" . In version 4.0.6 and below not.
If not use "output" everything works fine.
How to reproduce
Just make custom output DTO.
Possible Solution
Is this bug ? I couldn't find any mention of this in the changes.
Additional Context
custom api resource
in response tons of "@ context" (around 1k lines)
The text was updated successfully, but these errors were encountered: