fix: align OpenAPI 3.x.y file uploads with specification (#10409)

Refs #9278
This commit is contained in:
Oliwia Rogala
2025-04-11 13:43:44 +02:00
committed by GitHub
parent 22adad3a2e
commit c29e7126c9
19 changed files with 812 additions and 200 deletions

View File

@@ -0,0 +1,189 @@
/**
* @prettier
*/
describe("OpenAPI 3.0 Request Body upload file button", () => {
beforeEach(() => {
cy.visit("/?url=/documents/features/oas3-request-body-upload-file.yaml")
})
describe("application/octet-stream", () => {
beforeEach(() => {
cy.get("#operations-default-uploadApplicationOctetStream").click()
})
it("should display description with the correct content type", () => {
cy.get(
".opblock-section-request-body .opblock-description-wrapper i"
).should(
"have.text",
"Example values are not available for application/octet-stream media types."
)
})
it("should display a file upload button", () => {
cy.get(".try-out__btn").click()
cy.get(
".opblock-section-request-body .opblock-description-wrapper input"
).should("have.prop", "type", "file")
})
})
describe("image/png", () => {
beforeEach(() => {
cy.get("#operations-default-uploadImagePng").click()
})
it("should display description with the correct content type", () => {
cy.get(
".opblock-section-request-body .opblock-description-wrapper i"
).should(
"have.text",
"Example values are not available for image/png media types."
)
})
it("should display a file upload button", () => {
cy.get(".try-out__btn").click()
cy.get(
".opblock-section-request-body .opblock-description-wrapper input"
).should("have.prop", "type", "file")
})
})
describe("audio/wav", () => {
beforeEach(() => {
cy.get("#operations-default-uploadAudioWav").click()
})
it("should display description with the correct content type", () => {
cy.get(
".opblock-section-request-body .opblock-description-wrapper i"
).should(
"have.text",
"Example values are not available for audio/wav media types."
)
})
it("should display a file upload button", () => {
cy.get(".try-out__btn").click()
cy.get(
".opblock-section-request-body .opblock-description-wrapper input"
).should("have.prop", "type", "file")
})
})
describe("video/mpeg", () => {
beforeEach(() => {
cy.get("#operations-default-uploadVideoMpeg").click()
})
it("should display description with the correct content type", () => {
cy.get(
".opblock-section-request-body .opblock-description-wrapper i"
).should(
"have.text",
"Example values are not available for video/mpeg media types."
)
})
it("should display a file upload button", () => {
cy.get(".try-out__btn").click()
cy.get(
".opblock-section-request-body .opblock-description-wrapper input"
).should("have.prop", "type", "file")
})
})
describe("application/octet-stream with empty Media Type Object", () => {
beforeEach(() => {
cy.get("#operations-default-uploadApplicationOctetStreamEmpty").click()
})
it("should display description with the correct content type", () => {
cy.get(
".opblock-section-request-body .opblock-description-wrapper i"
).should(
"have.text",
"Example values are not available for application/octet-stream media types."
)
})
it("should display a file upload button", () => {
cy.get(".try-out__btn").click()
cy.get(
".opblock-section-request-body .opblock-description-wrapper input"
).should("have.prop", "type", "file")
})
})
describe("schema type string and format binary", () => {
beforeEach(() => {
cy.get("#operations-default-uploadSchemaFormatBinary").click()
})
it("should display description with the correct content type", () => {
cy.get(
".opblock-section-request-body .opblock-description-wrapper i"
).should(
"have.text",
"Example values are not available for application/x-custom media types."
)
})
it("should display a file upload button", () => {
cy.get(".try-out__btn").click()
cy.get(
".opblock-section-request-body .opblock-description-wrapper input"
).should("have.prop", "type", "file")
})
})
describe("schema type string and format byte", () => {
beforeEach(() => {
cy.get("#operations-default-uploadSchemaFormatByte").click()
})
it("should display description with the correct content type", () => {
cy.get(
".opblock-section-request-body .opblock-description-wrapper i"
).should(
"have.text",
"Example values are not available for application/x-custom media types."
)
})
it("should display a file upload button", () => {
cy.get(".try-out__btn").click()
cy.get(
".opblock-section-request-body .opblock-description-wrapper input"
).should("have.prop", "type", "file")
})
})
describe("multipart/form-data object property with schema type string and format binary", () => {
beforeEach(() => {
cy.get("#operations-default-uploadPropertySchemaFormatBinary").click()
})
it("should display a file upload button", () => {
cy.get(".try-out__btn").click()
cy.get(
".opblock-section-request-body .opblock-description-wrapper input"
).should("have.prop", "type", "file")
})
})
describe("multipart/form-data object property with schema type string and format byte", () => {
beforeEach(() => {
cy.get("#operations-default-uploadPropertySchemaFormatByte").click()
})
it("should display a file upload button", () => {
cy.get(".try-out__btn").click()
cy.get(
".opblock-section-request-body .opblock-description-wrapper input"
).should("have.prop", "type", "file")
})
})
})

View File

@@ -0,0 +1,257 @@
/**
* @prettier
*/
describe("OpenAPI 3.1 Request Body upload file button", () => {
beforeEach(() => {
cy.visit("/?url=/documents/features/oas31-request-body-upload-file.yaml")
})
describe("application/octet-stream", () => {
beforeEach(() => {
cy.get("#operations-default-uploadApplicationOctetStream").click()
})
it("should display description with the correct content type", () => {
cy.get(
".opblock-section-request-body .opblock-description-wrapper i"
).should(
"have.text",
"Example values are not available for application/octet-stream media types."
)
})
it("should display a file upload button", () => {
cy.get(".try-out__btn").click()
cy.get(
".opblock-section-request-body .opblock-description-wrapper input"
).should("have.prop", "type", "file")
})
})
describe("image/png", () => {
beforeEach(() => {
cy.get("#operations-default-uploadImagePng").click()
})
it("should display description with the correct content type", () => {
cy.get(
".opblock-section-request-body .opblock-description-wrapper i"
).should(
"have.text",
"Example values are not available for image/png media types."
)
})
it("should display a file upload button", () => {
cy.get(".try-out__btn").click()
cy.get(
".opblock-section-request-body .opblock-description-wrapper input"
).should("have.prop", "type", "file")
})
})
describe("audio/wav", () => {
beforeEach(() => {
cy.get("#operations-default-uploadAudioWav").click()
})
it("should display description with the correct content type", () => {
cy.get(
".opblock-section-request-body .opblock-description-wrapper i"
).should(
"have.text",
"Example values are not available for audio/wav media types."
)
})
it("should display a file upload button", () => {
cy.get(".try-out__btn").click()
cy.get(
".opblock-section-request-body .opblock-description-wrapper input"
).should("have.prop", "type", "file")
})
})
describe("video/mpeg", () => {
beforeEach(() => {
cy.get("#operations-default-uploadVideoMpeg").click()
})
it("should display description with the correct content type", () => {
cy.get(
".opblock-section-request-body .opblock-description-wrapper i"
).should(
"have.text",
"Example values are not available for video/mpeg media types."
)
})
it("should display a file upload button", () => {
cy.get(".try-out__btn").click()
cy.get(
".opblock-section-request-body .opblock-description-wrapper input"
).should("have.prop", "type", "file")
})
})
describe("application/octet-stream with empty Media Type Object", () => {
beforeEach(() => {
cy.get("#operations-default-uploadApplicationOctetStreamEmpty").click()
})
it("should display description with the correct content type", () => {
cy.get(
".opblock-section-request-body .opblock-description-wrapper i"
).should(
"have.text",
"Example values are not available for application/octet-stream media types."
)
})
it("should display a file upload button", () => {
cy.get(".try-out__btn").click()
cy.get(
".opblock-section-request-body .opblock-description-wrapper input"
).should("have.prop", "type", "file")
})
})
describe("schema type string and format binary", () => {
beforeEach(() => {
cy.get("#operations-default-uploadSchemaTypeFormatBinary").click()
})
it("should display description with the correct content type", () => {
cy.get(
".opblock-section-request-body .opblock-description-wrapper i"
).should(
"have.text",
"Example values are not available for application/x-custom media types."
)
})
it("should display a file upload button", () => {
cy.get(".try-out__btn").click()
cy.get(
".opblock-section-request-body .opblock-description-wrapper input"
).should("have.prop", "type", "file")
})
})
describe("schema type string and format byte", () => {
beforeEach(() => {
cy.get("#operations-default-uploadSchemaTypeFormatByte").click()
})
it("should display description with the correct content type", () => {
cy.get(
".opblock-section-request-body .opblock-description-wrapper i"
).should(
"have.text",
"Example values are not available for application/x-custom media types."
)
})
it("should display a file upload button", () => {
cy.get(".try-out__btn").click()
cy.get(
".opblock-section-request-body .opblock-description-wrapper input"
).should("have.prop", "type", "file")
})
})
describe("schema union type includes string and format binary", () => {
beforeEach(() => {
cy.get("#operations-default-uploadSchemaUnionTypeFormatBinary").click()
})
it("should display description with the correct content type", () => {
cy.get(
".opblock-section-request-body .opblock-description-wrapper i"
).should(
"have.text",
"Example values are not available for application/x-custom media types."
)
})
it("should display a file upload button", () => {
cy.get(".try-out__btn").click()
cy.get(
".opblock-section-request-body .opblock-description-wrapper input"
).should("have.prop", "type", "file")
})
})
describe("schema union type includes string and format byte", () => {
beforeEach(() => {
cy.get("#operations-default-uploadSchemaUnionTypeFormatByte").click()
})
it("should display description with the correct content type", () => {
cy.get(
".opblock-section-request-body .opblock-description-wrapper i"
).should(
"have.text",
"Example values are not available for application/x-custom media types."
)
})
it("should display a file upload button", () => {
cy.get(".try-out__btn").click()
cy.get(
".opblock-section-request-body .opblock-description-wrapper input"
).should("have.prop", "type", "file")
})
})
describe("multipart/form-data object property with schema type string and format binary", () => {
beforeEach(() => {
cy.get("#operations-default-uploadPropertySchemaFormatBinary").click()
})
it("should display a file upload button", () => {
cy.get(".try-out__btn").click()
cy.get(
".opblock-section-request-body .opblock-description-wrapper input"
).should("have.prop", "type", "file")
})
})
describe("multipart/form-data object property with schema type string and format byte", () => {
beforeEach(() => {
cy.get("#operations-default-uploadPropertySchemaFormatByte").click()
})
it("should display a file upload button", () => {
cy.get(".try-out__btn").click()
cy.get(
".opblock-section-request-body .opblock-description-wrapper input"
).should("have.prop", "type", "file")
})
})
describe("multipart/form-data object property with schema union type including string and format binary", () => {
beforeEach(() => {
cy.get(
"#operations-default-uploadPropertySchemaUnionTypeFormatBinary"
).click()
})
it("should display a file upload button", () => {
cy.get(".try-out__btn").click()
cy.get(
".opblock-section-request-body .opblock-description-wrapper input"
).should("have.prop", "type", "file")
})
})
describe("multipart/form-data object property with schema union type including string and format byte", () => {
beforeEach(() => {
cy.get(
"#operations-default-uploadPropertySchemaUnionTypeFormatByte"
).click()
})
it("should display a file upload button", () => {
cy.get(".try-out__btn").click()
cy.get(
".opblock-section-request-body .opblock-description-wrapper input"
).should("have.prop", "type", "file")
})
})
})

View File

@@ -1,132 +0,0 @@
/**
* @prettier
*/
describe("OpenAPI 3.0 Request Body upload file button", () => {
describe("application/octet-stream", () => {
it("should display description with the correct content type", () => {
cy.visit("/?url=/documents/features/request-body-upload-file.yaml")
.get("#operations-default-uploadApplicationOctetStream")
.click()
.get(".opblock-section-request-body .opblock-description-wrapper i")
.should(
"have.text",
"Example values are not available for application/octet-stream media types."
)
})
it("should display a file upload button", () => {
cy.visit("/?url=/documents/features/request-body-upload-file.yaml")
.get("#operations-default-uploadApplicationOctetStream")
.click()
.get(".try-out__btn")
.click()
.get(".opblock-section-request-body .opblock-description-wrapper input")
.should("have.prop", "type", "file")
})
})
describe("image/png", () => {
it("should display description with the correct content type", () => {
cy.visit("/?url=/documents/features/request-body-upload-file.yaml")
.get("#operations-default-uploadImagePng")
.click()
.get(".opblock-section-request-body .opblock-description-wrapper i")
.should(
"have.text",
"Example values are not available for image/png media types."
)
})
it("should display a file upload button", () => {
cy.visit("/?url=/documents/features/request-body-upload-file.yaml")
.get("#operations-default-uploadApplicationOctetStream")
.click()
.get(".try-out__btn")
.click()
.get(".opblock-section-request-body .opblock-description-wrapper input")
.should("have.prop", "type", "file")
})
})
describe("audio/wav", () => {
it("should display description with the correct content type", () => {
cy.visit("/?url=/documents/features/request-body-upload-file.yaml")
.get("#operations-default-uploadAudioWav")
.click()
.get(".opblock-section-request-body .opblock-description-wrapper i")
.should(
"have.text",
"Example values are not available for audio/wav media types."
)
})
it("should display a file upload button", () => {
cy.visit("/?url=/documents/features/request-body-upload-file.yaml")
.get("#operations-default-uploadApplicationOctetStream")
.click()
.get(".try-out__btn")
.click()
.get(".opblock-section-request-body .opblock-description-wrapper input")
.should("have.prop", "type", "file")
})
})
describe("video/mpeg", () => {
it("should display description with the correct content type", () => {
cy.visit("/?url=/documents/features/request-body-upload-file.yaml")
.get("#operations-default-uploadVideoMpeg")
.click()
.get(".opblock-section-request-body .opblock-description-wrapper i")
.should(
"have.text",
"Example values are not available for video/mpeg media types."
)
})
it("should display a file upload button", () => {
cy.visit("/?url=/documents/features/request-body-upload-file.yaml")
.get("#operations-default-uploadApplicationOctetStream")
.click()
.get(".try-out__btn")
.click()
.get(".opblock-section-request-body .opblock-description-wrapper input")
.should("have.prop", "type", "file")
})
})
describe("schema format binary", () => {
it("should display description with the correct content type", () => {
cy.visit("/?url=/documents/features/request-body-upload-file.yaml")
.get("#operations-default-uploadSchemaFormatBinary")
.click()
.get(".opblock-section-request-body .opblock-description-wrapper i")
.should(
"have.text",
"Example values are not available for application/x-custom media types."
)
})
it("should display a file upload button", () => {
cy.visit("/?url=/documents/features/request-body-upload-file.yaml")
.get("#operations-default-uploadSchemaFormatBinary")
.click()
.get(".try-out__btn")
.click()
.get(".opblock-section-request-body .opblock-description-wrapper input")
.should("have.prop", "type", "file")
})
})
describe("schema format base64", () => {
it("should display description with the correct content type", () => {
cy.visit("/?url=/documents/features/request-body-upload-file.yaml")
.get("#operations-default-uploadSchemaFormatBase64")
.click()
.get(".opblock-section-request-body .opblock-description-wrapper i")
.should(
"have.text",
"Example values are not available for application/x-custom media types."
)
})
it("should display a file upload button", () => {
cy.visit("/?url=/documents/features/request-body-upload-file.yaml")
.get("#operations-default-uploadSchemaFormatBinary")
.click()
.get(".try-out__btn")
.click()
.get(".opblock-section-request-body .opblock-description-wrapper input")
.should("have.prop", "type", "file")
})
})
})

View File

@@ -7,8 +7,11 @@ info:
* `audio/*` content type (no matter what schema format)
* `image/*` content type (no matter what schema format)
* `video/*` content type (no matter what schema format)
* schema format is `base64` (no matter what content type)
* schema format is `binary` (no matter what content type)
* `application/octect-stream` content type with empty Media Type Object
* schema type is `string` and format is `byte` (no matter what content type)
* schema type is `string` and format is `binary` (no matter what content type)
* multipart/form-data object property schema type is `string` and format is `byte`
* multipart/form-data object property schema type is `string` and format is `binary`
version: "1.0.0"
paths:
/upload-application-octet-stream:
@@ -19,13 +22,6 @@ paths:
application/octet-stream:
schema:
type: string
responses:
'200':
description: successful operation
content:
text/plain:
schema:
type: string
/upload-image-png:
post:
operationId: uploadImagePng
@@ -34,13 +30,6 @@ paths:
image/png:
schema:
type: string
responses:
'200':
description: successful operation
content:
text/plain:
schema:
type: string
/upload-audio-wav:
post:
operationId: uploadAudioWav
@@ -49,13 +38,6 @@ paths:
audio/wav:
schema:
type: string
responses:
'200':
description: successful operation
content:
text/plain:
schema:
type: string
/upload-video-mpeg:
post:
operationId: uploadVideoMpeg
@@ -64,13 +46,12 @@ paths:
video/mpeg:
schema:
type: string
responses:
'200':
description: successful operation
content:
text/plain:
schema:
type: string
/upload-application-octet-stream-empty:
post:
operationId: uploadApplicationOctetStreamEmpty
requestBody:
content:
application/octet-stream: {}
/upload-schema-format-binary:
post:
operationId: uploadSchemaFormatBinary
@@ -80,26 +61,36 @@ paths:
schema:
type: string
format: binary
responses:
'200':
description: successful operation
content:
text/plain:
schema:
type: string
/upload-schema-format-base64:
/upload-schema-format-byte:
post:
operationId: uploadSchemaFormatBase64
operationId: uploadSchemaFormatByte
requestBody:
content:
application/x-custom:
schema:
type: string
format: base64
responses:
'200':
description: successful operation
content:
text/plain:
schema:
type: string
format: byte
/upload-property-schema-format-binary:
post:
operationId: uploadPropertySchemaFormatBinary
requestBody:
content:
multipart/form-data:
schema:
type: object
properties:
file:
type: string
format: binary
/upload-property-schema-format-byte:
post:
operationId: uploadPropertySchemaFormatByte
requestBody:
content:
multipart/form-data:
schema:
type: object
properties:
file:
type: string
format: byte

View File

@@ -0,0 +1,150 @@
openapi: 3.1.0
info:
title: "Request body file upload"
description: |-
This document has examples for examining the `schema` or content type for request bodies requiring a file upload
* `application/octect-stream` content type (no matter what schema format)
* `audio/*` content type (no matter what schema format)
* `image/*` content type (no matter what schema format)
* `video/*` content type (no matter what schema format)
* `application/octect-stream` content type with empty Media Type Object
* schema type is `string` and format is `byte` (no matter what content type)
* schema type is `string` and format is `binary` (no matter what content type)
* schema union type includes `string` and format is `byte` (no matter what content type)
* schema union type includes `string` and format is `binary` (no matter what content type)
* multipart/form-data object property schema type is `string` and format is `byte`
* multipart/form-data object property schema type is `string` and format is `binary`
* multipart/form-data object property schema union type includes `string` and format is `byte`
* multipart/form-data object property schema union type includes `string` and format is `binary`
version: "1.0.0"
paths:
/upload-application-octet-stream:
post:
operationId: uploadApplicationOctetStream
requestBody:
content:
application/octet-stream:
schema:
type: string
/upload-image-png:
post:
operationId: uploadImagePng
requestBody:
content:
image/png:
schema:
type: string
/upload-audio-wav:
post:
operationId: uploadAudioWav
requestBody:
content:
audio/wav:
schema:
type: string
/upload-video-mpeg:
post:
operationId: uploadVideoMpeg
requestBody:
content:
video/mpeg:
schema:
type: string
/upload-application-octet-stream-empty:
post:
operationId: uploadApplicationOctetStreamEmpty
requestBody:
content:
application/octet-stream: {}
/upload-schema-type-format-binary:
post:
operationId: uploadSchemaTypeFormatBinary
requestBody:
content:
application/x-custom:
schema:
type: string
format: binary
/upload-schema-type-format-byte:
post:
operationId: uploadSchemaTypeFormatByte
requestBody:
content:
application/x-custom:
schema:
type: string
format: byte
/upload-schema-union-type-format-binary:
post:
operationId: uploadSchemaUnionTypeFormatBinary
requestBody:
content:
application/x-custom:
schema:
type:
- object
- string
format: binary
/upload-schema-union-type-format-byte:
post:
operationId: uploadSchemaUnionTypeFormatByte
requestBody:
content:
application/x-custom:
schema:
type:
- object
- string
format: byte
/upload-property-schema-format-binary:
post:
operationId: uploadPropertySchemaFormatBinary
requestBody:
content:
multipart/form-data:
schema:
type: object
properties:
file:
type: string
format: binary
/upload-property-schema-format-byte:
post:
operationId: uploadPropertySchemaFormatByte
requestBody:
content:
multipart/form-data:
schema:
type: object
properties:
file:
type: string
format: binary
/upload-property-schema-union-type-format-binary:
post:
operationId: uploadPropertySchemaUnionTypeFormatBinary
requestBody:
content:
multipart/form-data:
schema:
type: object
properties:
file:
type:
- object
- string
format: binary
/upload-property-schema-union-type-format-byte:
post:
operationId: uploadPropertySchemaUnionTypeFormatByte
requestBody:
content:
multipart/form-data:
schema:
type: object
properties:
file:
type:
- object
- string
format: byte