Skip to content

Commit

Permalink
fix(spec): ignore empty string for multi-value parameter (#9511)
Browse files Browse the repository at this point in the history
Refs #9266 
Refs #5176 

Co-authored-by: Julien Bourges <julien.bourges@actility.com>
Co-authored-by: Oliwia Rogala <oliwia.rogala@smartbear.com>
  • Loading branch information
3 people committed Feb 15, 2024
1 parent f04a542 commit 0ce0509
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/core/plugins/spec/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,9 @@ export function parameterValues(state, pathMethod, isXml) {
let paramValues = operationWithMeta(state, ...pathMethod).get("parameters", List())
return paramValues.reduce( (hash, p) => {
let value = isXml && p.get("in") === "body" ? p.get("value_xml") : p.get("value")
if (List.isList(value)) {
value = value.filter(v => v !== "")
}
return hash.set(paramToIdentifier(p, { allowHashes: false }), value)
}, fromJS({}))
}
Expand Down
8 changes: 6 additions & 2 deletions test/unit/core/plugins/spec/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ describe("parameterValue", function(){
get: {
parameters: [
{ name: "one", in: "query", value: 1},
{ name: "two", in: "query", value: "duos"}
{ name: "two", in: "query", value: "duos"},
{ name: "three", in: "query", value: ["v1","","v2"]},
{ name: "four", in: "query", value: [""]}
]
}
}
Expand All @@ -122,7 +124,9 @@ describe("parameterValue", function(){
// Then
expect(paramValues.toJS()).toEqual({
"query.one": 1,
"query.two": "duos"
"query.two": "duos",
"query.three": ["v1","v2"],
"query.four": []
})

})
Expand Down

0 comments on commit 0ce0509

Please sign in to comment.