Skip to content

Commit

Permalink
fix(spec): set multi-value parameters as an immutable list (#9567)
Browse files Browse the repository at this point in the history
Refs #9566
  • Loading branch information
glowcloud authored Feb 12, 2024
1 parent 3a86443 commit 6bb76c2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/core/plugins/spec/reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export default {

return state.setIn(
["meta", "paths", ...pathMethod, "parameters", paramKey, valueKey],
value
fromJS(value)
)
},

Expand Down
24 changes: 23 additions & 1 deletion test/unit/core/plugins/spec/reducer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import { fromJS } from "immutable"
import { fromJS, List } from "immutable"
import reducer from "core/plugins/spec/reducers"

describe("spec plugin - reducer", function(){
Expand Down Expand Up @@ -149,6 +149,7 @@ describe("spec plugin - reducer", function(){
const response = result.getIn(["meta", "paths", path, method, "parameters", "body.myBody", "value"])
expect(response).toEqual(`{ "a": 123 }`)
})

it("should store parameter values by identity", () => {
const updateParam = reducer["spec_update_param"]

Expand Down Expand Up @@ -176,6 +177,27 @@ describe("spec plugin - reducer", function(){
const value = result.getIn(["meta", "paths", path, method, "parameters", `body.myBody.hash-${param.hashCode()}`, "value"])
expect(value).toEqual(`{ "a": 123 }`)
})

it("should store a multi-value parameter as an immutable list", () => {
const updateParam = reducer["spec_update_param"]

const path = "/pet/post"
const method = "POST"

const state = fromJS({})
const result = updateParam(state, {
payload: {
path: [path, method],
paramName: "myBody",
paramIn: "body",
value: [ "a", "b" ],
isXml: false
}
})

const response = result.getIn(["meta", "paths", path, method, "parameters", "body.myBody", "value"])
expect(List.isList(response)).toEqual(true)
})
})
describe("SPEC_UPDATE_EMPTY_PARAM_INCLUSION", function() {
it("should store parameter values by {in}.{name}", () => {
Expand Down

0 comments on commit 6bb76c2

Please sign in to comment.