-
Notifications
You must be signed in to change notification settings - Fork 8.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
3 changed files
with
151 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
}) | ||
}) | ||
}) |