Skip to content

Commit 3a65070

Browse files
authoredMay 20, 2020
fix: entries as property name (#6025)
1 parent b85ae03 commit 3a65070

File tree

4 files changed

+76
-1
lines changed

4 files changed

+76
-1
lines changed
 

‎src/core/utils.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import _memoize from "lodash/memoize"
1818
import find from "lodash/find"
1919
import some from "lodash/some"
2020
import eq from "lodash/eq"
21+
import isFunction from "lodash/isFunction"
2122
import { memoizedSampleFromSchema, memoizedCreateXMLExample } from "core/plugins/samples/fn"
2223
import win from "./window"
2324
import cssEscape from "css.escape"
@@ -80,11 +81,14 @@ export function fromJSOrdered(js) {
8081
if (Array.isArray(js)) {
8182
return Im.Seq(js).map(fromJSOrdered).toList()
8283
}
83-
if (js.entries) {
84+
if (isFunction(js.entries)) {
8485
// handle multipart/form-data
8586
const objWithHashedKeys = createObjWithHashedKeys(js)
8687
return Im.OrderedMap(objWithHashedKeys).map(fromJSOrdered)
8788
}
89+
if (js.entries && !isFunction(js.entries)) {
90+
return Im.OrderedMap(js.entries).map(fromJSOrdered)
91+
}
8892
return Im.OrderedMap(js).map(fromJSOrdered)
8993
}
9094

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
swagger: "2.0"
2+
info:
3+
description: "OAS2 sample with entries as property name"
4+
version: "0.0.1"
5+
title: "Swagger Sample"
6+
paths:
7+
/pet:
8+
post:
9+
summary: "Add a new pet to the store"
10+
description: ""
11+
parameters:
12+
- in: "body"
13+
name: "body"
14+
schema:
15+
$ref: "#/definitions/Pet"
16+
responses:
17+
"405":
18+
description: "Invalid input"
19+
definitions:
20+
Pet:
21+
type: "object"
22+
properties:
23+
id:
24+
type: "integer"
25+
entries: # <-- evaluate
26+
type: "array"
27+
items:
28+
type: "string"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
openapi: 3.0.2
2+
info:
3+
title: OAS 3.0 sample with entries as property name
4+
version: 0.1.0
5+
paths:
6+
/test/:
7+
get:
8+
summary: Test
9+
operationId: test_test__get
10+
responses:
11+
'200':
12+
description: Successful Response
13+
content:
14+
application/json:
15+
schema:
16+
$ref: '#/components/schemas/Testmodel'
17+
components:
18+
schemas:
19+
Testmodel:
20+
title: Testmodel
21+
required:
22+
- name
23+
- entries
24+
type: object
25+
properties:
26+
name:
27+
title: Name
28+
type: string
29+
entries:
30+
title: Entries
31+
type: integer

‎test/e2e-cypress/tests/bugs/6016.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
describe("Entries should be valid property name", () => {
2+
it("should render a OAS3.0 definition that uses 'entries' as a property name", () => {
3+
cy.visit("/?url=/documents/bugs/6016-oas3.yaml")
4+
.get("#operations-tag-default")
5+
.should("exist")
6+
})
7+
it("should render a OAS2.0 definition that uses 'entries' as a property name", () => {
8+
cy.visit("/?url=/documents/bugs/6016-oas2.yaml")
9+
.get("#operations-default-post_pet")
10+
.should("exist")
11+
})
12+
})

0 commit comments

Comments
 (0)
Please sign in to comment.