Skip to content

Support for multiple media types #4081

Open
@lcawl

Description

@lcawl

🚀 Feature Proposal

Add a method to specify the supported medias type for each request and response body.
If multiple media types are supported, we'll need a method (such as folder or file names?) to indicate which type each example pertains to.

Motivation

In OpenAPI documents, you can have request and response bodies that support various media types per https://spec.openapis.org/oas/v3.0.3#media-types
For example, the cat API (e.g cat aliases returns text/plain responses by default and you can use the format query parameter to get back JSON, YAML, etc.

It does not seem like we currently have a way to represent these media types in the current specifications.
I am converting the text/plain examples to json to work with the existing system, but it would be good to be able to specify the media type explicitly.

Example

When we were manually curating the examples, it looked like this (i.e. the cat aliases API responses could have both JSON and text formats:

    cat.aliases#200:
      description: ''
      content:
        application/json:
          schema:
            type: array
            items:
              "$ref": "#/components/schemas/cat.aliases:AliasesRecord"
        text/plain:
          schema:
            type: string
          examples:
            catAliasesResponseExample1:
              "$ref": "#/components/examples/CatAliasesResponseExample1"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions