You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
How do I provide type information to a response schema?
When a service method has the following response type: ResponseEntity<PageDto<CustomerDto>> swagger correctly displays all type information I want to see.
However when I have multiple possible responses I would like to provide the same details via annotation and there I don't know how to provide the type information of the PageDto:
Swagger obviously doesnt know what type T the PageDto class contains. How do I provide this information such that the documentation is generated with better details?
Thanks for your help!
The text was updated successfully, but these errors were encountered:
#4129 addresses this by introducing field @ApiResponse.useReturnTypeSchema, which allows to mark a response to use the return type for its schema. Please see comment in PR for an example
@frantuma
In my opinion this can't work for this case. The specified return type is ResponseEntity<Any> and this is not helpful in the documentation. The return type also can't be different since the method actually returns either ErrorDto or PageDto.
Did I understand this wrong? useReturnTypeSchema can't magically find out what i'm doing inside the method also it wouldn't know which Type to use.
So again: How can I specify the generic Type of a Dto returned inside the Annotation (ApiResponse/Content/Schema)?
judos
changed the title
type information for response schema
generic type information for response schema
Mar 11, 2022
How do I provide type information to a response schema?
When a service method has the following response type:
ResponseEntity<PageDto<CustomerDto>>
swagger correctly displays all type information I want to see.However when I have multiple possible responses I would like to provide the same details via annotation and there I don't know how to provide the type information of the PageDto:
Swagger obviously doesnt know what type T the PageDto class contains. How do I provide this information such that the documentation is generated with better details?
Thanks for your help!
The text was updated successfully, but these errors were encountered: