-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add mandatory id and annotations #1080
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
Conversation
Adding an id to Book entity class and with the annotations included the example works from scratch including OpenAPI docs.
core/dto.md
Outdated
@@ -6,7 +6,7 @@ However, it's sometimes useful to use a specific class to represent the input or | |||
|
|||
## Specifying an Input or an Output Data Representation | |||
|
|||
For a given resource class, you may want to have a different representation of this class as input (write) or output (read). | |||
For a given resource class, you may want to have a different representation of this class as input (write) or output (read). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you remove the trailing space?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in d094c19
@@ -27,6 +27,7 @@ use App\Dto\BookOutput; | |||
*/ | |||
final class Book | |||
{ | |||
public $id; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example is needs also a @ApiProperty(identifier=true)
And to be honest, I should also have a property called $code
So the InputDataTransformer
actually transform the isbn into a code.
And then in the OutputDataTransformer
, from this code into the name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example only needs the annotation @ApiProperty(identifier=true)
if you use another name to the property, like $code
. But the example works without the annotation with the $id
property.
Although, IMHO, Book entity shouldn't need a mandatory id property, because you have a BookInput and a BookOutput DTOs and BookInput have an id (called isbn
).
So, to make a simple full example, that works with this issue, I think that adding an id called $id
to Book is the clearest way.
Maybe, we can add also a note explaining the option of using $code
property, annotated as identifier, and transforming it to isbn.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup it's a good idea, at least to clarify the process.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can check fabb572 🙂
Fix trailing space
Add process explanation
Hi! What's happened with the PR? This is my first contribution so I don't know if you need anything else to merge. Please, tell me. |
Thank you @dhernandez. |
Adding an id to Book entity class and with the annotations included the example works from scratch including OpenAPI docs.