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

Make operationId mandatory #182

Open
pvdbosch opened this issue Apr 17, 2024 · 3 comments
Open

Make operationId mandatory #182

pvdbosch opened this issue Apr 17, 2024 · 3 comments

Comments

@pvdbosch
Copy link
Contributor

Add a guideline that operationId MUST be present for each operation:

  • This operationId is used by code generation tools; using it will avoid warnings and bad method names: Empty operationId found for path: get /someResource. Renamed to auto-generated operationId: someResourceGet
  • other tooling may use it as well (e.g. the api gateway we're using)

Further guidelines in the OpenAPI spec about the operationId seem sufficiently clear (we refer or copy them):

Unique string used to identify the operation. The id MUST be unique among all operations described in the API. The operationId value is case-sensitive. Tools and libraries MAY use the operationId to uniquely identify an operation, therefore, it is RECOMMENDED to follow common programming naming conventions.

@jpraet
Copy link
Contributor

jpraet commented Apr 18, 2024

I'm wondering about the "RECOMMENDED to follow common programming naming conventions".

Doesn't that mean it would depend on the targeted programming language:

  • java: lowerCamelCase, e.g. getEnterprise
  • C#: UpperCamelCase, e.g. GetEnterprise
  • python: snake_case, e.g. get_enterprise

Or do code generators generally take care of converting operationId getEnterprise to GetEnterprise for C#, and get_enterprise for python?

@pvdbosch
Copy link
Contributor Author

openapi-generator seems to convert to language-specific conventions, tested with python-flask,

e.g. operationId: getOneOfTwoStrings => def get_one_of_two_strings()
it also generates an openapi.yaml file with the operationId replaced this converted method name

Works for other elements as well (without modification in the openapi), e.g.:

Parameter name 'paramObject' is not consistent with Python variable names. It will be replaced by 'param_object'

@pvdbosch
Copy link
Contributor Author

WG: OK to mandate operationId. Prefer to have lowerCamelCase as naming convention, consistent with property naming convention.

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