fix: entries as property name (#6025)
This commit is contained in:
@@ -18,6 +18,7 @@ import _memoize from "lodash/memoize"
|
||||
import find from "lodash/find"
|
||||
import some from "lodash/some"
|
||||
import eq from "lodash/eq"
|
||||
import isFunction from "lodash/isFunction"
|
||||
import { memoizedSampleFromSchema, memoizedCreateXMLExample } from "core/plugins/samples/fn"
|
||||
import win from "./window"
|
||||
import cssEscape from "css.escape"
|
||||
@@ -80,11 +81,14 @@ export function fromJSOrdered(js) {
|
||||
if (Array.isArray(js)) {
|
||||
return Im.Seq(js).map(fromJSOrdered).toList()
|
||||
}
|
||||
if (js.entries) {
|
||||
if (isFunction(js.entries)) {
|
||||
// handle multipart/form-data
|
||||
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)
|
||||
}
|
||||
|
||||
|
||||
28
test/e2e-cypress/static/documents/bugs/6016-oas2.yaml
Normal file
28
test/e2e-cypress/static/documents/bugs/6016-oas2.yaml
Normal file
@@ -0,0 +1,28 @@
|
||||
swagger: "2.0"
|
||||
info:
|
||||
description: "OAS2 sample with entries as property name"
|
||||
version: "0.0.1"
|
||||
title: "Swagger Sample"
|
||||
paths:
|
||||
/pet:
|
||||
post:
|
||||
summary: "Add a new pet to the store"
|
||||
description: ""
|
||||
parameters:
|
||||
- in: "body"
|
||||
name: "body"
|
||||
schema:
|
||||
$ref: "#/definitions/Pet"
|
||||
responses:
|
||||
"405":
|
||||
description: "Invalid input"
|
||||
definitions:
|
||||
Pet:
|
||||
type: "object"
|
||||
properties:
|
||||
id:
|
||||
type: "integer"
|
||||
entries: # <-- evaluate
|
||||
type: "array"
|
||||
items:
|
||||
type: "string"
|
||||
31
test/e2e-cypress/static/documents/bugs/6016-oas3.yaml
Normal file
31
test/e2e-cypress/static/documents/bugs/6016-oas3.yaml
Normal file
@@ -0,0 +1,31 @@
|
||||
openapi: 3.0.2
|
||||
info:
|
||||
title: OAS 3.0 sample with entries as property name
|
||||
version: 0.1.0
|
||||
paths:
|
||||
/test/:
|
||||
get:
|
||||
summary: Test
|
||||
operationId: test_test__get
|
||||
responses:
|
||||
'200':
|
||||
description: Successful Response
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Testmodel'
|
||||
components:
|
||||
schemas:
|
||||
Testmodel:
|
||||
title: Testmodel
|
||||
required:
|
||||
- name
|
||||
- entries
|
||||
type: object
|
||||
properties:
|
||||
name:
|
||||
title: Name
|
||||
type: string
|
||||
entries:
|
||||
title: Entries
|
||||
type: integer
|
||||
12
test/e2e-cypress/tests/bugs/6016.js
Normal file
12
test/e2e-cypress/tests/bugs/6016.js
Normal file
@@ -0,0 +1,12 @@
|
||||
describe("Entries should be valid property name", () => {
|
||||
it("should render a OAS3.0 definition that uses 'entries' as a 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", () => {
|
||||
cy.visit("/?url=/documents/bugs/6016-oas2.yaml")
|
||||
.get("#operations-default-post_pet")
|
||||
.should("exist")
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user