belgif / rest-guide

REST Guidelines of Belgian government institutions
https://www.belgif.be/specification/rest/api-guide/
Apache License 2.0
24 stars 4 forks source link

Make operationId mandatory #182

Open pvdbosch opened 4 months ago

pvdbosch commented 4 months ago

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

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 commented 4 months ago

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

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

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

pvdbosch commented 4 months ago

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 commented 3 months ago

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