#3615·fumadocs

[Feature][OpenAPI] Fallback media adapter for request bodies, instead of throwing

Author: mehnoorsiddiquiCreated Sep 29, 2026Updated Sep 29, 2026

What problem will this feature address?

A request body with a media type that has no adapter makes the whole operation page throw: Media type application/pdf is not supported (in …). This happens during prerender and in the browser. Common real-world types hit it: text/html, application/pdf, text/csv, application/zip, and wildcard ranges such as image/* and */*, which OpenAPI allows as content keys. Response bodies with these types render fine.

In #1810 you explained that throwing is intentional because the code samples can't be encoded correctly, and mediaAdapters was added as the extension point. It works, but only for types listed by name: resolveMediaAdapter (openapi/src/requests/media/resolve-adapter.ts) does an exact lookup, then a +suffix lookup. So an app has to know every media type in every spec it renders ahead of time, and one it misses crashes the page.

A related small bug in the same function: the text/plain fallback checks mediaType === 'text/plain' against the raw value, not normalized. So text/plain; charset=utf-8 skips the fallback and throws, while plain text/plain works. Comparing normalized instead would fix it.

Describe the solution you'd like

A fallback in resolveMediaAdapter, either:

  • a mediaAdapters['*'] (or fallbackMediaAdapter) option used when nothing else matches, or
  • type/* matching against the adapters (image/png → image/*), plus a catch-all.

A built-in read-only fallback would help too: show the media type and schema, and leave the body unencoded in the samples (the current application/octet-stream adapter is close to this).

Describe alternatives you've considered

Collecting every request-body media type from the document at build time and registering the same read-only adapter under each name. This works, but every app has to reimplement it.