From 6bb76c2c28d3d7d69a56c9f81ff7d50669d8b88b Mon Sep 17 00:00:00 2001 From: Oliwia Rogala Date: Mon, 12 Feb 2024 12:12:38 +0100 Subject: [PATCH] fix(spec): set multi-value parameters as an immutable list (#9567) Refs #9566 --- src/core/plugins/spec/reducers.js | 2 +- test/unit/core/plugins/spec/reducer.js | 24 +++++++++++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/core/plugins/spec/reducers.js b/src/core/plugins/spec/reducers.js index 5a664491..8a5644de 100644 --- a/src/core/plugins/spec/reducers.js +++ b/src/core/plugins/spec/reducers.js @@ -62,7 +62,7 @@ export default { return state.setIn( ["meta", "paths", ...pathMethod, "parameters", paramKey, valueKey], - value + fromJS(value) ) }, diff --git a/test/unit/core/plugins/spec/reducer.js b/test/unit/core/plugins/spec/reducer.js index a0635b44..2f274d30 100644 --- a/test/unit/core/plugins/spec/reducer.js +++ b/test/unit/core/plugins/spec/reducer.js @@ -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}", () => {