Skip to content

Commit

Permalink
feat: Display example value in Swagger ReadOnly documentation (#4422)
Browse files Browse the repository at this point in the history
  • Loading branch information
dedece35 committed Jun 15, 2020
1 parent 973e1f7 commit ca1b19a
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/core/components/parameter-row.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,11 @@ export default class ParameterRow extends Component {
: null
}

{ (bodyParam || !isExecute) && paramExample !== undefined ?
<Markdown source={"<i>Example</i> : " + paramExample}/>
: null
}

{(isFormData && !isFormDataSupported) && <div>Error: your browser does not support FormData</div>}

{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
describe("parameter example rendering", function () {
describe("swagger 2.0", () => {
beforeEach(function (client, done) {
client
.url("localhost:3230")
.page.main()

client.waitForElementVisible(".download-url-input:not([disabled])", 5000)
.clearValue(".download-url-input")
.setValue(".download-url-input", "/test-specs/features/example.swagger.yaml")
.click("button.download-url-button")
.waitForElementVisible(".opblock", 10000)
.click("#operations-default-put_one")
.waitForElementVisible("#operations-default-put_one.is-open", 5000)

done()
})
afterEach(function (client, done) {
done()
})
it("reveals a string parameter's example when viewing that parameter", function (client) {
client.waitForElementVisible(".opblock-tag-section", 10000)
.assert.containsText(".opblock-summary-path span", "/one")
.click(".opblock")
.waitForElementVisible(".opblock.is-open", 5000)
.pause(500)
.assert.containsText(`tr[data-param-name="ValidParam"]`, `12345`)

client.end()
})

})
describe("openapi 3.0", () => {
beforeEach(function (client, done) {
client
.url("localhost:3230")
.page.main()

client.waitForElementVisible(".download-url-input:not([disabled])", 5000)
.clearValue(".download-url-input")
.setValue(".download-url-input", "/test-specs/features/example.openapi.yaml")
.click("button.download-url-button")
.waitForElementVisible(".opblock-summary-description", 10000)
.click("#operations-agent-editAgent")
.waitForElementVisible("#operations-agent-editAgent.is-open", 5000)

done()
})
afterEach(function (client, done) {
done()
})
it("reveals a string parameter's example when viewing that parameter", function (client) {
it("should respect a primitive example value", function(client) {
client
.assert.value(
`div.parameters-container > div > table > tbody > tr > td.col.parameters-col_description > input[type="text"]`,
`12345`
)

client.end()
})
})
})
})

0 comments on commit ca1b19a

Please sign in to comment.