Skip to content

Commit

Permalink
Combine some definitions as filtered supersets
Browse files Browse the repository at this point in the history
  • Loading branch information
vearutop committed Mar 8, 2019
1 parent 9592b1f commit 81e3dd5
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 114 deletions.
3 changes: 3 additions & 0 deletions schemas/v3.0/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,6 @@ not:
- examples
```

## Combine some definitions as filtered supersets

With same pattern as for Parameter.
180 changes: 66 additions & 114 deletions schemas/v3.0/schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -377,31 +377,11 @@ definitions:
additionalProperties: false

MediaType:
oneOf:
- $ref: '#/definitions/MediaTypeWithExample'
- $ref: '#/definitions/MediaTypeWithExamples'

MediaTypeWithExample:
type: object
properties:
schema:
$ref: '#/definitions/Schema'
example: {}
encoding:
type: object
additionalProperties:
$ref: '#/definitions/Encoding'
patternProperties:
'^x-': {}
additionalProperties: false

MediaTypeWithExamples:
type: object
required:
- examples
properties:
schema:
$ref: '#/definitions/Schema'
examples:
type: object
additionalProperties:
Expand All @@ -415,6 +395,9 @@ definitions:
patternProperties:
'^x-': {}
additionalProperties: false
not:
description: Example and examples are mutually exclusive
required: [example, examples]

Example:
type: object
Expand All @@ -432,19 +415,7 @@ definitions:
additionalProperties: false

Header:
oneOf:
- $ref: '#/definitions/HeaderWithSchema'
- $ref: '#/definitions/HeaderWithContent'

HeaderWithSchema:
oneOf:
- $ref: '#/definitions/HeaderWithSchemaWithExample'
- $ref: '#/definitions/HeaderWithSchemaWithExamples'

HeaderWithSchemaWithExample:
type: object
required:
- schema
properties:
description:
type: string
Expand All @@ -469,40 +440,13 @@ definitions:
default: false
schema:
$ref: '#/definitions/Schema'
content:
type: object
additionalProperties:
$ref: '#/definitions/MediaType'
minProperties: 1
maxProperties: 1
example: {}
patternProperties:
'^x-': {}
additionalProperties: false

HeaderWithSchemaWithExamples:
type: object
required:
- schema
- examples
properties:
description:
type: string
required:
type: boolean
default: false
deprecated:
type: boolean
default: false
allowEmptyValue:
type: boolean
default: false
style:
type: string
enum:
- simple
default: simple
explode:
type: boolean
allowReserved:
type: boolean
default: false
schema:
$ref: '#/definitions/Schema'
examples:
type: object
additionalProperties:
Expand All @@ -512,32 +456,29 @@ definitions:
patternProperties:
'^x-': {}
additionalProperties: false
allOf:
- description: Example and examples are mutually exclusive
not:
required: [example, examples]

HeaderWithContent:
type: object
required:
- content
properties:
description:
type: string
required:
type: boolean
default: false
deprecated:
type: boolean
default: false
allowEmptyValue:
type: boolean
default: false
content:
type: object
additionalProperties:
$ref: '#/definitions/MediaType'
minProperties: 1
maxProperties: 1
patternProperties:
'^x-': {}
additionalProperties: false
- description: Schema and content are mutually exclusive, at least one is required
not:
required: [schema, content]
oneOf:
- required: [schema]
- description: Content does not allow some properties
required: [content]
allOf:
- not:
required: [style]
- not:
required: [explode]
- not:
required: [allowReserved]
- not:
required: [example]
- not:
required: [examples]

Paths:
type: object
Expand Down Expand Up @@ -857,9 +798,37 @@ definitions:
additionalProperties: false

HTTPSecurityScheme:
type: object
required:
- scheme
- type
properties:
scheme:
type: string
bearerFormat:
type: string
description:
type: string
type:
type: string
enum:
- http
patternProperties:
'^x-': {}
additionalProperties: false
oneOf:
- $ref: '#/definitions/NonBearerHTTPSecurityScheme'
- $ref: '#/definitions/BearerHTTPSecurityScheme'
- description: Bearer
properties:
scheme:
enum: [bearer]

- description: Non Bearer
not:
required: [bearerFormat]
properties:
scheme:
not:
enum: [bearer]

NonBearerHTTPSecurityScheme:
type: object
Expand Down Expand Up @@ -1038,13 +1007,10 @@ definitions:
additionalProperties: false

Link:
oneOf:
- $ref: '#/definitions/LinkWithOperationRef'
- $ref: '#/definitions/LinkWithOperationId'

LinkWithOperationRef:
type: object
properties:
operationId:
type: string
operationRef:
type: string
format: uri-reference
Expand All @@ -1059,23 +1025,9 @@ definitions:
patternProperties:
'^x-': {}
additionalProperties: false

LinkWithOperationId:
type: object
properties:
operationId:
type: string
parameters:
type: object
additionalProperties: {}
requestBody: {}
description:
type: string
server:
$ref: '#/definitions/Server'
patternProperties:
'^x-': {}
additionalProperties: false
not:
description: Operation Id and Operation Ref are mutually exclusive
required: [operationId, operationRef]

Callback:
type: object
Expand Down

0 comments on commit 81e3dd5

Please sign in to comment.