Duplicate "apiOperation" when 2 HTTP methods are on the same method
See original GitHub issueHello,
I have a Spring MVC controller class annotated with:
@ApiOperation(value = "Do something.")
@RequestMapping(method = {RequestMethod.GET, RequestMethod.POST})
public String doSomething(HttpServletRequest request, HttpServletResponse response) throws Exception {
[...]
}
and the generated swagger file contains 2 paths (expected) but with the same operationId
(not expected) so swagger editor complains about it: “Cannot have multiple operations with the same operationId: doSomething”
Would be nice to have the operationId
being httpMethod-methodName
instead of just methodName
, what do you think?
Thanks Fanny
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:8 (3 by maintainers)
Top Results From Across the Web
java - Swagger - how to get multiple operations with same http ...
In my API I have two methods to register user: @RequestMapping(method = RequestMethod.POST, consumes = "application/customer+json", produces = ...
Read more >Paths and Operations - Swagger
OpenAPI defines a unique operation as a combination of a path and an HTTP method. This means that two GET or two POST...
Read more >@ApiOperation vs @ApiResponse in Swagger | Baeldung
The @ApiOperation annotation is used to describe a single operation. An operation is a unique combination of a path and an HTTP method....
Read more >Idempotent REST APIs
An idempotent HTTP method is a method that can be invoked many times without the different outcomes. ... 2. Idempotency with HTTP Methods....
Read more >HTTP Methods in RESTful Web Services
Learn different HTTP method and their use while designing your REST API. ... Multiple requests should return same data for the GET request ......
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 Free
Top 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
We’ve ran into this issue, too. The annoying thing is that if we have 2 methods in different Java classes (and different swagger Tags), it will just prepend numbers to the operation ID silently, which is a real problem. Is there a setting to just fail at compile time if you have 2 methods with the same operation ID, instead of silently renaming them?
Hi all,
I know this is an old issue. I also ran into this problem.
Since operationId is optional (https://swagger.io/docs/specification/paths-and-operations/), can we skip generating this if not provided by user?