Skip to content

Commit d903532

Browse files
authored
pass meta error information to JsonSchemaForm correctly (#4416)
* tests: add failing e2e tests * fix: pass meta error information to JsonSchemaForm correctly
1 parent 4480db0 commit d903532

File tree

3 files changed

+261
-1
lines changed

3 files changed

+261
-1
lines changed

src/core/components/parameter-row.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ export default class ParameterRow extends Component {
188188
required={ required }
189189
description={param.get("description") ? `${param.get("name")} - ${param.get("description")}` : `${param.get("name")}`}
190190
onChange={ this.onChangeWrapper }
191-
errors={ param.get("errors") }
191+
errors={ paramWithMeta.get("errors") }
192192
schema={ isOAS3 && isOAS3() ? param.get("schema") : param }/>
193193
}
194194

test/e2e/scenarios/bugs/4374.js

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
describe("bug #4374: OAS3 parameters should be visibly validated in Try-It-Out", function () {
2+
let mainPage
3+
beforeEach(function (client, done) {
4+
mainPage = client
5+
.url("localhost:3230")
6+
.page.main()
7+
8+
client.waitForElementVisible(".download-url-input", 10000)
9+
.pause(1000)
10+
.clearValue(".download-url-input")
11+
.setValue(".download-url-input", "http://localhost:3230/test-specs/bugs/4374.yaml")
12+
.click("button.download-url-button")
13+
.pause(1000)
14+
15+
done()
16+
})
17+
afterEach(function (client, done) {
18+
done()
19+
})
20+
it("indicates an error when a required parameter is not selected", function (client) {
21+
client.waitForElementVisible(".opblock-tag-section", 10000)
22+
.assert.containsText(".opblock-summary-path span", "/pet/findByStatus")
23+
.click(".opblock")
24+
.waitForElementVisible(".opblock.is-open", 5000)
25+
.click(".try-out__btn")
26+
.click(".btn.execute")
27+
.pause(100)
28+
.assert.cssClassPresent(".parameters-col_description select", "invalid")
29+
30+
client.end()
31+
})
32+
})

test/e2e/specs/bugs/4374.yaml

+228
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,228 @@
1+
---
2+
openapi: 3.0.0
3+
servers:
4+
- url: http://localhost:3204/
5+
info:
6+
description: 'This is a sample server Petstore server. You can find out more about
7+
Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For
8+
this sample, you can use the api key `special-key` to test the authorization filters.'
9+
version: 1.0.0
10+
title: Swagger Petstore
11+
termsOfService: http://swagger.io/terms/
12+
contact:
13+
14+
license:
15+
name: Apache 2.0
16+
url: http://www.apache.org/licenses/LICENSE-2.0.html
17+
tags:
18+
- name: pet
19+
description: Everything about your Pets
20+
externalDocs:
21+
description: Find out more
22+
url: http://swagger.io
23+
- name: store
24+
description: Access to Petstore orders
25+
- name: user
26+
description: Operations about user
27+
externalDocs:
28+
description: Find out more about our store
29+
url: http://swagger.io
30+
paths:
31+
"/pet/findByStatus":
32+
get:
33+
tags:
34+
- pet
35+
summary: Finds Pets by status
36+
description: Multiple status values can be provided with comma separated strings
37+
operationId: findPetsByStatus
38+
parameters:
39+
- name: status
40+
in: query
41+
description: Status values that need to be considered for filter
42+
required: true
43+
explode: true
44+
schema:
45+
type: array
46+
items:
47+
type: string
48+
enum:
49+
- available
50+
- pending
51+
- sold
52+
default: available
53+
responses:
54+
'200':
55+
description: successful operation
56+
content:
57+
application/xml:
58+
schema:
59+
type: array
60+
items:
61+
"$ref": "#/components/schemas/Pet"
62+
application/json:
63+
schema:
64+
type: array
65+
items:
66+
"$ref": "#/components/schemas/Pet"
67+
'400':
68+
description: Invalid status value
69+
security:
70+
- petstore_auth:
71+
- write:pets
72+
- read:pets
73+
externalDocs:
74+
description: Find out more about Swagger
75+
url: http://swagger.io
76+
components:
77+
schemas:
78+
Order:
79+
type: object
80+
properties:
81+
id:
82+
type: integer
83+
format: int64
84+
petId:
85+
type: integer
86+
format: int64
87+
quantity:
88+
type: integer
89+
format: int32
90+
shipDate:
91+
type: string
92+
format: date-time
93+
status:
94+
type: string
95+
description: Order Status
96+
enum:
97+
- placed
98+
- approved
99+
- delivered
100+
complete:
101+
type: boolean
102+
default: false
103+
xml:
104+
name: Order
105+
Category:
106+
type: object
107+
properties:
108+
id:
109+
type: integer
110+
format: int64
111+
name:
112+
type: string
113+
xml:
114+
name: Category
115+
User:
116+
type: object
117+
properties:
118+
id:
119+
type: integer
120+
format: int64
121+
username:
122+
type: string
123+
firstName:
124+
type: string
125+
lastName:
126+
type: string
127+
email:
128+
type: string
129+
password:
130+
type: string
131+
phone:
132+
type: string
133+
userStatus:
134+
type: integer
135+
format: int32
136+
description: User Status
137+
xml:
138+
name: User
139+
Tag:
140+
type: object
141+
properties:
142+
id:
143+
type: integer
144+
format: int64
145+
name:
146+
type: string
147+
xml:
148+
name: Tag
149+
Pet:
150+
type: object
151+
required:
152+
- name
153+
- photoUrls
154+
properties:
155+
id:
156+
type: integer
157+
format: int64
158+
category:
159+
"$ref": "#/components/schemas/Category"
160+
name:
161+
type: string
162+
example: doggie
163+
photoUrls:
164+
type: array
165+
xml:
166+
name: photoUrl
167+
wrapped: true
168+
items:
169+
type: string
170+
tags:
171+
type: array
172+
xml:
173+
name: tag
174+
wrapped: true
175+
items:
176+
"$ref": "#/components/schemas/Tag"
177+
status:
178+
type: string
179+
description: pet status in the store
180+
enum:
181+
- available
182+
- pending
183+
- sold
184+
xml:
185+
name: Pet
186+
ApiResponse:
187+
type: object
188+
properties:
189+
code:
190+
type: integer
191+
format: int32
192+
type:
193+
type: string
194+
message:
195+
type: string
196+
requestBodies:
197+
Pet:
198+
content:
199+
application/json:
200+
schema:
201+
"$ref": "#/components/schemas/Pet"
202+
application/xml:
203+
schema:
204+
"$ref": "#/components/schemas/Pet"
205+
description: Pet object that needs to be added to the store
206+
required: true
207+
UserArray:
208+
content:
209+
application/json:
210+
schema:
211+
type: array
212+
items:
213+
"$ref": "#/components/schemas/User"
214+
description: List of user object
215+
required: true
216+
securitySchemes:
217+
petstore_auth:
218+
type: oauth2
219+
flows:
220+
implicit:
221+
authorizationUrl: http://petstore.swagger.io/oauth/dialog
222+
scopes:
223+
write:pets: modify pets in your account
224+
read:pets: read your pets
225+
api_key:
226+
type: apiKey
227+
name: api_key
228+
in: header

0 commit comments

Comments
 (0)