Parameter name/key validation too strict (takes global parameters into account in local path inappropriately)
See original GitHub issueQ | A |
---|---|
Bug or feature request? | Bug |
Which Swagger/OpenAPI version? | 2.0 |
Which Swagger-Editor version? | editor.swagger.io |
How did you install Swagger-Editor? | Using public version |
Which browser & version? | Chrome |
Which operating system? | Windows |
Demonstration API definition
Taken from default “pet store” example, modified as follows… example problem yaml.txt
...
parameters:
testParameter:
name: mytest
in: query
required: true
type: string
paths:
/pet:
post:
tags:
- "pet"
summary: "Add a new pet to the store"
description: ""
operationId: "addPet"
consumes:
- "application/json"
- "application/xml"
produces:
- "application/xml"
- "application/json"
parameters:
- name: mytest
in: query
type: string
required: true
...
Expected Behavior
Should not have any error because technically the parameter name/key (combo of name
and in
are unique to the specific path entry (/pet | post
). The “conflicting” parameter is in the global parameter
object named testParameter
, however it does not even have to be referenced in any of the path methods for this faulty error message to come up.
Current Behavior
It complains about having duplicate parameter names for the mytest:in
key with the error message:
Semantic error at paths./pet.post.parameters.0
Sibling parameters, whether inherited or direct, must have unique name + in values
It appears to have a global context for parameters and combines the parameter definitions from the global parameters
field with the parameters
field of individual path method definitions. This is in conflict with the specification that states:
Parameters
An object to hold parameters that can be used across operations. This property does not define global parameters for all operations.
It should only take into account parameters that are defined and/or referenced in each specific path/method definition.
Context
This bug is relatively new as I have been using the public editor for nearly 12 months with my schema that has global parameters with the same names as locally defined parameters and have never had this error message before now.
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (4 by maintainers)
fixed, will ship on Friday!
thx @hsgreen @maiconmichelon @G-Rath @mminns for pointing out the flaw in this validator 🤜 🤛
@shockey I’m getting this as well when trying to use the bitbucket swagger definitions (found here - WARNING: It’s a large file!).
I’m using the Swagger editor found here.
Since I have no experience with Swagger, I’m not sure how to resolve this, but it seems to fit the pattern of this bug 😕