Declare OpenAPI request and response bodies by media type
Answer: OpenAPI describes each HTTP representation under a content map. The key is the media type and the value describes it, as a Media Type Object or a Reference Object. Use registered names from the IANA Media Types registry, such as application/json. Put that map on a request body or on a response.
Request bodies and responses
requestBody is a Request Body Object or Reference Object, and it is the request body for this operation. It is fully supported in HTTP methods where the HTTP specification has explicitly defined semantics for request bodies. In other cases where the HTTP spec has little to say about message content (such as GET and DELETE), requestBody is still permitted, but it does not have well-defined semantics, so avoid it if possible. responses is a Responses Object: the list of possible responses as they are returned from executing this operation. A response example in the spec uses content: application/json: with a schema reference.
The Components Object can hold reusable Media Type Objects in a mediaTypes map. | requestBody | responses | |---|---| | requestBody | The request body applicable for this operation | | responses | Possible responses as they are returned | | Parameter content | Representations for the parameter; the map MUST only contain one entry | | Components mediaTypes | Reusable Media Type Objects |
IANA names
The IANA Media Types registry is the list of registered types. application/json is registered there (RFC 8259). The same registry also lists application/json-patch+json. Use that registered name as the OpenAPI content key.
See also
Claims
- id: C1 claim: requestBody holds the request body applicable for an operation. source: S1 evidence: "The request body applicable for this operation"
- id: C3 claim: A content map is keyed by media type and holds Media Type Objects. source: S1 evidence: "The key is the media type and the value describes it"
- id: C4 claim: IANA registers application/json among other media types. source: S2 evidence: "application/json RFC 8259"
Sources
- [S1] OpenAPI Specification. OpenAPI Initiative. https://spec.openapis.org/oas/latest.html . License: Apache-2.0. Accessed 2026-11-19.
- [S2] Media Types. IANA. https://www.iana.org/assignments/media-types/media-types.xhtml . License: CC0-1.0. Accessed 2026-11-19.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: OpenAPI Initiative, OpenAPI Specification; IANA, Media Types. Apache-2.0; CC0-1.0. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: OpenAPI Initiative, OpenAPI Specification; IANA, Media Types. Apache-2.0; CC0-1.0.
Cite this
iinventedlight. 2026. "Declare OpenAPI request and response bodies by media type." iinventedlight Library, iil:note:ztetg411, version of 2026-11-19. https://iinventedlight.com/library/notes/openapi-media-types/. License: CC-BY-4.0.
@misc{iil_note_ztetg411,
author = {{iinventedlight}},
title = {{Declare OpenAPI request and response bodies by media type}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-19},
url = {https://iinventedlight.com/library/notes/openapi-media-types/},
note = {Permanent ID iil:note:ztetg411. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- openapi-media-types.table.json (table; CC-BY-4.0)
- openapi-media-types.schema.json (schema; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/openapi-media-types.md.