operation-operationId-unique
Every operation must have an operationId
that is unique. It’s critical that all
Operation’s can be identified independently, without the need
to analyze the path, params and verbs to locate an operation.
An operationId
is used by documentation tools, code generators and mocking engines. It’s used to define page names,
URI’s and method names in auto-generated code.
It needs to be unique so there are no clashes with other operations (nothing else can share that ID).
Why did this violation appear?
There is an Operation in the specification that has a duplicated operationId
.
What is this rule checking for?
Every Operation is checked for the following
- Operation ID is unique in the spec.
A bad example
"/pet":
post:
operationId: createPet
responses:
'200':
...
"/pet":
put:
operationId: createPet
responses:
'200':
...
A good example
"/pet":
post:
operationId: createPet
responses:
'200':
...
"/pet":
put:
operationId: updatePet
responses:
'200':
...
How do I fix this violation?
Every single Operation needs an operationId
. It’s a critical requirement to be able to identify each individual
operation uniquely. Ensure all operations have a clear, unique operationId
Spectral Equivalent
The rule is equivalent to operation-operationId-unique