From 9433b88620cb1dee91f778ff04917e9ab9a793fc Mon Sep 17 00:00:00 2001 From: Jeremy Fiel Date: Tue, 21 May 2024 19:58:22 -0400 Subject: [PATCH 1/4] codify Encoding in specific requestBody mediatypes the specification indicates > The encoding object SHALL only apply to requestBody objects when the media type is multipart or application/x-www-form-urlencoded. Co-authored-by: Fiel, Jeremy --- schemas/v3.0/schema.yaml | 31 +++++++++++++++++++++++++++---- schemas/v3.1/schema.yaml | 14 ++++++++++++++ 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/schemas/v3.0/schema.yaml b/schemas/v3.0/schema.yaml index 0123b9f645..7d55120942 100644 --- a/schemas/v3.0/schema.yaml +++ b/schemas/v3.0/schema.yaml @@ -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: @@ -763,6 +783,9 @@ definitions: type: object additionalProperties: $ref: '#/definitions/MediaType' + patternProperties: + '^application/x-www-form-urlencoded$|^multipart\/.+$': + $ref: '#/definitions/MediaTypeWithEncoding' required: type: boolean default: false diff --git a/schemas/v3.1/schema.yaml b/schemas/v3.1/schema.yaml index bd1925ca9c..0391e9aec2 100644 --- a/schemas/v3.1/schema.yaml +++ b/schemas/v3.1/schema.yaml @@ -474,10 +474,24 @@ $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: + $comment: https://spec.openapis.org/oas/v3.1.0#media-type-object + type: object + properties: + schema: + $dynamicRef: '#meta' + allOf: + - $ref: '#/$defs/specification-extensions' + - $ref: '#/$defs/examples' + unevaluatedProperties: false + + media-type-with-encoding: $comment: https://spec.openapis.org/oas/v3.1.0#media-type-object type: object properties: From ca06d24a0e812c24166b5a309e4ba4453e17f340 Mon Sep 17 00:00:00 2001 From: Jeremy Fiel Date: Wed, 22 May 2024 15:33:43 -0400 Subject: [PATCH 2/4] resolve feedback --- schemas/v3.1/schema.yaml | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/schemas/v3.1/schema.yaml b/schemas/v3.1/schema.yaml index 0391e9aec2..467c3f7b43 100644 --- a/schemas/v3.1/schema.yaml +++ b/schemas/v3.1/schema.yaml @@ -480,7 +480,7 @@ $defs: propertyNames: format: media-range - media-type: + media-type-common: $comment: https://spec.openapis.org/oas/v3.1.0#media-type-object type: object properties: @@ -489,21 +489,19 @@ $defs: 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: - schema: - $dynamicRef: '#meta' encoding: - type: object - additionalProperties: - $ref: '#/$defs/encoding' - allOf: - - $ref: '#/$defs/specification-extensions' - - $ref: '#/$defs/examples' + $ref: '#/$defs/encoding' unevaluatedProperties: false encoding: From f04462d3ff66b13c5956e9867a6908c697398c9f Mon Sep 17 00:00:00 2001 From: Jeremy Fiel Date: Thu, 23 May 2024 12:56:33 -0400 Subject: [PATCH 3/4] add `*/*` to satisfy wildcard mediatypes --- schemas/v3.0/schema.yaml | 2 +- schemas/v3.1/schema.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/schemas/v3.0/schema.yaml b/schemas/v3.0/schema.yaml index 7d55120942..cb2dcc0e62 100644 --- a/schemas/v3.0/schema.yaml +++ b/schemas/v3.0/schema.yaml @@ -784,7 +784,7 @@ definitions: additionalProperties: $ref: '#/definitions/MediaType' patternProperties: - '^application/x-www-form-urlencoded$|^multipart\/.+$': + '\*\/\*|^application/x-www-form-urlencoded$|^multipart\/.+$': $ref: '#/definitions/MediaTypeWithEncoding' required: type: boolean diff --git a/schemas/v3.1/schema.yaml b/schemas/v3.1/schema.yaml index 467c3f7b43..12c747c5fe 100644 --- a/schemas/v3.1/schema.yaml +++ b/schemas/v3.1/schema.yaml @@ -475,7 +475,7 @@ $defs: additionalProperties: $ref: '#/$defs/media-type' patternProperties: - '^application/x-www-form-urlencoded$|^multipart\/.+$': + '\*\/\*|^application/x-www-form-urlencoded$|^multipart\/.+$': $ref: '#/$defs/media-type-with-encoding' propertyNames: format: media-range From e7a3da46ed0db732601d9dc82820f05991c1f936 Mon Sep 17 00:00:00 2001 From: Jeremy Fiel Date: Mon, 10 Jun 2024 12:15:20 -0500 Subject: [PATCH 4/4] fix(schema): include start and end anchors for pattern --- schemas/v3.0/schema.yaml | 2 +- schemas/v3.1/schema.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/schemas/v3.0/schema.yaml b/schemas/v3.0/schema.yaml index cb2dcc0e62..0be8d7f0d8 100644 --- a/schemas/v3.0/schema.yaml +++ b/schemas/v3.0/schema.yaml @@ -784,7 +784,7 @@ definitions: additionalProperties: $ref: '#/definitions/MediaType' patternProperties: - '\*\/\*|^application/x-www-form-urlencoded$|^multipart\/.+$': + '^\*\/\*$|^application/x-www-form-urlencoded$|^multipart\/.+$': $ref: '#/definitions/MediaTypeWithEncoding' required: type: boolean diff --git a/schemas/v3.1/schema.yaml b/schemas/v3.1/schema.yaml index 12c747c5fe..57c2b53eb7 100644 --- a/schemas/v3.1/schema.yaml +++ b/schemas/v3.1/schema.yaml @@ -475,7 +475,7 @@ $defs: additionalProperties: $ref: '#/$defs/media-type' patternProperties: - '\*\/\*|^application/x-www-form-urlencoded$|^multipart\/.+$': + '^\*\/\*$|^application/x-www-form-urlencoded$|^multipart\/.+$': $ref: '#/$defs/media-type-with-encoding' propertyNames: format: media-range