Skip to content

Commit 1434d3c

Browse files
require that responses object has 'default' or a response code (fixes #2833)
ref: https://spec.openapis.org/oas/v3.1.0#responses-object
1 parent 36a3a67 commit 1434d3c

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

schemas/v3.1/schema.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,16 @@
840840
},
841841
"minProperties": 1,
842842
"$ref": "#/$defs/specification-extensions",
843-
"unevaluatedProperties": false
843+
"unevaluatedProperties": false,
844+
"$comment": "either default, or at least one response code property must exist",
845+
"if": {
846+
"patternProperties": {
847+
"^[1-5](?:[0-9]{2}|XX)$": false
848+
}
849+
},
850+
"then" : {
851+
"required": [ "default" ]
852+
}
844853
},
845854
"response": {
846855
"$comment": "https://spec.openapis.org/oas/v3.1.0#response-object",

schemas/v3.1/schema.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,12 @@ $defs:
574574
minProperties: 1
575575
$ref: '#/$defs/specification-extensions'
576576
unevaluatedProperties: false
577+
$comment: either default, or at least one response code property must exist
578+
if:
579+
patternProperties:
580+
'^[1-5](?:[0-9]{2}|XX)$': false
581+
then:
582+
required: [default]
577583

578584
response:
579585
$comment: https://spec.openapis.org/oas/v3.1.0#response-object

0 commit comments

Comments
 (0)