path-parameter-exists-in-path-url-template
Overview
This rule belongs to the swagger-v2-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 | SWAGGER20STANDARDS_V101 |
Type | Validation |
Rule System | Semantic |
Broad Category | Parameters |
Products Impacted | API Transformer, Code Generation, Developer Experience Portal |
Tags | swagger2 swagger 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.