Request Body examples should respect media-type (#6739)
* fix: request body.jsx should rely on the getSampleSchema utility * test: add test to ensure xml request body
This commit is contained in:
57
test/e2e-cypress/static/documents/bugs/6475.yaml
Normal file
57
test/e2e-cypress/static/documents/bugs/6475.yaml
Normal file
@@ -0,0 +1,57 @@
|
||||
openapi: 3.0.1
|
||||
info:
|
||||
title: Example Swagger
|
||||
version: '1.0'
|
||||
servers:
|
||||
- url: /api/v1
|
||||
paths:
|
||||
/xmlTest/examples:
|
||||
post:
|
||||
summary: sample issues
|
||||
operationId: xmlTest_examples
|
||||
parameters: []
|
||||
requestBody:
|
||||
description: Simple Test xml examples
|
||||
content:
|
||||
application/xml:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Test"
|
||||
examples:
|
||||
test:
|
||||
value:
|
||||
x: should be xml
|
||||
responses:
|
||||
'200':
|
||||
description: Simple Test xml examples
|
||||
content: {}
|
||||
/xmlTest/example:
|
||||
post:
|
||||
summary: sample issues
|
||||
operationId: xmlTest_example
|
||||
parameters: []
|
||||
requestBody:
|
||||
description: Simple Test xml example
|
||||
content:
|
||||
application/xml:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Test"
|
||||
example:
|
||||
x: should be xml
|
||||
responses:
|
||||
'200':
|
||||
description: Simple Test xml example
|
||||
content: {}
|
||||
components:
|
||||
schemas:
|
||||
Test:
|
||||
type: object
|
||||
xml:
|
||||
name: root
|
||||
properties:
|
||||
x:
|
||||
type: string
|
||||
other:
|
||||
type: string
|
||||
format: email
|
||||
example:
|
||||
x: what the f
|
||||
65
test/e2e-cypress/tests/bugs/6475.js
Normal file
65
test/e2e-cypress/tests/bugs/6475.js
Normal file
@@ -0,0 +1,65 @@
|
||||
describe("#6475: 'Examples' keyword definitions can not be rendered as xml", () => {
|
||||
it("should render requestBody examples preview accourdingly to content-type xml", () => {
|
||||
const xmlIndicator = "<x>should be xml</x>"
|
||||
|
||||
cy
|
||||
.visit("?url=/documents/bugs/6475.yaml")
|
||||
.get("#operations-default-xmlTest_examples")
|
||||
.click()
|
||||
.get(".opblock-section-request-body")
|
||||
.within(() => {
|
||||
cy
|
||||
.get(".microlight")
|
||||
.should("include.text", xmlIndicator)
|
||||
})
|
||||
})
|
||||
it("should requestBody examples input accourdingly to content-type xml", () => {
|
||||
const xmlIndicator = "<x>should be xml</x>"
|
||||
|
||||
cy
|
||||
.visit("?url=/documents/bugs/6475.yaml")
|
||||
.get("#operations-default-xmlTest_examples")
|
||||
.click()
|
||||
.get(".btn.try-out__btn")
|
||||
.click()
|
||||
.get(".opblock-section-request-body")
|
||||
.within(() => {
|
||||
cy
|
||||
.get("textarea")
|
||||
.contains(xmlIndicator)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe("#6475: 'Example' keyword definitions can not be rendered as xml", () => {
|
||||
it("should render requestBody examples preview accourdingly to content-type xml", () => {
|
||||
const xmlIndicator = "<x>should be xml</x>"
|
||||
|
||||
cy
|
||||
.visit("?url=/documents/bugs/6475.yaml")
|
||||
.get("#operations-default-xmlTest_example")
|
||||
.click()
|
||||
.get(".opblock-section-request-body")
|
||||
.within(() => {
|
||||
cy
|
||||
.get(".microlight")
|
||||
.should("include.text", xmlIndicator)
|
||||
})
|
||||
})
|
||||
it("should requestBody examples input accourdingly to content-type xml", () => {
|
||||
const xmlIndicator = "<x>should be xml</x>"
|
||||
|
||||
cy
|
||||
.visit("?url=/documents/bugs/6475.yaml")
|
||||
.get("#operations-default-xmlTest_example")
|
||||
.click()
|
||||
.get(".btn.try-out__btn")
|
||||
.click()
|
||||
.get(".opblock-section-request-body")
|
||||
.within(() => {
|
||||
cy
|
||||
.get("textarea")
|
||||
.contains(xmlIndicator)
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user