question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Duplicate "apiOperation" when 2 HTTP methods are on the same method

See original GitHub issue

Hello,

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:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
charlescappscommented, Sep 11, 2017

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?

0reactions
liuxh0commented, Aug 28, 2019

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?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found