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
We have a controller that returns a time.Duration. This means the generated swagger specification shows the 200 response for the controller as having an object schema. We want to customize this response so that the schema is a string instead.
We wanted to use the OperationCustomizer to handle this:
Our plan was to get the return type of the controller like so handlerMethod.getReturnType().getParameterType() and if it was of a java.time.Duration, get the 200 response schema and set it to a string. The problem is that default API responses are not yet added so operation.getResponses() returns null.
We understand that we can place ApiResponse annotation on the controller to override this however we want to avoid doing that because its a cross cutting concern and we don't to add code to the controller to generate a valid swagger spec.
To Reproduce
Steps to reproduce the behavior:
What version of spring-boot you are using?
2.2.6
What modules and versions of springdoc-openapi are you using?
I will see if we can improve the OperationCustimizer to have access to the ApiResponse Object as well.
If you need to replace the schema of Duration, you can just do:
Describe the bug
We have a controller that returns a time.Duration. This means the generated swagger specification shows the 200 response for the controller as having an object schema. We want to customize this response so that the schema is a string instead.
We wanted to use the OperationCustomizer to handle this:
Our plan was to get the return type of the controller like so
handlerMethod.getReturnType().getParameterType()
and if it was of a java.time.Duration, get the 200 response schema and set it to a string. The problem is that default API responses are not yet added sooperation.getResponses()
returns null.We understand that we can place ApiResponse annotation on the controller to override this however we want to avoid doing that because its a cross cutting concern and we don't to add code to the controller to generate a valid swagger spec.
To Reproduce
Steps to reproduce the behavior:
What version of spring-boot you are using?
2.2.6
What modules and versions of springdoc-openapi are you using?
group: 'org.springdoc', name: 'springdoc-openapi-ui', version: '1.3.2'
The actual response is this:
The expected response is this:
I can't share the actual code but this is a close approximation. The key piece is the return type being Duration in the controller.
Expected behavior
operation.getResponses() is non-null / non-empty when the OperationCustomizer is executed
The text was updated successfully, but these errors were encountered: