Improvement: Hash-keyed Try-It-Out parameter value storage (#4670)

* allow param update by identity + hashed value storage

* add specActions.changeParamByIdentity

* add identity-based lookup support in spec selectors

* migrate `changeParam` usage to `changeParamByIdentity`

* migrate usage of `parameterWithMeta` to `parameterWithMetaByIdentity`

* update invocations of `changeParamByIdentity` to match fn signature

* use OrderedMap throughout hash-based selectors for consistency

* normalize usage of ParameterRow `onChange`

* migrate bug 4557 tests to reflect new ParameterRow interface

* remove exclusive test blocks

* linter fixes

* copy Parameters changes into OAS3 wrapper

* use rawParam for meta lookups in ParameterRow
This commit is contained in:
kyle
2018-06-21 21:36:38 -07:00
committed by GitHub
parent 634615346d
commit 8e295c23a4
11 changed files with 410 additions and 45 deletions

View File

@@ -129,4 +129,53 @@ describe("spec plugin - reducer", function(){
expect(response).toEqual(expectedResult)
})
})
describe("SPEC_UPDATE_PARAM", function() {
it("should store parameter values by name+in", () => {
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: "body",
paramIn: "body",
value: `{ "a": 123 }`,
isXml: false
}
})
const response = result.getIn(["meta", "paths", path, method, "parameters", "body.body", "value"])
expect(response).toEqual(`{ "a": 123 }`)
})
it("should store parameter values by identity", () => {
const updateParam = reducer["spec_update_param"]
const path = "/pet/post"
const method = "POST"
const param = fromJS({
name: "body",
in: "body",
schema: {
type: "string"
}
})
const state = fromJS({})
const result = updateParam(state, {
payload: {
param,
path: [path, method],
value: `{ "a": 123 }`,
isXml: false
}
})
const value = result.getIn(["meta", "paths", path, method, "parameters", `body.body.hash-${param.hashCode()}`, "value"])
expect(value).toEqual(`{ "a": 123 }`)
})
})
})