Skip to content

Commit 6bb76c2

Browse files
authored
fix(spec): set multi-value parameters as an immutable list (#9567)
Refs #9566
1 parent 3a86443 commit 6bb76c2

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

src/core/plugins/spec/reducers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export default {
6262

6363
return state.setIn(
6464
["meta", "paths", ...pathMethod, "parameters", paramKey, valueKey],
65-
value
65+
fromJS(value)
6666
)
6767
},
6868

test/unit/core/plugins/spec/reducer.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
import { fromJS } from "immutable"
2+
import { fromJS, List } from "immutable"
33
import reducer from "core/plugins/spec/reducers"
44

55
describe("spec plugin - reducer", function(){
@@ -149,6 +149,7 @@ describe("spec plugin - reducer", function(){
149149
const response = result.getIn(["meta", "paths", path, method, "parameters", "body.myBody", "value"])
150150
expect(response).toEqual(`{ "a": 123 }`)
151151
})
152+
152153
it("should store parameter values by identity", () => {
153154
const updateParam = reducer["spec_update_param"]
154155

@@ -176,6 +177,27 @@ describe("spec plugin - reducer", function(){
176177
const value = result.getIn(["meta", "paths", path, method, "parameters", `body.myBody.hash-${param.hashCode()}`, "value"])
177178
expect(value).toEqual(`{ "a": 123 }`)
178179
})
180+
181+
it("should store a multi-value parameter as an immutable list", () => {
182+
const updateParam = reducer["spec_update_param"]
183+
184+
const path = "/pet/post"
185+
const method = "POST"
186+
187+
const state = fromJS({})
188+
const result = updateParam(state, {
189+
payload: {
190+
path: [path, method],
191+
paramName: "myBody",
192+
paramIn: "body",
193+
value: [ "a", "b" ],
194+
isXml: false
195+
}
196+
})
197+
198+
const response = result.getIn(["meta", "paths", path, method, "parameters", "body.myBody", "value"])
199+
expect(List.isList(response)).toEqual(true)
200+
})
179201
})
180202
describe("SPEC_UPDATE_EMPTY_PARAM_INCLUSION", function() {
181203
it("should store parameter values by {in}.{name}", () => {

0 commit comments

Comments
 (0)