Skip to content

Commit

Permalink
fix: Swagger 2.0 Response.examples, again (via #5465)
Browse files Browse the repository at this point in the history
* fix: Swagger 2.0 `Response.examples`

* stringify results
  • Loading branch information
shockey authored Jul 13, 2019
1 parent 9749a47 commit a9493a2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/core/components/response.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const getExampleComponent = ( sampleResponse, HighlightCode ) => {
sampleResponse !== undefined &&
sampleResponse !== null
) { return <div>
<HighlightCode className="example" value={ sampleResponse } />
<HighlightCode className="example" value={ stringify(sampleResponse) } />
</div>
}
return null
Expand Down
8 changes: 6 additions & 2 deletions test/e2e-cypress/tests/bugs/5458.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
// http://github.com/swagger-api/swagger-ui/issues/5458

const expectedValue = `{
"foo": "custom value"
}`

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")
.contains(expectedValue)
})
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")
.contains(expectedValue)
})
})

0 comments on commit a9493a2

Please sign in to comment.