fix(spec): set multi-value parameters as an immutable list (#9567)

Refs #9566
This commit is contained in:
Oliwia Rogala
2024-02-12 12:12:38 +01:00
committed by GitHub
parent 3a86443322
commit 6bb76c2c28
2 changed files with 24 additions and 2 deletions

View File

@@ -62,7 +62,7 @@ export default {
return state.setIn(
["meta", "paths", ...pathMethod, "parameters", paramKey, valueKey],
value
fromJS(value)
)
},

View File

@@ -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(){
@@ -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"]
@@ -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}", () => {