Skip to content

Commit e7dcdb3

Browse files
committed
test: add test to ensure xml request body
1 parent 050fd6b commit e7dcdb3

File tree

2 files changed

+122
-0
lines changed

2 files changed

+122
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
openapi: 3.0.1
2+
info:
3+
title: Example Swagger
4+
version: '1.0'
5+
servers:
6+
- url: /api/v1
7+
paths:
8+
/xmlTest/examples:
9+
post:
10+
summary: sample issues
11+
operationId: xmlTest_examples
12+
parameters: []
13+
requestBody:
14+
description: Simple Test xml examples
15+
content:
16+
application/xml:
17+
schema:
18+
$ref: "#/components/schemas/Test"
19+
examples:
20+
test:
21+
value:
22+
x: should be xml
23+
responses:
24+
'200':
25+
description: Simple Test xml examples
26+
content: {}
27+
/xmlTest/example:
28+
post:
29+
summary: sample issues
30+
operationId: xmlTest_example
31+
parameters: []
32+
requestBody:
33+
description: Simple Test xml example
34+
content:
35+
application/xml:
36+
schema:
37+
$ref: "#/components/schemas/Test"
38+
example:
39+
x: should be xml
40+
responses:
41+
'200':
42+
description: Simple Test xml example
43+
content: {}
44+
components:
45+
schemas:
46+
Test:
47+
type: object
48+
xml:
49+
name: root
50+
properties:
51+
x:
52+
type: string
53+
other:
54+
type: string
55+
format: email
56+
example:
57+
x: what the f

test/e2e-cypress/tests/bugs/6475.js

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
describe("#6475: 'Examples' keyword definitions can not be rendered as xml", () => {
2+
it("should render requestBody examples preview accourdingly to content-type xml", () => {
3+
const xmlIndicator = "<x>should be xml</x>"
4+
5+
cy
6+
.visit("?url=/documents/bugs/6475.yaml")
7+
.get("#operations-default-xmlTest_examples")
8+
.click()
9+
.get(".opblock-section-request-body")
10+
.within(() => {
11+
cy
12+
.get(".microlight")
13+
.should("include.text", xmlIndicator)
14+
})
15+
})
16+
it("should requestBody examples input accourdingly to content-type xml", () => {
17+
const xmlIndicator = "<x>should be xml</x>"
18+
19+
cy
20+
.visit("?url=/documents/bugs/6475.yaml")
21+
.get("#operations-default-xmlTest_examples")
22+
.click()
23+
.get(".btn.try-out__btn")
24+
.click()
25+
.get(".opblock-section-request-body")
26+
.within(() => {
27+
cy
28+
.get("textarea")
29+
.contains(xmlIndicator)
30+
})
31+
})
32+
})
33+
34+
describe("#6475: 'Example' keyword definitions can not be rendered as xml", () => {
35+
it("should render requestBody examples preview accourdingly to content-type xml", () => {
36+
const xmlIndicator = "<x>should be xml</x>"
37+
38+
cy
39+
.visit("?url=/documents/bugs/6475.yaml")
40+
.get("#operations-default-xmlTest_example")
41+
.click()
42+
.get(".opblock-section-request-body")
43+
.within(() => {
44+
cy
45+
.get(".microlight")
46+
.should("include.text", xmlIndicator)
47+
})
48+
})
49+
it("should requestBody examples input accourdingly to content-type xml", () => {
50+
const xmlIndicator = "<x>should be xml</x>"
51+
52+
cy
53+
.visit("?url=/documents/bugs/6475.yaml")
54+
.get("#operations-default-xmlTest_example")
55+
.click()
56+
.get(".btn.try-out__btn")
57+
.click()
58+
.get(".opblock-section-request-body")
59+
.within(() => {
60+
cy
61+
.get("textarea")
62+
.contains(xmlIndicator)
63+
})
64+
})
65+
})

0 commit comments

Comments
 (0)