diff --git a/src/core/plugins/json-schema-5/components/json-schema-components.jsx b/src/core/plugins/json-schema-5/components/json-schema-components.jsx index 9f1cf55163c..f9c7c902f40 100644 --- a/src/core/plugins/json-schema-5/components/json-schema-components.jsx +++ b/src/core/plugins/json-schema-5/components/json-schema-components.jsx @@ -196,10 +196,15 @@ export class JsonSchema_array extends PureComponent { const schemaItemsType = fn.getSchemaObjectType(schemaItems) const schemaItemsTypeLabel = fn.getSchemaObjectTypeLabel(schemaItems) const schemaItemsFormat = schema.getIn(["items", "format"]) + const schemaItemsContentMediaType = schema.getIn(["items", "contentMediaType"]) const schemaItemsSchema = schema.get("items") let ArrayItemsComponent let isArrayItemText = false - let isArrayItemFile = (schemaItemsType === "file" || (schemaItemsType === "string" && schemaItemsFormat === "binary")) + let isArrayItemFile = ( + schemaItemsType === "file" || + (schemaItemsType === "string" && schemaItemsFormat === "binary") || + (schemaItemsType === "string" && typeof schemaItemsContentMediaType === "string" && schemaItemsContentMediaType !== "") + ) if (schemaItemsType && schemaItemsFormat) { ArrayItemsComponent = getComponent(`JsonSchema_${schemaItemsType}_${schemaItemsFormat}`) } else if (schemaItemsType === "boolean" || schemaItemsType === "array" || schemaItemsType === "object") { diff --git a/test/e2e-cypress/e2e/features/plugins/oas31/oas31-request-body-upload-file.cy.js b/test/e2e-cypress/e2e/features/plugins/oas31/oas31-request-body-upload-file.cy.js index 56541204969..76e20c85084 100644 --- a/test/e2e-cypress/e2e/features/plugins/oas31/oas31-request-body-upload-file.cy.js +++ b/test/e2e-cypress/e2e/features/plugins/oas31/oas31-request-body-upload-file.cy.js @@ -324,4 +324,20 @@ describe("OpenAPI 3.1 Request Body upload file button", () => { ).should("have.prop", "type", "file") }) }) + + describe("multipart/form-data array property whose items schema has contentMediaType with non-empty string", () => { + beforeEach(() => { + cy.get( + "#operations-default-uploadArrayPropertySchemaContentMediaType" + ).click() + }) + + it("should display a file upload button when an item is added", () => { + cy.get(".try-out__btn").click() + cy.get(".json-schema-form-item-add").click() + cy.get( + ".opblock-section-request-body .json-schema-array .json-schema-form-item input" + ).should("have.prop", "type", "file") + }) + }) }) diff --git a/test/e2e-cypress/static/documents/features/oas31-request-body-upload-file.yaml b/test/e2e-cypress/static/documents/features/oas31-request-body-upload-file.yaml index ffbf658c17e..3b0f6d752c6 100644 --- a/test/e2e-cypress/static/documents/features/oas31-request-body-upload-file.yaml +++ b/test/e2e-cypress/static/documents/features/oas31-request-body-upload-file.yaml @@ -18,8 +18,9 @@ info: * 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` - * multipart/form-data object property schema `contentMediaType` is present and is a non-empty `string` + * multipart/form-data object property schema `contentMediaType` is present and is a non-empty `string` * multipart/form-data object property schema `contentEncoding` is present and is a non-empty `string` + * multipart/form-data array property whose items schema has `contentMediaType` set to a non-empty `string` version: "1.0.0" paths: /upload-application-octet-stream: @@ -190,3 +191,17 @@ paths: properties: file: contentEncoding: base64 + /upload-array-property-schema-contentMediaType: + post: + operationId: uploadArrayPropertySchemaContentMediaType + requestBody: + content: + multipart/form-data: + schema: + type: object + properties: + files: + type: array + items: + type: string + contentMediaType: application/octet-stream