Linter rulesOpenAPIpath-parameters-defined
path-parameters-defined
Since 0.0.1 · fixed by --fix
This rule ensures that for all parameter placeholders defined in path item URLs, there are path parameters defined in corresponding path items or their operations.
Rule Details
The path-parameters-defined rule is designed to ensure that for all
parameter placeholders defined in path item URLs, there are corresponding path
parameters defined in the path items or their operations. This helps to
maintain consistency and clarity in the API’s structure.
Configuration
The optional defaultType selects the schema type for generated path
parameters. It defaults to string; set it to null to disable automatic
insertion.
Examples
Good.
paths:
/users/{userId}:
parameters:
- name: userId
in: path
required: true
schema:
type: string
get:
summary: Get a user by ID
Bad. Definition of the userId parameter is missing.
paths:
/users/{userId}:
get:
summary: Get a user by ID
When Not to Use It
If your API does not use path parameters or if you have other means of ensuring that all parameter placeholders have corresponding path parameters, you may not need to use this rule.
Automatic fixes
When invoked with --fix, missing placeholders are added as path-level
parameters with in: path, required: true, and the configured schema type.
Compatibility
This rule is compatible with all OpenAPI 3.x versions.