Skip to content

Commit 39f8ceb

Browse files
authored
fix: empty ModelExample rendering in a Response w/o content (via #5504)
* add failing test * use falsy notSetValue for oas3SchemaForContentType
1 parent e895fb5 commit 39f8ceb

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

src/core/components/response.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export default class Response extends React.Component {
109109

110110
// Goal: find a schema value for `schema`
111111
if(isOAS3) {
112-
const oas3SchemaForContentType = activeMediaType.get("schema", Map({}))
112+
const oas3SchemaForContentType = activeMediaType.get("schema")
113113

114114
schema = oas3SchemaForContentType ? inferSchema(oas3SchemaForContentType.toJS()) : null
115115
specPathWithPossibleSchema = oas3SchemaForContentType ? List(["content", this.state.responseContentType, "schema"]) : specPath
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
openapi: 3.0.2
2+
info:
3+
title: Response without a schema
4+
version: 1.0.0
5+
paths:
6+
/foo:
7+
get:
8+
responses:
9+
'200':
10+
description: OK
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// http://github.com/swagger-api/swagger-ui/issues/5453
2+
3+
describe("#5453: Responses w/o `content` should not render ModelExample", () => {
4+
it("should not render a ModelExample section", () => {
5+
cy.visit("/?url=/documents/bugs/5453.yaml")
6+
.get("#operations-default-get_foo")
7+
.click()
8+
.get(".responses-inner")
9+
.should("not.have.descendants", ".model-example")
10+
})
11+
})

0 commit comments

Comments
 (0)