Skip to content

Commit a9493a2

Browse files
authored
fix: Swagger 2.0 Response.examples, again (via #5465)
* fix: Swagger 2.0 `Response.examples` * stringify results
1 parent 9749a47 commit a9493a2

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/core/components/response.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const getExampleComponent = ( sampleResponse, HighlightCode ) => {
1010
sampleResponse !== undefined &&
1111
sampleResponse !== null
1212
) { return <div>
13-
<HighlightCode className="example" value={ sampleResponse } />
13+
<HighlightCode className="example" value={ stringify(sampleResponse) } />
1414
</div>
1515
}
1616
return null
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
// http://github.com/swagger-api/swagger-ui/issues/5458
22

3+
const expectedValue = `{
4+
"foo": "custom value"
5+
}`
6+
37
describe("#5458: Swagger 2.0 `Response.examples` mappings", () => {
48
it("should render a custom example when a schema is not defined", () => {
59
cy.visit("/?url=/documents/bugs/5458.yaml")
610
.get("#operations-default-get_foo1")
711
.click()
812
.get(".model-example .highlight-code")
9-
.contains("custom value")
13+
.contains(expectedValue)
1014
})
1115
it("should render a custom example when a schema is defined", () => {
1216
cy.visit("/?url=/documents/bugs/5458.yaml")
1317
.get("#operations-default-get_foo2")
1418
.click()
1519
.get(".model-example .highlight-code")
16-
.contains("custom value")
20+
.contains(expectedValue)
1721
})
1822
})

0 commit comments

Comments
 (0)