Last active
December 8, 2020 10:22
-
-
Save MikeRalphson/c533a8e977129b616565cfecbc14a6f4 to your computer and use it in GitHub Desktop.
OpenAPI 3.1 $ref inside and outside schema objects
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
openapi: 3.1.0 | |
info: | |
title: My API | |
version: 1.0.0 | |
paths: | |
/things: | |
post: | |
parameters: | |
- $ref: '#/components/parameters/type' | |
description: The type of the thing to submit # only summary and description are effective here, they override any inside the $ref | |
requestBody: | |
required: true | |
content: | |
'application/json': | |
schema: | |
$ref: '#/components/schemas/thing' | |
required: | |
- name | |
responses: | |
'200': | |
description: OK | |
content: | |
'application/json': | |
schema: | |
$ref: '#/components/schemas/thing' | |
required: # all constraints within and outside the $ref must validate | |
- id | |
- name | |
description: The new thing being returned including its id # all annotations within and outside the $ref are collected (not merged or overridden) | |
components: | |
schemas: | |
thing: | |
description: Generic description of a thing with no required properties | |
type: object | |
properties: | |
id: | |
type: integer | |
name: | |
type: string | |
parameters: | |
type: | |
description: Generic description of a type parameter | |
name: type | |
in: query | |
schema: | |
type: string |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment