Skip to content

Commit 22036b1

Browse files
authored
fix: OAS3 parameter value input bug (#4271)
1 parent 043e491 commit 22036b1

File tree

3 files changed

+745
-2
lines changed

3 files changed

+745
-2
lines changed

src/core/components/parameter-row.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,16 +98,17 @@ export default class ParameterRow extends Component {
9898
const Markdown = getComponent("Markdown")
9999
const ParameterExt = getComponent("ParameterExt")
100100

101+
let paramWithMeta = specSelectors.parameterWithMeta(pathMethod, param.get("name"), param.get("in"))
102+
101103
let schema = param.get("schema")
102104
let type = isOAS3 && isOAS3() ? param.getIn(["schema", "type"]) : param.get("type")
103105
let isFormData = inType === "formData"
104106
let isFormDataSupported = "FormData" in win
105107
let required = param.get("required")
106108
let itemType = param.getIn(isOAS3 && isOAS3() ? ["schema", "items", "type"] : ["items", "type"])
107-
let value = param ? param.get("value") : ""
109+
let value = paramWithMeta ? paramWithMeta.get("value") : ""
108110
let extensions = getExtensions(param)
109111

110-
111112
let paramItems // undefined
112113
let paramItemsEnum // undefined
113114
let isDisplayParamItemsEnum = false

test/e2e/scenarios/oas3/pet.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
describe("render pet api container", function () {
2+
let mainPage
3+
let apiWrapper
4+
beforeEach(function (client, done) {
5+
mainPage = client
6+
.url("localhost:3200")
7+
.page.main()
8+
9+
client.waitForElementVisible(".download-url-input", 5000)
10+
.pause(5000)
11+
.clearValue(".download-url-input")
12+
.setValue(".download-url-input", "http://localhost:3200/test-specs/petstore.openapi.yaml")
13+
.click("button.download-url-button")
14+
.pause(1000)
15+
16+
apiWrapper = mainPage.section.apiWrapper
17+
18+
done()
19+
})
20+
afterEach(function (client, done) {
21+
done()
22+
})
23+
describe("GET /pet/{petId}", () => {
24+
it("should render Try-It-Out flow correctly", function (client) {
25+
apiWrapper.waitForElementVisible("#operations-pet-updatePetWithForm", 10000)
26+
.assert.containsText("#operations-pet-updatePetWithForm > div > span.opblock-summary-path > a > span", "/pet")
27+
.click("#operations-pet-updatePetWithForm")
28+
.waitForElementVisible("#operations-pet-updatePetWithForm > div:nth-child(2) > div", 5000)
29+
.click("#operations-pet-updatePetWithForm > div:nth-child(2) > div > div.opblock-section > div.opblock-section-header > div.try-out > button")
30+
.waitForElementVisible("#operations-pet-updatePetWithForm > div:nth-child(2) > div > div.execute-wrapper > button", 1000)
31+
.click("#operations-pet-updatePetWithForm > div:nth-child(2) > div > div.execute-wrapper > button")
32+
.assert.cssClassNotPresent("#operations-pet-updatePetWithForm > div:nth-child(2) > div > div.execute-wrapper > button", "cancel")
33+
34+
client.end()
35+
})
36+
37+
it("should have stable input values", function (client) {
38+
client.waitForElementVisible("#operations-pet-updatePetWithForm", 10000)
39+
.assert.containsText("#operations-pet-updatePetWithForm > div > span.opblock-summary-path > a > span", "/pet")
40+
.click("#operations-pet-updatePetWithForm")
41+
.waitForElementVisible("#operations-pet-updatePetWithForm > div:nth-child(2) > div", 5000)
42+
.click("#operations-pet-updatePetWithForm > div:nth-child(2) > div > div.opblock-section > div.opblock-section-header > div.try-out > button")
43+
.waitForElementVisible("#operations-pet-updatePetWithForm > div:nth-child(2) > div > div.execute-wrapper > button", 1000)
44+
.setValue("#operations-pet-updatePetWithForm td.parameters-col_description > input", "12345")
45+
.click("#operations-pet-updatePetWithForm > div:nth-child(2) > div > div.execute-wrapper > button")
46+
.pause(800) // for swagger-api/swagger-ui#4269, which happens above 350ms
47+
.assert.containsText("#operations-pet-updatePetWithForm div.responses-inner > div > div > div:nth-child(2) > div > pre", "http://localhost:3204/pet/12345")
48+
.assert.value("#operations-pet-updatePetWithForm td.parameters-col_description > input", "12345")
49+
50+
client.end()
51+
})
52+
})
53+
})

0 commit comments

Comments
 (0)