From 39f8ceba55cae435cfce7c4e0df55652261acfc5 Mon Sep 17 00:00:00 2001 From: kyle Date: Mon, 29 Jul 2019 22:15:19 -0500 Subject: [PATCH] fix: empty ModelExample rendering in a Response w/o `content` (via #5504) * add failing test * use falsy notSetValue for oas3SchemaForContentType --- src/core/components/response.jsx | 2 +- test/e2e-cypress/static/documents/bugs/5453.yaml | 10 ++++++++++ test/e2e-cypress/tests/bugs/5453.js | 11 +++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 test/e2e-cypress/static/documents/bugs/5453.yaml create mode 100644 test/e2e-cypress/tests/bugs/5453.js diff --git a/src/core/components/response.jsx b/src/core/components/response.jsx index 81d8ffb8..4a7e93d5 100644 --- a/src/core/components/response.jsx +++ b/src/core/components/response.jsx @@ -109,7 +109,7 @@ export default class Response extends React.Component { // Goal: find a schema value for `schema` if(isOAS3) { - const oas3SchemaForContentType = activeMediaType.get("schema", Map({})) + const oas3SchemaForContentType = activeMediaType.get("schema") schema = oas3SchemaForContentType ? inferSchema(oas3SchemaForContentType.toJS()) : null specPathWithPossibleSchema = oas3SchemaForContentType ? List(["content", this.state.responseContentType, "schema"]) : specPath diff --git a/test/e2e-cypress/static/documents/bugs/5453.yaml b/test/e2e-cypress/static/documents/bugs/5453.yaml new file mode 100644 index 00000000..fc604048 --- /dev/null +++ b/test/e2e-cypress/static/documents/bugs/5453.yaml @@ -0,0 +1,10 @@ +openapi: 3.0.2 +info: + title: Response without a schema + version: 1.0.0 +paths: + /foo: + get: + responses: + '200': + description: OK diff --git a/test/e2e-cypress/tests/bugs/5453.js b/test/e2e-cypress/tests/bugs/5453.js new file mode 100644 index 00000000..2430783a --- /dev/null +++ b/test/e2e-cypress/tests/bugs/5453.js @@ -0,0 +1,11 @@ +// http://github.com/swagger-api/swagger-ui/issues/5453 + + describe("#5453: Responses w/o `content` should not render ModelExample", () => { + it("should not render a ModelExample section", () => { + cy.visit("/?url=/documents/bugs/5453.yaml") + .get("#operations-default-get_foo") + .click() + .get(".responses-inner") + .should("not.have.descendants", ".model-example") + }) + })