-
-
Notifications
You must be signed in to change notification settings - Fork 888
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
[RFC] Support for DTOs / resource representation classes #2053
Comments
nb. @dunglas even if the type check is performed in the normalizer, it's still not a good error message when we'd expect to get validation errors instead. I think it's a symptom of a design problem when validation is not done using the Symfony Validator. |
Uhh, more importantly, input validation is more than just checking for the correct types and required values. Having a resource representation class is a really powerful thing as it allows supporting all kinds of validation and authorization scenarios. |
What are benefits in real apps? |
+1 Actually when you add contextual serializer groups (according to the user role), the swagger documentation is incomplete (properties key missing). You can actually create your own DTO, but you have to manually hydrate your entity in an event subscriber, and the route appears disconnected of your resources routes in the swagger UI interface (not Front developpers friendly) @ApiResource(relatedResource="Book") ? |
@Bertranddev I imagine it should be the other way around. |
Sounds legit. You're right that creating DTOs, currently, is not very convenient but the best way to make the app looking the same regardless the data is fetched via entity or generated in some way. One request — keep docs actual, especially if someone do not use any annotations because right now it requires too much of guessing. Switching to YAML/XML needs to dig into sources. :( |
Fixed (at least partially) by #2235 |
We should support resource representation classes as an intermediary so that our resource classes can be clean / strongly typed.
To illustrate: https://gist.github.com/teohhanhui/970cf7d5bff27530aa3935a1566f67bf
The text was updated successfully, but these errors were encountered: