fix: use null as a notSetValue for examplesForMediaType (via #5503)

* fix: use null as a notSetValue for examplesForMediaType

fixes #5455

* tests!
This commit is contained in:
kyle
2019-07-29 21:44:14 -05:00
committed by GitHub
parent f53e611071
commit e895fb544f
3 changed files with 37 additions and 1 deletions

View File

@@ -67,7 +67,7 @@ const RequestBody = ({
const mediaTypeValue = requestBodyContent.get(contentType, OrderedMap()) const mediaTypeValue = requestBodyContent.get(contentType, OrderedMap())
const schemaForMediaType = mediaTypeValue.get("schema", OrderedMap()) const schemaForMediaType = mediaTypeValue.get("schema", OrderedMap())
const examplesForMediaType = mediaTypeValue.get("examples", OrderedMap()) const examplesForMediaType = mediaTypeValue.get("examples", null)
const handleExamplesSelect = (key /*, { isSyntheticChange } */) => { const handleExamplesSelect = (key /*, { isSyntheticChange } */) => {
updateActiveExamplesKey(key) updateActiveExamplesKey(key)

View File

@@ -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

View File

@@ -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 <select> element", () => {
cy.visit("/?url=/documents/bugs/5455.yaml")
.get("#operations-default-post_foo")
.click()
.get(".opblock-section-request-body > .opblock-description-wrapper")
.should("not.have.descendants", "select")
})
})