tinyspec icon indicating copy to clipboard operation
tinyspec copied to clipboard

Generated Operation IDs contain unwanted characters

Open pvgoran opened this issue 5 years ago • 3 comments

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 _.

pvgoran avatar Dec 24 '18 16:12 pvgoran

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 avatar Dec 26 '18 00:12 Ajaxy

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)

Ajaxy avatar Dec 26 '18 01:12 Ajaxy

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

pvgoran avatar Dec 26 '18 03:12 pvgoran