diff --git a/src/core/utils.js b/src/core/utils.js index 1ef08971562..e3bab7189fa 100644 --- a/src/core/utils.js +++ b/src/core/utils.js @@ -86,9 +86,6 @@ export function fromJSOrdered(js) { const objWithHashedKeys = createObjWithHashedKeys(js) 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) } @@ -97,11 +94,21 @@ export function fromJSOrdered(js) { * Append a hashIdx and counter to the key name, if multiple exists * if single, key name = * if multiple, key name = + * @example single entry for vegetable + * fdObj.entries.vegtables: "carrot" + * // returns newObj.vegetables : "carrot" + * @example multiple entries for fruits[] + * 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 * @return {Object} - a plain object */ export function createObjWithHashedKeys (fdObj) { - if (!fdObj.entries) { + if (!isFunction(fdObj.entries)) { return fdObj // not a FormData object with iterable } const newObj = {} diff --git a/test/e2e-cypress/tests/bugs/6016.js b/test/e2e-cypress/tests/bugs/6016.js index ef82bf822d2..d65142f3491 100644 --- a/test/e2e-cypress/tests/bugs/6016.js +++ b/test/e2e-cypress/tests/bugs/6016.js @@ -1,12 +1,42 @@ 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") .get("#operations-tag-default") .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") .get("#operations-default-post_pet") .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") + }) })