-
-
Save shockey/63f4415ff08672f3e8039c3d7a4fcd7f to your computer and use it in GitHub Desktop.
Example of using `allOf`, `anyOf`, `oneOf`, and `not` to describe a schema in an OpenAPI spec. Also includes a nullable schema.
This file contains 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
# Invalid! Used for testing 3.0 version-guarding in the UI rendering. | |
swagger: "2.0" | |
servers: [] | |
info: | |
version: 1.0.0 | |
title: minimal | |
description: News Articles ftw | |
paths: | |
/users: | |
get: | |
responses: | |
'200': | |
description: hello world | |
definitions: | |
NewsArticle: | |
title: NewsArticle | |
type: object | |
nullable: true | |
properties: | |
id: | |
type: integer | |
format: int32 | |
x-mysql-type: int(11) | |
allOfNewsArticle: | |
title: allOfNewsArticle | |
type: object | |
allOf: | |
- $ref: '#/definitions/NewsArticle' | |
- properties: | |
articleBody: | |
type: string | |
anyOfNewsArticle: | |
title: anyOfNewsArticle | |
type: object | |
anyOf: | |
- $ref: '#/definitions/NewsArticle' | |
- properties: | |
articleBody: | |
type: string | |
oneOfNewsArticle: | |
title: oneOfNewsArticle | |
type: object | |
oneOf: | |
- $ref: '#/definitions/NewsArticle' | |
- properties: | |
articleBody: | |
type: string | |
notNewsArticle: | |
title: notNewsArticle | |
type: object | |
allOf: | |
- $ref: '#/definitions/NewsArticle' | |
- not: | |
articleBody: | |
type: string | |
responses: {} | |
parameters: {} | |
examples: {} | |
requestBodies: {} | |
securitySchemes: {} | |
headers: {} |
This file contains 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.0.0-RC1 | |
servers: [] | |
info: | |
version: 1.0.0 | |
title: minimal | |
description: News Articles ftw | |
paths: | |
/users: | |
get: | |
responses: | |
'200': | |
description: hello world | |
components: | |
schemas: | |
NewsArticle: | |
title: NewsArticle | |
type: object | |
nullable: true | |
properties: | |
id: | |
type: integer | |
format: int32 | |
x-mysql-type: int(11) | |
allOfNewsArticle: | |
title: allOfNewsArticle | |
type: object | |
allOf: | |
- $ref: '#/components/schemas/NewsArticle' | |
- properties: | |
articleBody: | |
type: string | |
anyOfNewsArticle: | |
title: anyOfNewsArticle | |
type: object | |
anyOf: | |
- $ref: '#/components/schemas/NewsArticle' | |
- properties: | |
articleBody: | |
type: string | |
oneOfNewsArticle: | |
title: oneOfNewsArticle | |
type: object | |
oneOf: | |
- $ref: '#/components/schemas/NewsArticle' | |
- properties: | |
articleBody: | |
type: string | |
notNewsArticle: | |
title: notNewsArticle | |
type: object | |
allOf: | |
- $ref: '#/components/schemas/NewsArticle' | |
- not: | |
articleBody: | |
type: string | |
responses: {} | |
parameters: {} | |
examples: {} | |
requestBodies: {} | |
securitySchemes: {} | |
headers: {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The value of
not
should be a schema, so it should beor
etc.