Skip to content

Commit

Permalink
Revert embed references as it flattens definition scopes and therefor…
Browse files Browse the repository at this point in the history
…e affects `*Of`, `required` behavior
  • Loading branch information
vearutop committed Mar 8, 2019
1 parent 2208e08 commit 3f09f46
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 50 deletions.
7 changes: 1 addition & 6 deletions schemas/v3.0/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,4 @@ not:

## Combine some definitions as filtered supersets

With same pattern as for Parameter.

## Embed references

In order to simplify `oneOf` logic, many references can be embedded in respective definitions
(with same pattern as for Schema or Reference).
With same pattern as for Parameter.
105 changes: 61 additions & 44 deletions schemas/v3.0/schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,14 @@ patternProperties:
'^x-': {}
additionalProperties: false
definitions:
RefProperty:
type: string
format: uri-reference

Reference:
type: object
required:
- $ref
patternProperties:
'^\$ref$':
$ref: '#/definitions/RefProperty'

type: string
format: uri-reference
Info:
type: object
required:
Expand Down Expand Up @@ -143,27 +139,37 @@ definitions:
type: object
patternProperties:
'^[a-zA-Z0-9\.\-_]+$':
$ref: '#/definitions/Response'
oneOf:
- $ref: '#/definitions/Reference'
- $ref: '#/definitions/Response'
parameters:
type: object
patternProperties:
'^[a-zA-Z0-9\.\-_]+$':
$ref: '#/definitions/Parameter'
oneOf:
- $ref: '#/definitions/Reference'
- $ref: '#/definitions/Parameter'
examples:
type: object
patternProperties:
'^[a-zA-Z0-9\.\-_]+$':
$ref: '#/definitions/Example'
oneOf:
- $ref: '#/definitions/Reference'
- $ref: '#/definitions/Example'
requestBodies:
type: object
patternProperties:
'^[a-zA-Z0-9\.\-_]+$':
$ref: '#/definitions/RequestBody'
oneOf:
- $ref: '#/definitions/Reference'
- $ref: '#/definitions/RequestBody'
headers:
type: object
patternProperties:
'^[a-zA-Z0-9\.\-_]+$':
$ref: '#/definitions/Header'
oneOf:
- $ref: '#/definitions/Reference'
- $ref: '#/definitions/Header'
securitySchemes:
type: object
patternProperties:
Expand All @@ -175,12 +181,16 @@ definitions:
type: object
patternProperties:
'^[a-zA-Z0-9\.\-_]+$':
$ref: '#/definitions/Link'
oneOf:
- $ref: '#/definitions/Reference'
- $ref: '#/definitions/Link'
callbacks:
type: object
patternProperties:
'^[a-zA-Z0-9\.\-_]+$':
$ref: '#/definitions/Callback'
oneOf:
- $ref: '#/definitions/Reference'
- $ref: '#/definitions/Callback'
patternProperties:
'^x-': {}
additionalProperties: false
Expand Down Expand Up @@ -349,18 +359,20 @@ definitions:
headers:
type: object
additionalProperties:
$ref: '#/definitions/Header'
oneOf:
- $ref: '#/definitions/Header'
- $ref: '#/definitions/Reference'
content:
type: object
additionalProperties:
$ref: '#/definitions/MediaType'
links:
type: object
additionalProperties:
$ref: '#/definitions/Link'
oneOf:
- $ref: '#/definitions/Link'
- $ref: '#/definitions/Reference'
patternProperties:
'^\$ref$':
$ref: '#/definitions/RefProperty'
'^x-': {}
additionalProperties: false

Expand All @@ -373,7 +385,9 @@ definitions:
examples:
type: object
additionalProperties:
$ref: '#/definitions/Example'
oneOf:
- $ref: '#/definitions/Example'
- $ref: '#/definitions/Reference'
encoding:
type: object
additionalProperties:
Expand All @@ -396,8 +410,6 @@ definitions:
type: string
format: uri-reference
patternProperties:
'^\$ref$':
$ref: '#/definitions/RefProperty'
'^x-': {}
additionalProperties: false

Expand Down Expand Up @@ -437,10 +449,10 @@ definitions:
examples:
type: object
additionalProperties:
$ref: '#/definitions/Example'
oneOf:
- $ref: '#/definitions/Example'
- $ref: '#/definitions/Reference'
patternProperties:
'^\$ref$':
$ref: '#/definitions/RefProperty'
'^x-': {}
additionalProperties: false
allOf:
Expand Down Expand Up @@ -471,7 +483,9 @@ definitions:
parameters:
type: array
items:
$ref: '#/definitions/Parameter'
oneOf:
- $ref: '#/definitions/Parameter'
- $ref: '#/definitions/Reference'
uniqueItems: true
patternProperties:
'^(get|put|post|delete|options|head|patch|trace)$':
Expand Down Expand Up @@ -499,16 +513,22 @@ definitions:
parameters:
type: array
items:
$ref: '#/definitions/Parameter'
oneOf:
- $ref: '#/definitions/Parameter'
- $ref: '#/definitions/Reference'
uniqueItems: true
requestBody:
$ref: '#/definitions/RequestBody'
oneOf:
- $ref: '#/definitions/RequestBody'
- $ref: '#/definitions/Reference'
responses:
$ref: '#/definitions/Responses'
callbacks:
type: object
additionalProperties:
$ref: '#/definitions/Callback'
oneOf:
- $ref: '#/definitions/Callback'
- $ref: '#/definitions/Reference'
deprecated:
type: boolean
default: false
Expand All @@ -528,10 +548,14 @@ definitions:
type: object
properties:
default:
$ref: '#/definitions/Response'
oneOf:
- $ref: '#/definitions/Response'
- $ref: '#/definitions/Reference'
patternProperties:
'^[1-5](?:\d{2}|XX)$':
$ref: '#/definitions/Response'
oneOf:
- $ref: '#/definitions/Response'
- $ref: '#/definitions/Reference'
'^x-': {}
minProperties: 1
additionalProperties: false
Expand Down Expand Up @@ -635,15 +659,15 @@ definitions:
examples:
type: object
additionalProperties:
$ref: '#/definitions/Example'
oneOf:
- $ref: '#/definitions/Example'
- $ref: '#/definitions/Reference'
patternProperties:
'^\$ref$':
$ref: '#/definitions/RefProperty'
'^x-': {}
additionalProperties: false
oneOf:
- required: [$ref]
- required: [name, in]
required:
- name
- in
allOf:
- $ref: '#/definitions/ExampleXORExamples'
- $ref: '#/definitions/SchemaXORContent'
Expand Down Expand Up @@ -690,6 +714,8 @@ definitions:

RequestBody:
type: object
required:
- content
properties:
description:
type: string
Expand All @@ -701,13 +727,8 @@ definitions:
type: boolean
default: false
patternProperties:
'^\$ref$':
$ref: '#/definitions/RefProperty'
'^x-': {}
additionalProperties: false
oneOf:
- required: ["content"]
- required: ["$ref"]

SecurityScheme:
oneOf:
Expand Down Expand Up @@ -924,8 +945,6 @@ definitions:
server:
$ref: '#/definitions/Server'
patternProperties:
'^\$ref$':
$ref: '#/definitions/RefProperty'
'^x-': {}
additionalProperties: false
not:
Expand All @@ -937,8 +956,6 @@ definitions:
additionalProperties:
$ref: '#/definitions/PathItem'
patternProperties:
'^\$ref$':
$ref: '#/definitions/RefProperty'
'^x-': {}

Encoding:
Expand Down

0 comments on commit 3f09f46

Please sign in to comment.