Skip to content
This repository has been archived by the owner on Sep 2, 2023. It is now read-only.

Duplicate operationIds #182

Open
knutwannheden opened this issue May 1, 2020 · 4 comments
Open

Duplicate operationIds #182

knutwannheden opened this issue May 1, 2020 · 4 comments

Comments

@knutwannheden
Copy link

It appears that this plugin has the same problem the Maven plugin had a while back: kongchen/swagger-maven-plugin#377.

According to the specification the operationId must be unique within the whole API. Currently the operationId is derived from the method name only and will thus result in duplicates if the API has multiple annotated Java methods with the same name:

I have seen other implementations where a number suffix will be used (e.g. foo and foo_1). In the Maven plugin there is a configuration parameter with which the format can be defined. E.g. <operationIdFormat>{{className}}_{{methodName}}_{{httpMethod}}</operationIdFormat>.

@ghost
Copy link

ghost commented May 2, 2020

Using the nickname attribute with the Swagger ApiOperation annotation ensures that each operation has a unique name.

@knutwannheden
Copy link
Author

Yes, I have seen that. But I think it would make sense if the generated operationId would also be unique, as with the Maven plugin. What do you think?

@gigaSproule
Copy link
Owner

@knutwannheden I agree this does make sense. Just for future reference, this default is applied in JaxrsReader#parseMethod and SpringMvcReader#parseMethod, so should be an easy update.

@anichari
Copy link

Any updates on this issue so far? We too are facing similar duplidate operationIds issues. It would be really useful to be able to configure the format like we do in the maven plugin

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants