Skip to content

Commit e895fb5

Browse files
authored
fix: use null as a notSetValue for examplesForMediaType (via #5503)
* fix: use null as a notSetValue for examplesForMediaType fixes #5455 * tests!
1 parent f53e611 commit e895fb5

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

src/core/plugins/oas3/components/request-body.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ const RequestBody = ({
6767

6868
const mediaTypeValue = requestBodyContent.get(contentType, OrderedMap())
6969
const schemaForMediaType = mediaTypeValue.get("schema", OrderedMap())
70-
const examplesForMediaType = mediaTypeValue.get("examples", OrderedMap())
70+
const examplesForMediaType = mediaTypeValue.get("examples", null)
7171

7272
const handleExamplesSelect = (key /*, { isSyntheticChange } */) => {
7373
updateActiveExamplesKey(key)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
openapi: 3.0.2
2+
info:
3+
title: test
4+
version: 1.0.0
5+
paths:
6+
/foo:
7+
post:
8+
requestBody:
9+
required: true
10+
content:
11+
application/json:
12+
schema:
13+
$ref: '#/components/schemas/Foo'
14+
responses:
15+
201:
16+
description: Created
17+
18+
components:
19+
schemas:
20+
Foo:
21+
type: object
22+
properties:
23+
foo:
24+
type: string
25+
example: bar
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/5455
2+
3+
describe("#5455: Request bodies w/o `examples` should not render a dropdown", () => {
4+
it("should not render a <select> element", () => {
5+
cy.visit("/?url=/documents/bugs/5455.yaml")
6+
.get("#operations-default-post_foo")
7+
.click()
8+
.get(".opblock-section-request-body > .opblock-description-wrapper")
9+
.should("not.have.descendants", "select")
10+
})
11+
})

0 commit comments

Comments
 (0)