operation-operationId-valid-in-url
- Applies to
operationId- Selects
#OperationObject- Function
pattern- Specs
- OpenAPI 2.0OpenAPI 3.0OpenAPI 3.1OpenAPI 3.2
- Message
operationId must not contain characters that are invalid when used in URL.
Use it
This rule ships with OpenLint in spectral:oas. Extending the ruleset turns it on:
extends: spectral:oas
rules:
operation-operationId-valid-in-url: warn # or off, or another severity
Definition
As defined in @openlint/openlint-rulesets. Functions show by name.
operation-operationId-valid-in-url:
message: operationId must not contain characters that are invalid when used in URL.
recommended: true
given: '#OperationObject'
then:
field: operationId
function: pattern
functionOptions:
match: '^[A-Za-z0-9-._~:/?#\[\]@!\$&''()*+,;=]*$'
About this rule
Seeing as operationId is often used for unique URLs in documentation systems, it’s a good idea to avoid non-URL-safe characters.
Bad Example
paths:
/pets:
get:
operationId: get cats