Skip to content

Commit 1919217

Browse files
authored
Merge pull request #4957 from karenetheridge/ether/v3.2-schema-remnants
v3.2 schema edits
2 parents 16b60f8 + 2463bd0 commit 1919217

10 files changed

+154
-54
lines changed

src/schemas/validation/schema.yaml

Lines changed: 60 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ $defs:
204204
additionalProperties:
205205
$ref: '#/$defs/media-type-or-reference'
206206
patternProperties:
207-
'^(schemas|responses|parameters|examples|requestBodies|headers|securitySchemes|links|callbacks|pathItems|mediaTypes)$':
207+
'^(?:schemas|responses|parameters|examples|requestBodies|headers|securitySchemes|links|callbacks|pathItems|mediaTypes)$':
208208
$comment: Enumerating all of the property names in the regex above is necessary for unevaluatedProperties to work as expected
209209
propertyNames:
210210
pattern: '^[a-zA-Z0-9._-]+$'
@@ -236,9 +236,7 @@ $defs:
236236
items:
237237
$ref: '#/$defs/server'
238238
parameters:
239-
type: array
240-
items:
241-
$ref: '#/$defs/parameter-or-reference'
239+
$ref: '#/$defs/parameters'
242240
additionalOperations:
243241
type: object
244242
additionalProperties:
@@ -295,9 +293,7 @@ $defs:
295293
operationId:
296294
type: string
297295
parameters:
298-
type: array
299-
items:
300-
$ref: '#/$defs/parameter-or-reference'
296+
$ref: '#/$defs/parameters'
301297
requestBody:
302298
$ref: '#/$defs/request-body-or-reference'
303299
responses:
@@ -334,6 +330,36 @@ $defs:
334330
$ref: '#/$defs/specification-extensions'
335331
unevaluatedProperties: false
336332

333+
parameters:
334+
type: array
335+
items:
336+
$ref: '#/$defs/parameter-or-reference'
337+
not:
338+
allOf:
339+
- contains:
340+
type: object
341+
properties:
342+
in:
343+
const: query
344+
required:
345+
- in
346+
- contains:
347+
type: object
348+
properties:
349+
in:
350+
const: querystring
351+
required:
352+
- in
353+
contains:
354+
type: object
355+
properties:
356+
in:
357+
const: querystring
358+
required:
359+
- in
360+
minContains: 0
361+
maxContains: 1
362+
337363
parameter:
338364
$comment: https://spec.openapis.org/oas/v3.2#parameter-object
339365
type: object
@@ -376,8 +402,6 @@ $defs:
376402
properties:
377403
in:
378404
const: query
379-
required:
380-
- in
381405
then:
382406
properties:
383407
allowEmptyValue:
@@ -387,8 +411,6 @@ $defs:
387411
properties:
388412
in:
389413
const: querystring
390-
required:
391-
- in
392414
then:
393415
required:
394416
- content
@@ -415,8 +437,6 @@ $defs:
415437
properties:
416438
in:
417439
const: path
418-
required:
419-
- in
420440
then:
421441
properties:
422442
style:
@@ -435,8 +455,6 @@ $defs:
435455
properties:
436456
in:
437457
const: header
438-
required:
439-
- in
440458
then:
441459
properties:
442460
style:
@@ -448,8 +466,6 @@ $defs:
448466
properties:
449467
in:
450468
const: query
451-
required:
452-
- in
453469
then:
454470
properties:
455471
style:
@@ -465,13 +481,13 @@ $defs:
465481
properties:
466482
in:
467483
const: cookie
468-
required:
469-
- in
470484
then:
471485
properties:
472486
style:
473487
default: form
474-
const: form
488+
enum:
489+
- form
490+
- cookie
475491

476492
unevaluatedProperties: false
477493

@@ -539,14 +555,14 @@ $defs:
539555
$ref: '#/$defs/encoding'
540556
itemEncoding:
541557
$ref: '#/$defs/encoding'
558+
dependentSchemas:
559+
encoding:
560+
properties:
561+
prefixEncoding: false
562+
itemEncoding: false
542563
allOf:
543564
- $ref: '#/$defs/examples'
544565
- $ref: '#/$defs/specification-extensions'
545-
- dependentSchemas:
546-
encoding:
547-
properties:
548-
prefixEncoding: false
549-
itemEncoding: false
550566
unevaluatedProperties: false
551567

552568
media-type-or-reference:
@@ -571,7 +587,6 @@ $defs:
571587
additionalProperties:
572588
$ref: '#/$defs/header-or-reference'
573589
style:
574-
default: form
575590
enum:
576591
- form
577592
- spaceDelimited
@@ -580,7 +595,6 @@ $defs:
580595
explode:
581596
type: boolean
582597
allowReserved:
583-
default: false
584598
type: boolean
585599
encoding:
586600
type: object
@@ -592,14 +606,28 @@ $defs:
592606
$ref: '#/$defs/encoding'
593607
itemEncoding:
594608
$ref: '#/$defs/encoding'
609+
dependentSchemas:
610+
encoding:
611+
properties:
612+
prefixEncoding: false
613+
itemEncoding: false
614+
style:
615+
properties:
616+
allowReserved:
617+
default: false
618+
explode:
619+
properties:
620+
style:
621+
default: form
622+
allowReserved:
623+
default: false
624+
allowReserved:
625+
properties:
626+
style:
627+
default: form
595628
allOf:
596629
- $ref: '#/$defs/specification-extensions'
597630
- $ref: '#/$defs/styles-for-form'
598-
- dependentSchemas:
599-
encoding:
600-
properties:
601-
prefixEncoding: false
602-
itemEncoding: false
603631
unevaluatedProperties: false
604632

605633
responses:
@@ -783,7 +811,6 @@ $defs:
783811
allowReserved:
784812
default: false
785813
type: boolean
786-
$ref: '#/$defs/examples'
787814
allOf:
788815
- $ref: '#/$defs/examples'
789816
- $ref: '#/$defs/specification-extensions'
@@ -872,8 +899,6 @@ $defs:
872899
properties:
873900
type:
874901
const: apiKey
875-
required:
876-
- type
877902
then:
878903
properties:
879904
name:
@@ -892,8 +917,6 @@ $defs:
892917
properties:
893918
type:
894919
const: http
895-
required:
896-
- type
897920
then:
898921
properties:
899922
scheme:
@@ -922,8 +945,6 @@ $defs:
922945
properties:
923946
type:
924947
const: oauth2
925-
required:
926-
- type
927948
then:
928949
properties:
929950
flows:
@@ -939,8 +960,6 @@ $defs:
939960
properties:
940961
type:
941962
const: openIdConnect
942-
required:
943-
- type
944963
then:
945964
properties:
946965
openIdConnectUrl:

tests/schema/fail/example-examples.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,3 @@ components:
1515
examples:
1616
a mammalian example:
1717
dataValue: bear
18-
19-
20-

tests/schema/fail/invalid_schema_types.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,3 @@ components:
1010
invalid_null: null
1111
invalid_number: 0
1212
invalid_array: []
13-
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
openapi: 3.2.0
2+
info:
3+
title: API
4+
version: 1.0.0
5+
components:
6+
pathItems:
7+
my-path-item:
8+
get:
9+
description: a query parameter cannot be used together with a querystring parameter
10+
parameters:
11+
- name: myquerystring
12+
in: querystring
13+
content:
14+
application/json:
15+
schema:
16+
type: string
17+
- name: myquery
18+
in: query
19+
schema:
20+
type: string
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
openapi: 3.2.0
2+
info:
3+
title: API
4+
version: 1.0.0
5+
components:
6+
pathItems:
7+
my-path-item:
8+
get:
9+
description: querystring cannot be used twice
10+
parameters:
11+
- name: myquerystring1
12+
in: querystring
13+
content:
14+
application/json:
15+
schema: {}
16+
- name: myquerystring2
17+
in: querystring
18+
content:
19+
application/json:
20+
schema: {}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
openapi: 3.2.0
2+
info:
3+
title: API
4+
version: 1.0.0
5+
components:
6+
pathItems:
7+
my-path-item:
8+
parameters:
9+
- name: myquerystring
10+
in: querystring
11+
content:
12+
application/json:
13+
schema:
14+
type: string
15+
- name: myquery
16+
in: query
17+
schema:
18+
type: string
19+
get: {}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
openapi: 3.2.0
2+
info:
3+
title: API
4+
version: 1.0.0
5+
components:
6+
pathItems:
7+
my-path-item:
8+
description: querystring cannot be used twice
9+
parameters:
10+
- name: myquerystring1
11+
in: querystring
12+
content:
13+
application/json:
14+
schema: {}
15+
- name: myquerystring2
16+
in: querystring
17+
content:
18+
application/json:
19+
schema: {}
20+
get: {}

tests/schema/pass/example-object-examples.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ components:
2929
summary: This is a text example
3030
externalValue: https://foo.bar/examples/address-example.txt
3131
parameters:
32-
with-example:
32+
with-example:
3333
name: zipCode
3434
in: query
3535
schema:

tests/schema/pass/parameter-object-examples.yaml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ paths:
5252
type: number
5353
long:
5454
type: number
55+
- in: cookie
56+
name: my_cookie1
57+
style: form
58+
schema: {}
59+
- in: cookie
60+
name: my_cookie2
61+
style: cookie
62+
schema: {}
5563
/user:
5664
parameters:
5765
- in: querystring
@@ -62,7 +70,6 @@ paths:
6270
# Allow an arbitrary JSON object to keep
6371
# the example simple
6472
type: object
65-
example: {
66-
"numbers": [1, 2],
67-
"flag": null
68-
}
73+
example:
74+
numbers: [1, 2]
75+
flag: null

tests/schema/pass/schema-object-deprecated-example-keyword.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ paths:
1212
# the example simple
1313
type: object
1414
# DEPRECATED: don't use example keyword inside Schema Object
15-
example: {
16-
"numbers": [1, 2],
17-
"flag": null
18-
}
15+
example:
16+
numbers: [1, 2]
17+
flag: null

0 commit comments

Comments
 (0)