You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When an Operation parameter is defined with the same name as an applicable Path item parameter, parameters in requests are being validated against BOTH parameter schemas. According to the OpenAPI spec, the Operation level parameter should override the path item parameter, not be in addition to.
To Reproduce
Create a spec with a parameter defined at the path level, and a parameter with the same name for an operation under that path.
Actual behavior
Requests are validated against BOTH definitions of the parameter, rather than just the operation one.
Expected behavior
Requests will be validated against just the operation level schema, as by my reading of the openAPI Spec it should override the path level definition.
Examples and context
This seems to be an issue with the way the applicable parameter validation schema arrays are accumulated during preprocessing.
I think the preprocessPathLevelParameters function in the schema.preprocessor parser should only add path level parameters to the v.parameters array if there is not already an existing parameter definition by that name in the array.
I get the behavior I expect if I change this loop to this:
for (const param of parameters) {
//skip adding path param if operation param already exists.
if (!(v.parameters.some(vparam => vparam.name === param.name))){
v.parameters.push(param);
}
}
(Not sure if that's valid typescript.... I made my change in the node module)
The text was updated successfully, but these errors were encountered:
Also, just to be clear, I am talking about Query parameters specified at the path and operation levels, not parameters actually IN the path.
cd-rite
changed the title
Operation parameters should override path item parameters, not be in addition to them
Operation query parameter descriptions should override path item query parameter descriptions, and not be validated in addition to them
Jul 6, 2021
Describe the bug
When an Operation parameter is defined with the same name as an applicable Path item parameter, parameters in requests are being validated against BOTH parameter schemas. According to the OpenAPI spec, the Operation level parameter should override the path item parameter, not be in addition to.
https://swagger.io/docs/specification/describing-parameters/
https://spec.openapis.org/oas/v3.1.0#operation-object
To Reproduce
Create a spec with a parameter defined at the path level, and a parameter with the same name for an operation under that path.
Actual behavior
Requests are validated against BOTH definitions of the parameter, rather than just the operation one.
Expected behavior
Requests will be validated against just the operation level schema, as by my reading of the openAPI Spec it should override the path level definition.
Examples and context
This seems to be an issue with the way the applicable parameter validation schema arrays are accumulated during preprocessing.
I think the preprocessPathLevelParameters function in the schema.preprocessor parser should only add path level parameters to the v.parameters array if there is not already an existing parameter definition by that name in the array.
I get the behavior I expect if I change this loop to this:
(Not sure if that's valid typescript.... I made my change in the node module)
The text was updated successfully, but these errors were encountered: