Skip to content

Commit 7281c4a

Browse files
fix style, explode, allowReserved defaults for parameter and encoding objects
- explode defaults were wrong for in: cookie, style: cookie, and for encoding object - allowReserved defaults were wrong for encoding object in parameter objects: - explode: always false for "in: path", "in: header" - explode: always true for "in: cookie" (both "style: form" and "style: cookie" default to "explode: true") - explode: only true for "in: query" when "style: form" (the default style for this location) in encoding objects: - style: default is "form", but only when "explode" or "allowReserved" are present - explode: default is true when "style: form" (the default style) and otherwise false, and not included at all unless "style" or "allowReserved" are present - allowReserved: default is false, but only when "style" or "explode" are present that is: when none of style, explode or allowReserved are present, "contentType" is used (or a default is calculated), so none of style, explode or allowReserved shall have default values
1 parent 4097aa7 commit 7281c4a

2 files changed

Lines changed: 22 additions & 11 deletions

File tree

src/schemas/validation/schema.yaml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,6 @@ $defs:
426426
- $ref: '#/$defs/parameter/dependentSchemas/schema/$defs/styles-for-header'
427427
- $ref: '#/$defs/parameter/dependentSchemas/schema/$defs/styles-for-query'
428428
- $ref: '#/$defs/parameter/dependentSchemas/schema/$defs/styles-for-cookie'
429-
- $ref: '#/$defs/styles-for-form'
430429

431430
$defs:
432431
styles-for-path:
@@ -446,6 +445,8 @@ $defs:
446445
- simple
447446
required:
448447
const: true
448+
explode:
449+
default: false
449450
allowReserved:
450451
type: boolean
451452
default: false
@@ -462,6 +463,8 @@ $defs:
462463
style:
463464
default: simple
464465
const: simple
466+
explode:
467+
default: false
465468

466469
styles-for-query:
467470
if:
@@ -480,6 +483,7 @@ $defs:
480483
allowReserved:
481484
type: boolean
482485
default: false
486+
$ref: '#/$defs/explode-for-form'
483487

484488
styles-for-cookie:
485489
if:
@@ -493,6 +497,8 @@ $defs:
493497
enum:
494498
- form
495499
- cookie
500+
explode:
501+
default: true
496502
if:
497503
properties:
498504
style:
@@ -610,7 +616,6 @@ $defs:
610616
type: boolean
611617
allowReserved:
612618
type: boolean
613-
default: false
614619
encoding:
615620
type: object
616621
additionalProperties:
@@ -627,7 +632,10 @@ $defs:
627632
prefixEncoding: false
628633
itemEncoding: false
629634
style:
630-
$ref: '#/$defs/styles-for-form'
635+
properties:
636+
allowReserved:
637+
default: false
638+
$ref: '#/$defs/explode-for-form'
631639
explode:
632640
properties:
633641
style:
@@ -638,7 +646,7 @@ $defs:
638646
properties:
639647
style:
640648
default: form
641-
$ref: '#/$defs/styles-for-form'
649+
$ref: '#/$defs/explode-for-form'
642650
$ref: '#/$defs/specification-extensions'
643651
unevaluatedProperties: false
644652

@@ -1127,13 +1135,12 @@ $defs:
11271135
additionalProperties:
11281136
type: string
11291137

1130-
styles-for-form:
1138+
explode-for-form:
1139+
$comment: for encoding objects, and query and cookie parameters, style=form is the default
11311140
if:
11321141
properties:
11331142
style:
11341143
const: form
1135-
required:
1136-
- style
11371144
then:
11381145
properties:
11391146
explode:

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,23 @@ paths:
99
in: header
1010
description: token to be passed as a header
1111
required: true
12+
explode: false
1213
schema:
1314
type: array
1415
items:
1516
type: integer
1617
format: int64
1718
style: simple
18-
- name: username
19+
- name: usernames
1920
in: path
20-
description: username to fetch
21+
description: usernames to fetch
2122
required: true
23+
explode: false
2224
schema:
23-
type: string
25+
type: array
2426
- name: id
2527
in: query
26-
description: ID of the object to fetch
28+
description: IDs of the object to fetch
2729
required: false
2830
schema:
2931
type: array
@@ -55,10 +57,12 @@ paths:
5557
- in: cookie
5658
name: my_cookie1
5759
style: form
60+
explode: false
5861
schema: {}
5962
- in: cookie
6063
name: my_cookie2
6164
style: cookie
65+
explode: true
6266
schema: {}
6367
/user:
6468
parameters:

0 commit comments

Comments
 (0)