From 6119ce8690948494f9e15dade01074acb2acaf8e Mon Sep 17 00:00:00 2001 From: Kyle Shockey Date: Mon, 29 Jul 2019 21:12:40 -0500 Subject: [PATCH 1/2] fix: use null as a notSetValue for examplesForMediaType fixes #5455 --- src/core/plugins/oas3/components/request-body.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/plugins/oas3/components/request-body.jsx b/src/core/plugins/oas3/components/request-body.jsx index 00b5d97d31d..4b287f12cee 100644 --- a/src/core/plugins/oas3/components/request-body.jsx +++ b/src/core/plugins/oas3/components/request-body.jsx @@ -67,7 +67,7 @@ const RequestBody = ({ const mediaTypeValue = requestBodyContent.get(contentType, OrderedMap()) const schemaForMediaType = mediaTypeValue.get("schema", OrderedMap()) - const examplesForMediaType = mediaTypeValue.get("examples", OrderedMap()) + const examplesForMediaType = mediaTypeValue.get("examples", null) const handleExamplesSelect = (key /*, { isSyntheticChange } */) => { updateActiveExamplesKey(key) From 14cfdf5c2ae741b9b0fa400902fdfc7fc162867f Mon Sep 17 00:00:00 2001 From: Kyle Shockey Date: Mon, 29 Jul 2019 21:36:10 -0500 Subject: [PATCH 2/2] tests! --- .../static/documents/bugs/5455.yaml | 25 +++++++++++++++++++ test/e2e-cypress/tests/bugs/5455.js | 11 ++++++++ 2 files changed, 36 insertions(+) create mode 100644 test/e2e-cypress/static/documents/bugs/5455.yaml create mode 100644 test/e2e-cypress/tests/bugs/5455.js diff --git a/test/e2e-cypress/static/documents/bugs/5455.yaml b/test/e2e-cypress/static/documents/bugs/5455.yaml new file mode 100644 index 00000000000..70d9ae1420e --- /dev/null +++ b/test/e2e-cypress/static/documents/bugs/5455.yaml @@ -0,0 +1,25 @@ +openapi: 3.0.2 +info: + title: test + version: 1.0.0 +paths: + /foo: + post: + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/Foo' + responses: + 201: + description: Created + +components: + schemas: + Foo: + type: object + properties: + foo: + type: string + example: bar diff --git a/test/e2e-cypress/tests/bugs/5455.js b/test/e2e-cypress/tests/bugs/5455.js new file mode 100644 index 00000000000..338cb5804f2 --- /dev/null +++ b/test/e2e-cypress/tests/bugs/5455.js @@ -0,0 +1,11 @@ +// http://github.com/swagger-api/swagger-ui/issues/5455 + +describe("#5455: Request bodies w/o `examples` should not render a dropdown", () => { + it("should not render a