springmvc: @ResponseStatus annotation for CREATED results in doubled response description
See original GitHub issueGenerated result:
...
"responses" : {
"200" : {
"description" : "successful operation",
"schema" : {
"$ref" : "#/definitions/ResultDto"
}
},
"201" : {
"description" : ""
}
}
...
Expected result:
...
"responses" : {
"201" : {
"description" : "successful operation",
"schema" : {
"$ref" : "#/definitions/ResultDto"
}
}
}
...
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Using Spring @ResponseStatus to Set HTTP Status Code
In this short tutorial, we will see the most straightforward way: using the @ResponseStatus annotation. 2. On Controller Methods.
Read more >Exception Handling in Spring MVC
When an annotated exception is thrown from a controller method, and not handled elsewhere, it will automatically cause the appropriate HTTP ...
Read more >spring 4.2 application event is firing twice with Spring MVC ...
I suspect indeed that the EventListener bean is registered twice or something. You can enable org. springframework. context.
Read more >Spring Boot @ResponseStatus Annotation - Java Guides
@ResponseStatus marks a method or exception class with the status code and reason message that should be returned. The status code is applied...
Read more >Logging Requests and Responses in Spring (including body)
Recently we have found some problems trying to log a complete Request and Response in a Spring Application. When we talk about a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
from my perspective both of these methods should result in
At the same time, both of these
should result in
and finally,
should also be converted into
The last one is a little controversial and can be expected to become
but I think that if someone is explicitly specifying api responses there is no reason to avoid defining all of them, including the 200 one, if needed. Currently you PR fails to specify
type: string
in all cases and duplicates status code in the test1-test2 block .I don’t think so - the whole point of this PR is to remove/replace default 200 response (which is added in
com.github.kongchen.swagger.docgen.reader.SpringMvcApiReader#parseMethod
) in special cases where you don’t want 200 at all. For example - combination of ResponseStatus(201) and ApiResponse(204) is perfectly legitimate: 201 is default, 204 is a special case. I don’t think we should override scheme or description in case of 204 with the one from 200 - no content has no content. Also the case which you pointed out at the end - if you set any ApiResponses and have set default on ResponseStatus, it will be ignored.