You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When the flag "multipleInterfaces" is set to "ByTag", the method names are still being renamed to have numerical suffixes even though the names are unique within the Interface (e.g. InfoGET3Async).
The check for method name uniqueness should be performed at the interface level, and not at the OpenAPI specification level.
Thanks for taking the time to report this @dammitjanet
For the best code generation experience, I think that specifying the operationId at the OpenAPI specification level is best. Code generators, like mine, would try to do best guess attempts on how to name methods for each operation and one of the ways this is done is by looking at things like the verbs, path segments, and tags
You can maybe experiment with the --operation-name-generator CLI tool argument to try out different naming styles. Possible values for --operation-name-generator are documented here. The operation name generator options are taken directly from NSwag, the tool I use to parse the OpenAPI spec and generate models
For the best code generation experience, I think that specifying the operationId at the OpenAPI specification level is best. Code generators, like mine, would try to do best guess attempts on how to name methods for each operation and one of the ways this is done is by looking at things like the verbs, path segments, and tags
That didn't work when I used
[SwaggerOperation(OperationId = "_2fa")]
but did when I used
[SwaggerOperation(OperationId = "TwoFactor")]
Even so, the generator should not create invalid method names, so I think its a bug, just one with a relatively easy workaround and is low priority.
We could look into implementing some sort of "last line of defense" that checks if the generated method name will compile and if not, make a naive attempt to replace invalid characters with "something else". Something like this would never be perfect but it could save someone like @dammitjanet time and avoid changing the OpenAPI spec itself to get the generated code to work
Describe the bug
When the flag "multipleInterfaces" is set to "ByTag", the method names are still being renamed to have numerical suffixes even though the names are unique within the Interface (e.g. InfoGET3Async).
The check for method name uniqueness should be performed at the interface level, and not at the OpenAPI specification level.
Support Key:
7l7irxz
OpenAPI Specifications
n/a
The text was updated successfully, but these errors were encountered: