Make operationId mandatory
See original GitHub issueHi,
I would like to propose to make operationId
required in Operation definition. As the specification states, this field may be used in tooling to uniquely identify operations. I have a couple of real world examples:
- different tools that support both http method/path combination have an algorithm that transforms the http method/path combination to an operationId, giving sometimes awful/unexpected results. For example, let’s say that you have a contract without operationIds and you generate clients for it using any tool. One day you update the contract changing a path name or a path parameter name. The generated clients will durely change the method names, while the meaning of the operation is always the same!
- Some libraries (like mine https://vertx.io/docs/vertx-web-api-contract/java/) uniquely refer to an operation using the operationId more than the http method/path combination. While the http method/path combination is subject to changes, while
operationId
usually remains related with the meaning of the operation.
In the end, I personally see operationId
as the only meaningful operation identifier, that’s why I think we should encourage users to define it, making it mandatory
WDYT?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:6
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Paths and Operations - Swagger
operationId is an optional unique string used to identify an operation. If provided, these IDs must be unique among all operations described in...
Read more >FATAL: OperationId is required for all operations. Please add ...
I think latest Swagger (5.2.1) by default doesn't generate OperationId for operations because it is an optional identifier as per their docs ...
Read more >OperationId is required for all operations. Please add it for 'get ...
I ran into this error message when trying to create a REST API Client in Visual Studio for a C# class from an...
Read more >OpenAPI Best Practices - operation-operationId - MuleSoft
This operation ID is a reference for the operation that can be used ... Make the value lower-hyphen-case and use a name for...
Read more >10 Essentials When Creating an OpenAPI Specification - Tyk.io
While not required, the operationId is encouraged. But little direction is given regarding naming conventions or how to create an ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This issue is a dupe of closed issue #1019 (though that issue was closed by it’s original poster).
To summarise, the arguments against making
operationId
mandatory are:operationId
s being usedoperationId
from the method and path, though perhaps not as readableuuid
can be used where not intended for human consumptionThis really leaves the case where a document author has not included
operationId
s but a third party requires them for a use-case such as code generation or framework ingestion. The proposed overlay approach in OAS 3.1 would likely be a reasonable way of resolving this issue.A good OAS validator should definitely report an error on a duplicated
operationId
and several linters which use rules originated inoas-kit
warn about missingoperationIds
by default.Strong agreement from me. Our use of OperationId requires this for unique naming, through I can see how code or doc generation would not require it.