mirror of
https://github.com/matrix-org/matrix-spec
synced 2025-12-20 16:38:37 +01:00
Document OpenAPI extension
Signed-off-by: Alexey Rusakov <Alexey.Rusakov@pm.me>
This commit is contained in:
parent
9be78f3aa7
commit
b41eb26124
|
|
@ -21,3 +21,25 @@ Example:
|
||||||
name: fields...
|
name: fields...
|
||||||
type: string
|
type: string
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Using oneOf to provide type alternatives
|
||||||
|
|
||||||
|
<!-- TODO: Remove this section after upgrading to OpenAPI v3 -->
|
||||||
|
|
||||||
|
`oneOf` (available in JSON Schema and Swagger/OpenAPI v3 but not in v2)
|
||||||
|
is used in cases when a simpler type specification as a list of types
|
||||||
|
doesn't work, as in the following example:
|
||||||
|
```
|
||||||
|
properties:
|
||||||
|
old: # compliant with old Swagger
|
||||||
|
type:
|
||||||
|
- string
|
||||||
|
- object # Cannot specify a schema here
|
||||||
|
new: # uses oneOf extension
|
||||||
|
oneOf:
|
||||||
|
- type: string
|
||||||
|
- type: object
|
||||||
|
title: CustomSchemaForTheWin
|
||||||
|
properties:
|
||||||
|
...
|
||||||
|
```
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue