fix: remove special handling of non-FormData entries (#6036)
Ref: #6033 * 'createObjWithHashedKeys' validation consistency with isFunction * 'createObjWithHashedKeys' additional jsdoc example
This commit is contained in:
@@ -86,9 +86,6 @@ export function fromJSOrdered(js) {
|
|||||||
const objWithHashedKeys = createObjWithHashedKeys(js)
|
const objWithHashedKeys = createObjWithHashedKeys(js)
|
||||||
return Im.OrderedMap(objWithHashedKeys).map(fromJSOrdered)
|
return Im.OrderedMap(objWithHashedKeys).map(fromJSOrdered)
|
||||||
}
|
}
|
||||||
if (js.entries && !isFunction(js.entries)) {
|
|
||||||
return Im.OrderedMap(js.entries).map(fromJSOrdered)
|
|
||||||
}
|
|
||||||
return Im.OrderedMap(js).map(fromJSOrdered)
|
return Im.OrderedMap(js).map(fromJSOrdered)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,11 +94,21 @@ export function fromJSOrdered(js) {
|
|||||||
* Append a hashIdx and counter to the key name, if multiple exists
|
* Append a hashIdx and counter to the key name, if multiple exists
|
||||||
* if single, key name = <original>
|
* if single, key name = <original>
|
||||||
* if multiple, key name = <original><hashIdx><count>
|
* if multiple, key name = <original><hashIdx><count>
|
||||||
|
* @example <caption>single entry for vegetable</caption>
|
||||||
|
* fdObj.entries.vegtables: "carrot"
|
||||||
|
* // returns newObj.vegetables : "carrot"
|
||||||
|
* @example <caption>multiple entries for fruits[]</caption>
|
||||||
|
* fdObj.entries.fruits[]: "apple"
|
||||||
|
* // returns newObj.fruits[]_**[]1 : "apple"
|
||||||
|
* fdObj.entries.fruits[]: "banana"
|
||||||
|
* // returns newObj.fruits[]_**[]2 : "banana"
|
||||||
|
* fdObj.entries.fruits[]: "grape"
|
||||||
|
* // returns newObj.fruits[]_**[]3 : "grape"
|
||||||
* @param {FormData} fdObj - a FormData object
|
* @param {FormData} fdObj - a FormData object
|
||||||
* @return {Object} - a plain object
|
* @return {Object} - a plain object
|
||||||
*/
|
*/
|
||||||
export function createObjWithHashedKeys (fdObj) {
|
export function createObjWithHashedKeys (fdObj) {
|
||||||
if (!fdObj.entries) {
|
if (!isFunction(fdObj.entries)) {
|
||||||
return fdObj // not a FormData object with iterable
|
return fdObj // not a FormData object with iterable
|
||||||
}
|
}
|
||||||
const newObj = {}
|
const newObj = {}
|
||||||
|
|||||||
@@ -1,12 +1,42 @@
|
|||||||
describe("Entries should be valid property name", () => {
|
describe("Entries should be valid property name", () => {
|
||||||
it("should render a OAS3.0 definition that uses 'entries' as a property name", () => {
|
it("should render a OAS3.0 definition that uses 'entries' as a 'components' property name", () => {
|
||||||
cy.visit("/?url=/documents/bugs/6016-oas3.yaml")
|
cy.visit("/?url=/documents/bugs/6016-oas3.yaml")
|
||||||
.get("#operations-tag-default")
|
.get("#operations-tag-default")
|
||||||
.should("exist")
|
.should("exist")
|
||||||
})
|
})
|
||||||
it("should render a OAS2.0 definition that uses 'entries' as a property name", () => {
|
it("should render expanded Operations of OAS3.0 definition that uses 'entries' as a 'components' property name", () => {
|
||||||
|
cy.visit("/?url=/documents/bugs/6016-oas3.yaml")
|
||||||
|
.get("#operations-default-test_test__get")
|
||||||
|
.click()
|
||||||
|
.get("#operations-default-test_test__get > div .opblock-body")
|
||||||
|
.should("exist")
|
||||||
|
|
||||||
|
})
|
||||||
|
it("should render expanded Models of OAS3.0 definition that uses 'entries' as a 'components' property name", () => {
|
||||||
|
cy.visit("/?url=/documents/bugs/6016-oas3.yaml")
|
||||||
|
.get("#model-Testmodel > span .model-box")
|
||||||
|
.click()
|
||||||
|
.get("div .model-box")
|
||||||
|
.should("exist")
|
||||||
|
})
|
||||||
|
it("should render a OAS2.0 definition that uses 'entries' as a 'definitions' property name", () => {
|
||||||
cy.visit("/?url=/documents/bugs/6016-oas2.yaml")
|
cy.visit("/?url=/documents/bugs/6016-oas2.yaml")
|
||||||
.get("#operations-default-post_pet")
|
.get("#operations-default-post_pet")
|
||||||
.should("exist")
|
.should("exist")
|
||||||
})
|
})
|
||||||
|
it("should render expanded Operations of OAS2.0 definition that uses 'entries' as a 'definitions' property name", () => {
|
||||||
|
cy.visit("/?url=/documents/bugs/6016-oas2.yaml")
|
||||||
|
.get("#operations-default-post_pet")
|
||||||
|
.click()
|
||||||
|
.get("#operations-default-post_pet > div .opblock-body")
|
||||||
|
.should("exist")
|
||||||
|
|
||||||
|
})
|
||||||
|
it("should render expanded Models of OAS2.0 definition that uses 'entries' as a 'defintions' property name", () => {
|
||||||
|
cy.visit("/?url=/documents/bugs/6016-oas2.yaml")
|
||||||
|
.get("#model-Pet > span .model-box")
|
||||||
|
.click()
|
||||||
|
.get("div .model-box")
|
||||||
|
.should("exist")
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user