Skip to content

Commit d827bd5

Browse files
dedece35mattyb678
authored andcommitted
feat: Display example value in Swagger ReadOnly documentation (swagger-api#4422)
1 parent 49d2c2f commit d827bd5

File tree

2 files changed

+69
-0
lines changed

2 files changed

+69
-0
lines changed

src/core/components/parameter-row.jsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,11 @@ export default class ParameterRow extends Component {
294294
: null
295295
}
296296

297+
{ (bodyParam || !isExecute) && paramExample !== undefined ?
298+
<Markdown source={"<i>Example</i> : " + paramExample}/>
299+
: null
300+
}
301+
297302
{(isFormData && !isFormDataSupported) && <div>Error: your browser does not support FormData</div>}
298303

299304
{
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
describe("parameter example rendering", function () {
2+
describe("swagger 2.0", () => {
3+
beforeEach(function (client, done) {
4+
client
5+
.url("localhost:3230")
6+
.page.main()
7+
8+
client.waitForElementVisible(".download-url-input:not([disabled])", 5000)
9+
.clearValue(".download-url-input")
10+
.setValue(".download-url-input", "/test-specs/features/example.swagger.yaml")
11+
.click("button.download-url-button")
12+
.waitForElementVisible(".opblock", 10000)
13+
.click("#operations-default-put_one")
14+
.waitForElementVisible("#operations-default-put_one.is-open", 5000)
15+
16+
done()
17+
})
18+
afterEach(function (client, done) {
19+
done()
20+
})
21+
it("reveals a string parameter's example when viewing that parameter", function (client) {
22+
client.waitForElementVisible(".opblock-tag-section", 10000)
23+
.assert.containsText(".opblock-summary-path span", "/one")
24+
.click(".opblock")
25+
.waitForElementVisible(".opblock.is-open", 5000)
26+
.pause(500)
27+
.assert.containsText(`tr[data-param-name="ValidParam"]`, `12345`)
28+
29+
client.end()
30+
})
31+
32+
})
33+
describe("openapi 3.0", () => {
34+
beforeEach(function (client, done) {
35+
client
36+
.url("localhost:3230")
37+
.page.main()
38+
39+
client.waitForElementVisible(".download-url-input:not([disabled])", 5000)
40+
.clearValue(".download-url-input")
41+
.setValue(".download-url-input", "/test-specs/features/example.openapi.yaml")
42+
.click("button.download-url-button")
43+
.waitForElementVisible(".opblock-summary-description", 10000)
44+
.click("#operations-agent-editAgent")
45+
.waitForElementVisible("#operations-agent-editAgent.is-open", 5000)
46+
47+
done()
48+
})
49+
afterEach(function (client, done) {
50+
done()
51+
})
52+
it("reveals a string parameter's example when viewing that parameter", function (client) {
53+
it("should respect a primitive example value", function(client) {
54+
client
55+
.assert.value(
56+
`div.parameters-container > div > table > tbody > tr > td.col.parameters-col_description > input[type="text"]`,
57+
`12345`
58+
)
59+
60+
client.end()
61+
})
62+
})
63+
})
64+
})

0 commit comments

Comments
 (0)