Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated Operation IDs contain unwanted characters #13

Open
pvgoran opened this issue Dec 24, 2018 · 3 comments
Open

Generated Operation IDs contain unwanted characters #13

pvgoran opened this issue Dec 24, 2018 · 3 comments

Comments

@pvgoran
Copy link
Contributor

pvgoran commented Dec 24, 2018

The use of - as a placeholder character that replaces non-word characters of the path to produce an Operation ID seems to be a poor choice. The specification says:

Tools and libraries MAY use the operationId to uniquely identify an operation, therefore, it is recommended to follow common programming naming conventions.

And use of - definitely does not follow common programming naming conventions. As a result, the Swagger's code generator that I use (swagger-codegen-cli-2.3.1.jar) can't produce a working code for such operationIds.

Thus, I suggest changing the placeholder character to _.

@Ajaxy
Copy link
Owner

Ajaxy commented Dec 26, 2018

I agree. Would be great if you could do a PR. I would use _.camelCase here.

However, we need to avoid collisions (for example for GET /hello_world vs. GET /hello/world). Now a double dash separator (--) is used for it, but it makes the operation ID quite ugly. Another possible solution would be to keep track of occurrences of each operation ID and if it's > 0, add some postfix to the next one, like getHelloWorld and getHelloWorld2.

Also, we need to use path with the param types stripped out (after merge of #12).

@Ajaxy
Copy link
Owner

Ajaxy commented Dec 26, 2018

Also, maybe would be better to just remove the autogenerated operation IDs at all. Because tools that use them (codegens) have their own defaults in case they’re missing.

And in case someone is not satisfied with defaults we’ll support explicit way (from #14)

@pvgoran
Copy link
Contributor Author

pvgoran commented Dec 26, 2018

I agree, it would be probably better to remove the auto-generated Operation IDs altogether. The best code is no code at all!

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

No branches or pull requests

2 participants