Skip to content

parse: 'arrayBuffer' produces empty content in OpenAPI spec #1825

@pae-blue

Description

@pae-blue

When using parse: 'arrayBuffer' with a body schema, the generated OpenAPI spec has an empty content object in requestBody:

{
  "requestBody": {
    "description": "Audio file as binary data",
    "content": {},
    "required": true
  }
}

This causes OpenAPI-to-TypeScript generators to infer the body type as undefined.

The switch in src/openapi.ts of @elysiajs/openapi handles text, urlencoded, json, and formdata, but not arrayBuffer. Same root cause as #1720 (which covers parse: 'none').

Reproduction:

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

A possible fix would be adding arrayBuffer as a case mapping to application/octet-stream, and/or a fallback for any unmatched parse mode so this can't recur.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions