-
Notifications
You must be signed in to change notification settings - Fork 9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: avoid rendering empty response schemas (#9667)
Refs #9666 Co-authored-by: Pierre Paysant-Le Roux <[email protected]>
- Loading branch information
Showing
3 changed files
with
75 additions
and
1 deletion.
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
39 changes: 39 additions & 0 deletions
39
test/e2e-cypress/e2e/features/default-model-rendering.cy.js
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,39 @@ | ||
/** | ||
* @prettier | ||
*/ | ||
|
||
describe("defaultModelRendering set to model", () => { | ||
it("should not render schemas for responses with no defined schemas", () => { | ||
cy.visit( | ||
"/?defaultModelRendering=model&url=/documents/features/default-model-rendering.yaml" | ||
) | ||
.get("#operations-default-get_") | ||
.click() | ||
.get( | ||
"#operations-default-get_ [data-code=200] .response-col_description__inner" | ||
) | ||
.contains("no content") | ||
.get("#operations-default-get_ [data-code=200] .model-example") | ||
.should("not.exist") | ||
.get( | ||
"#operations-default-get_ [data-code=201] .response-col_description__inner" | ||
) | ||
.contains("no schema but an example") | ||
.get("#operations-default-get_ [data-code=201] .model-example") | ||
.contains('"foo": "bar"') | ||
.should("exist") | ||
.get( | ||
"#operations-default-get_ [data-code=202] .response-col_description__inner" | ||
) | ||
.contains("no schema but examples") | ||
.get("#operations-default-get_ [data-code=202] .model-example") | ||
.contains('"foo": "bar"') | ||
.should("exist") | ||
.get( | ||
"#operations-default-get_ [data-code=203] .response-col_description__inner" | ||
) | ||
.contains("no schema no example") | ||
.get("#operations-default-get_ [data-code=203] .model-example") | ||
.should("not.exist") | ||
}) | ||
}) |
31 changes: 31 additions & 0 deletions
31
test/e2e-cypress/static/documents/features/default-model-rendering.yaml
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,31 @@ | ||
openapi: 3.1.0 | ||
info: | ||
title: Empty response test case | ||
version: '1' | ||
paths: | ||
'/': | ||
get: | ||
responses: | ||
'200': | ||
description: no content | ||
'201': | ||
description: no schema but an example | ||
content: | ||
application/json: | ||
example: | ||
foo: bar | ||
'202': | ||
description: no schema but examples | ||
content: | ||
application/json: | ||
examples: | ||
first: | ||
value: | ||
foo: bar | ||
second: | ||
value: | ||
baz: foobar | ||
'203': | ||
description: no schema no example | ||
content: | ||
application/json: {} |