Skip to content

Commit

Permalink
refactor out a common definition when style=form (OAI#3379)
Browse files Browse the repository at this point in the history
  • Loading branch information
karenetheridge authored Oct 5, 2023
1 parent 485f655 commit ddcab42
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 92 deletions.
86 changes: 29 additions & 57 deletions schemas/v3.1/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@
"$ref": "#/$defs/parameter/dependentSchemas/schema/$defs/styles-for-cookie"
},
{
"$ref": "#/$defs/parameter/dependentSchemas/schema/$defs/styles-for-form"
"$ref": "#/$defs/styles-for-form"
}
],
"$defs": {
Expand Down Expand Up @@ -640,32 +640,6 @@
}
}
}
},
"styles-for-form": {
"if": {
"properties": {
"style": {
"const": "form"
}
},
"required": [
"style"
]
},
"then": {
"properties": {
"explode": {
"default": true
}
}
},
"else": {
"properties": {
"explode": {
"default": false
}
}
}
}
}
}
Expand Down Expand Up @@ -792,38 +766,10 @@
"$ref": "#/$defs/specification-extensions"
},
{
"$ref": "#/$defs/encoding/$defs/explode-default"
"$ref": "#/$defs/styles-for-form"
}
],
"unevaluatedProperties": false,
"$defs": {
"explode-default": {
"if": {
"properties": {
"style": {
"const": "form"
}
},
"required": [
"style"
]
},
"then": {
"properties": {
"explode": {
"default": true
}
}
},
"else": {
"properties": {
"explode": {
"default": false
}
}
}
}
}
"unevaluatedProperties": false
},
"responses": {
"$comment": "https://spec.openapis.org/oas/v3.1.0#responses-object",
Expand Down Expand Up @@ -1444,6 +1390,32 @@
"additionalProperties": {
"type": "string"
}
},
"styles-for-form": {
"if": {
"properties": {
"style": {
"const": "form"
}
},
"required": [
"style"
]
},
"then": {
"properties": {
"explode": {
"default": true
}
}
},
"else": {
"properties": {
"explode": {
"default": false
}
}
}
}
}
}
54 changes: 19 additions & 35 deletions schemas/v3.1/schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ $defs:
- $ref: '#/$defs/parameter/dependentSchemas/schema/$defs/styles-for-header'
- $ref: '#/$defs/parameter/dependentSchemas/schema/$defs/styles-for-query'
- $ref: '#/$defs/parameter/dependentSchemas/schema/$defs/styles-for-cookie'
- $ref: '#/$defs/parameter/dependentSchemas/schema/$defs/styles-for-form'
- $ref: '#/$defs/styles-for-form'

$defs:
styles-for-path:
Expand Down Expand Up @@ -426,6 +426,7 @@ $defs:
allowReserved:
default: false
type: boolean

styles-for-cookie:
if:
properties:
Expand All @@ -439,22 +440,6 @@ $defs:
default: form
const: form

styles-for-form:
if:
properties:
style:
const: form
required:
- style
then:
properties:
explode:
default: true
else:
properties:
explode:
default: false

$ref: '#/$defs/specification-extensions'
unevaluatedProperties: false

Expand Down Expand Up @@ -542,26 +527,9 @@ $defs:
type: boolean
allOf:
- $ref: '#/$defs/specification-extensions'
- $ref: '#/$defs/encoding/$defs/explode-default'
- $ref: '#/$defs/styles-for-form'
unevaluatedProperties: false

$defs:
explode-default:
if:
properties:
style:
const: form
required:
- style
then:
properties:
explode:
default: true
else:
properties:
explode:
default: false

responses:
$comment: https://spec.openapis.org/oas/v3.1.0#responses-object
type: object
Expand Down Expand Up @@ -999,3 +967,19 @@ $defs:
type: object
additionalProperties:
type: string

styles-for-form:
if:
properties:
style:
const: form
required:
- style
then:
properties:
explode:
default: true
else:
properties:
explode:
default: false

0 comments on commit ddcab42

Please sign in to comment.