Skip to content

Commit d74d33a

Browse files
fix style, explode, allowReserved defaults for parameter and encoding objects
- explode defaults were wrong 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" ("style: form" is the only option, and defaults 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 1e12511 commit d74d33a

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

src/schemas/validation/schema.yaml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,6 @@ $defs:
359359
- $ref: '#/$defs/parameter/dependentSchemas/schema/$defs/styles-for-header'
360360
- $ref: '#/$defs/parameter/dependentSchemas/schema/$defs/styles-for-query'
361361
- $ref: '#/$defs/parameter/dependentSchemas/schema/$defs/styles-for-cookie'
362-
- $ref: '#/$defs/styles-for-form'
363362

364363
$defs:
365364
styles-for-path:
@@ -379,6 +378,8 @@ $defs:
379378
- simple
380379
required:
381380
const: true
381+
explode:
382+
default: false
382383
required:
383384
- required
384385

@@ -392,6 +393,8 @@ $defs:
392393
style:
393394
default: simple
394395
const: simple
396+
explode:
397+
default: false
395398

396399
styles-for-query:
397400
if:
@@ -410,6 +413,7 @@ $defs:
410413
allowReserved:
411414
default: false
412415
type: boolean
416+
$ref: '#/$defs/explode-for-form'
413417

414418
styles-for-cookie:
415419
if:
@@ -511,7 +515,7 @@ $defs:
511515
properties:
512516
allowReserved:
513517
default: false
514-
$ref: '#/$defs/styles-for-form'
518+
$ref: '#/$defs/explode-for-form'
515519
explode:
516520
properties:
517521
style:
@@ -522,7 +526,7 @@ $defs:
522526
properties:
523527
style:
524528
default: form
525-
$ref: '#/$defs/styles-for-form'
529+
$ref: '#/$defs/explode-for-form'
526530
$ref: '#/$defs/specification-extensions'
527531
unevaluatedProperties: false
528532

@@ -959,13 +963,12 @@ $defs:
959963
additionalProperties:
960964
type: string
961965

962-
styles-for-form:
966+
explode-for-form:
967+
$comment: for encoding objects, and query and cookie parameters, style=form is the default
963968
if:
964969
properties:
965970
style:
966971
const: form
967-
required:
968-
- style
969972
then:
970973
properties:
971974
explode:

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

Lines changed: 12 additions & 5 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
@@ -51,4 +53,9 @@ paths:
5153
lat:
5254
type: number
5355
long:
54-
type: number
56+
type: number
57+
- in: cookie
58+
name: my_cookie1
59+
style: form
60+
explode: false
61+
schema: {}

0 commit comments

Comments
 (0)