Skip to content

Commit 866a4a2

Browse files
Add "type" qualifier to ensure that "if" clauses fail properly (#2696)
If the wrong type is used for a particular piece of data, then a bare "required" will validate as true, causing the "if" clause to be true, which can lead to confusing errors when the "then" schema then fires, instead of the error occurring at a higher position in the schema.
1 parent 085be94 commit 866a4a2

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

schemas/v3.1/schema.json

+7
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@
316316
},
317317
"path-item-or-reference": {
318318
"if": {
319+
"type": "object",
319320
"required": [
320321
"$ref"
321322
]
@@ -651,6 +652,7 @@
651652
},
652653
"request-body-or-reference": {
653654
"if": {
655+
"type": "object",
654656
"required": [
655657
"$ref"
656658
]
@@ -807,6 +809,7 @@
807809
},
808810
"response-or-reference": {
809811
"if": {
812+
"type": "object",
810813
"required": [
811814
"$ref"
812815
]
@@ -827,6 +830,7 @@
827830
},
828831
"callbacks-or-reference": {
829832
"if": {
833+
"type": "object",
830834
"required": [
831835
"$ref"
832836
]
@@ -905,6 +909,7 @@
905909
},
906910
"link-or-reference": {
907911
"if": {
912+
"type": "object",
908913
"required": [
909914
"$ref"
910915
]
@@ -969,6 +974,7 @@
969974
},
970975
"header-or-reference": {
971976
"if": {
977+
"type": "object",
972978
"required": [
973979
"$ref"
974980
]
@@ -1190,6 +1196,7 @@
11901196
},
11911197
"security-scheme-or-reference": {
11921198
"if": {
1199+
"type": "object",
11931200
"required": [
11941201
"$ref"
11951202
]

schemas/v3.1/schema.yaml

+9
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ $defs:
219219

220220
path-item-or-reference:
221221
if:
222+
type: object
222223
required:
223224
- $ref
224225
then:
@@ -416,6 +417,7 @@ $defs:
416417

417418
parameter-or-reference:
418419
if:
420+
type: object
419421
required:
420422
- $ref
421423
then:
@@ -440,6 +442,7 @@ $defs:
440442

441443
request-body-or-reference:
442444
if:
445+
type: object
443446
required:
444447
- $ref
445448
then:
@@ -545,6 +548,7 @@ $defs:
545548

546549
response-or-reference:
547550
if:
551+
type: object
548552
required:
549553
- $ref
550554
then:
@@ -560,6 +564,7 @@ $defs:
560564

561565
callbacks-or-reference:
562566
if:
567+
type: object
563568
required:
564569
- $ref
565570
then:
@@ -583,6 +588,7 @@ $defs:
583588

584589
example-or-reference:
585590
if:
591+
type: object
586592
required:
587593
- $ref
588594
then:
@@ -614,6 +620,7 @@ $defs:
614620

615621
link-or-reference:
616622
if:
623+
type: object
617624
required:
618625
- $ref
619626
then:
@@ -656,6 +663,7 @@ $defs:
656663

657664
header-or-reference:
658665
if:
666+
type: object
659667
required:
660668
- $ref
661669
then:
@@ -801,6 +809,7 @@ $defs:
801809

802810
security-scheme-or-reference:
803811
if:
812+
type: object
804813
required:
805814
- $ref
806815
then:

0 commit comments

Comments
 (0)