-
-
Notifications
You must be signed in to change notification settings - Fork 848
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
Allow configuring input and ouput class per operation #2481
Allow configuring input and ouput class per operation #2481
Conversation
unrelated CI failure |
I don't really understand why we need that. It should already work actually |
I want to use a different DTO for creation and updating a resource. If you have a better idea I'm happy to hear it. I couldn't get it to work at all per operation, without this PR. |
looks legit to me |
@soyuka is this the correct place to implement the fix? |
I don't understand why we need a request attribute for that. As the operation is known at this point, we should just be able to lookup the attribute value from the operation metadata (using the metadata factory). Or am I missing something? |
The output class should be set directly on the /** @ApiResource(itemOperations={"get"={"output_class"="FooBar"}})*/ |
Can you try? I have tried exactly that, it does not work. here is my actually attempt: /**
* @ApiResource(
* normalizationContext={"groups": {"account:read"}},
* collectionOperations={
* "get": {"method": "GET", "path": "/accounts/"},
* },
* itemOperations={
* "get": {"output_class": "ThrowAnError", "method": "GET", "path": "/accounts/{id}", "requirements": {"id": "%uuid_regex%"}},
* "put": {"input_class": "ThrowAnError", "method": "PUT", "path": "/accounts/{id}", "requirements": {"id": "%uuid_regex%"}, "denormalization_context": {"groups": {"account:update"}}}
* }
* )
*/ Which should throw an error, but does nothing. The config is ignored. |
@dunglas we were not using the operation configuration but rather the resource-level one: Therefore, @bendavies yes the fix is in the correct place. |
The input class shouldn't be in the request attribute but in our own metadata We must change this behavior before tagging 2.4. |
Closing due to #2483 |
This allows specifying the input and output class per operation.
It is already possibly to specify them for subresources, so I think it was an oversight for operations, which is why i'm classifying this as a bug.