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
7 changes: 7 additions & 0 deletions src/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,13 @@ export function toOpenAPISchema(
schema: body
}
continue

case 'arrayBuffer':
case 'application/octet-stream':
content['application/octet-stream'] = {
schema: body
}
continue
}
}

Expand Down
33 changes: 33 additions & 0 deletions test/openapi/to-openapi-schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,39 @@ describe('OpenAPI > toOpenAPISchema', () => {
})
})

it('handle arrayBuffer request body', () => {
const app = new Elysia().post('/upload', () => 'ok', {
parse: 'arrayBuffer',
body: t.Any({
description: 'Binary file data'
})
})

is(app, {
components: {
schemas: {}
},
paths: {
'/upload': {
post: {
operationId: 'postUpload',
requestBody: {
description: 'Binary file data',
content: {
'application/octet-stream': {
schema: {
description: 'Binary file data'
}
}
},
required: true
}
}
}
}
})
})

it('handle response', () => {
const app = new Elysia().get(
'/user',
Expand Down