path-parameter-exists-in-path-url-template
Overview
This rule belongs to the openapi-v3-standards-validation
ruleset and states that:
If a parameter is defined in the parameters
list with location set as path
, a corresponding URL segment in the path URL must exist for that parameter. A path URL can use curly braces ({}) to mark a section of a URL path as replaceable with a path parameter value. The name specified within these braces must match exactly with the name of the path parameter defined in the parameters
list.
Property | Value |
---|---|
Enabled | Yes |
Maximum Severity | Error |
Message | Unused path parameter found. |
Code | OPENAPI3STANDARDS_V080 |
Type | Validation |
Rule System | Semantic |
Broad Category | Parameters |
Products Impacted | API Transformer, Code Generation, Developer Experience Portal |
Tags | openapi3 openapi standards semantic validation path parameter url |
Suggested Fixes
- In path '/pet/{petId}', 'petId' is the name of a path parameter. Correspondingly, if you have a definition for a path parameter, its name must exist within curly braces in the path URL.
- Ensure that the name of the parameter matches exactly with the name used in the path URL.
- Names are compared in a case-sensitive manner.
- If the path URL is accurate and should not be changed, consider removing the redundant path parameter definition from the parameters list.
For More Information
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#path-templating
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#parameter-object
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#pathsPath
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#paths-object
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#path-templating
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#parameter-object
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#pathsPath
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#paths-object
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#openapi-specification
- https://docs.apimatic.io/rulesets/overview/