-
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: Swagger 2.0
Response.examples
(via #5464)
- Loading branch information
Showing
3 changed files
with
67 additions
and
4 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,37 @@ | ||
swagger: "2.0" | ||
info: | ||
title: test | ||
version: 1.0.0 | ||
paths: | ||
/foo1: | ||
get: | ||
summary: Response without a schema | ||
produces: | ||
- application/json | ||
responses: | ||
200: | ||
description: Successful response | ||
examples: | ||
application/json: | ||
foo: custom value | ||
/foo2: | ||
get: | ||
summary: Response with schema | ||
produces: | ||
- application/json | ||
responses: | ||
200: | ||
description: Successful response | ||
schema: | ||
$ref: '#/definitions/Foo' | ||
examples: | ||
application/json: | ||
foo: custom value | ||
|
||
definitions: | ||
Foo: | ||
type: object | ||
properties: | ||
foo: | ||
type: string | ||
example: bar |
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,18 @@ | ||
// http://github.com/swagger-api/swagger-ui/issues/5458 | ||
|
||
describe("#5458: Swagger 2.0 `Response.examples` mappings", () => { | ||
it("should render a custom example when a schema is not defined", () => { | ||
cy.visit("/?url=/documents/bugs/5458.yaml") | ||
.get("#operations-default-get_foo1") | ||
.click() | ||
.get(".model-example .highlight-code") | ||
.contains("custom value") | ||
}) | ||
it("should render a custom example when a schema is defined", () => { | ||
cy.visit("/?url=/documents/bugs/5458.yaml") | ||
.get("#operations-default-get_foo2") | ||
.click() | ||
.get(".model-example .highlight-code") | ||
.contains("custom value") | ||
}) | ||
}) |