Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Loading