Skip to content

Why OpenAPI 3.1.0 does not allow schema references in Parameter & Media Type objects? #2676

Closed Answered by hkosova
flaksp asked this question in Q&A
Discussion options

You must be logged in to vote

@flaksp your example

application/json: 
  schema:
    $ref: "#/components/schemas/Pet"
    description: "Description goes here"
    summary: "Summary goes here"

is perfectly valid in OAS 3.1.0.

Schemas support $ref siblings as part of JSON Schema 2019-09 and later. (OAS 3.1 uses JSON Schema 2020-12 by default.) Schema $refs are a bit different from OpenAPI Reference Objects (used for parameter $refs, response $refs, etc.) in that schema $refs support any sibling keywords, whereas OAS Reference Objects only support sibling summary and description.

Note that JSON Schema doesn't have the summary keyword so it will be handled as an annotation.

Replies: 4 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@flaksp
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by flaksp
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants