Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 27 additions & 4 deletions schemas/v3.0/schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -405,16 +405,36 @@ definitions:
oneOf:
- $ref: '#/definitions/Example'
- $ref: '#/definitions/Reference'
encoding:
type: object
additionalProperties:
$ref: '#/definitions/Encoding'
patternProperties:
'^x-': {}
additionalProperties: false
allOf:
- $ref: '#/definitions/ExampleXORExamples'

MediaTypeWithEncoding:
type: object
properties:
schema:
oneOf:
- $ref: '#/definitions/Schema'
- $ref: '#/definitions/Reference'
example: {}
examples:
type: object
additionalProperties:
oneOf:
- $ref: '#/definitions/Example'
- $ref: '#/definitions/Reference'
encoding:
type: object
additionalProperties:
$ref: '#/definitions/Encoding'
patternProperties:
'^x-': {}
additionalProperties: false
allOf:
- $ref: '#/definitions/ExampleXORExamples'

Example:
type: object
properties:
Expand Down Expand Up @@ -763,6 +783,9 @@ definitions:
type: object
additionalProperties:
$ref: '#/definitions/MediaType'
patternProperties:
'\*\/\*|^application/x-www-form-urlencoded$|^multipart\/.+$':
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should */* have ^/$ anchors?
Should application/* be matched, as that would apply to application/x-www-form-urlencoded?

Copy link
Contributor Author

@jeremyfiel jeremyfiel Jun 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the purpose of the anchors? Why would it be needed?

I see your point on the above. I'll update that

application/* would match any application media type and that's not what we want here., although that would enable quite a few different media types to allow encoding schema. Matching */* was only for backwards compatibility per Darrell's comment.

$ref: '#/definitions/MediaTypeWithEncoding'
required:
type: boolean
default: false
Expand Down
22 changes: 17 additions & 5 deletions schemas/v3.1/schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -474,22 +474,34 @@ $defs:
type: object
additionalProperties:
$ref: '#/$defs/media-type'
patternProperties:
'\*\/\*|^application/x-www-form-urlencoded$|^multipart\/.+$':
$ref: '#/$defs/media-type-with-encoding'
propertyNames:
format: media-range

media-type:
media-type-common:
$comment: https://spec.openapis.org/oas/v3.1.0#media-type-object
type: object
properties:
schema:
$dynamicRef: '#meta'
encoding:
type: object
additionalProperties:
$ref: '#/$defs/encoding'
allOf:
- $ref: '#/$defs/specification-extensions'
- $ref: '#/$defs/examples'

media-type:
$comment: https://spec.openapis.org/oas/v3.1.0#media-type-object
$ref: '#/$defs/media-type-common'
unevaluatedProperties: false

media-type-with-encoding:
$comment: https://spec.openapis.org/oas/v3.1.0#media-type-object
$ref: '#/$defs/media-type-common'
type: object
properties:
encoding:
$ref: '#/$defs/encoding'
unevaluatedProperties: false

encoding:
Expand Down