Skip to content

Allow $ref in request body and response content objects #3056

Closed
@DavidBiesack

Description

@DavidBiesack

I'd like to define an API to allow the client to accept either application/json or application/problem+json for responses; they share the same schema and description. At present, I must copy/paste the Media Type Object each time, rather than define it oncereuse one

That is, I must code:

        '400':
          description: Bad Request
          content:
            application/json:
              description: {My description of the response}
              schema:
                $ref: '#/components/schemas/problemResponse'
            application/problem+json:
              description: {My description of the response}
              schema:
                $ref: '#/components/schemas/problemResponse'

when I'd really like to do is

        '400':
          description: Bad Request
          content:
            application/json:
              description: {My description of the response}
              schema:
                $ref: '#/components/schemas/problemResponse'
            application/problem+json:
               $ref: '#../application~1json'

Maintaining copies is not scalable, especially if one uses Specification Extensions inside the media type object

Each operation's 400 response (or each 422 response, etc) may differ (error descriptions change) so using a $ref for the entire Response Object is not a complete solution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    re-use: ref-everywhereRequests to support referencing in more / all places

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions