Skip to content

Commit 81e3dd5

Browse files
committed
Combine some definitions as filtered supersets
1 parent 9592b1f commit 81e3dd5

File tree

2 files changed

+69
-114
lines changed

2 files changed

+69
-114
lines changed

schemas/v3.0/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,6 @@ not:
4343
- examples
4444
```
4545

46+
## Combine some definitions as filtered supersets
47+
48+
With same pattern as for Parameter.

schemas/v3.0/schema.yaml

Lines changed: 66 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -377,31 +377,11 @@ definitions:
377377
additionalProperties: false
378378

379379
MediaType:
380-
oneOf:
381-
- $ref: '#/definitions/MediaTypeWithExample'
382-
- $ref: '#/definitions/MediaTypeWithExamples'
383-
384-
MediaTypeWithExample:
385380
type: object
386381
properties:
387382
schema:
388383
$ref: '#/definitions/Schema'
389384
example: {}
390-
encoding:
391-
type: object
392-
additionalProperties:
393-
$ref: '#/definitions/Encoding'
394-
patternProperties:
395-
'^x-': {}
396-
additionalProperties: false
397-
398-
MediaTypeWithExamples:
399-
type: object
400-
required:
401-
- examples
402-
properties:
403-
schema:
404-
$ref: '#/definitions/Schema'
405385
examples:
406386
type: object
407387
additionalProperties:
@@ -415,6 +395,9 @@ definitions:
415395
patternProperties:
416396
'^x-': {}
417397
additionalProperties: false
398+
not:
399+
description: Example and examples are mutually exclusive
400+
required: [example, examples]
418401

419402
Example:
420403
type: object
@@ -432,19 +415,7 @@ definitions:
432415
additionalProperties: false
433416

434417
Header:
435-
oneOf:
436-
- $ref: '#/definitions/HeaderWithSchema'
437-
- $ref: '#/definitions/HeaderWithContent'
438-
439-
HeaderWithSchema:
440-
oneOf:
441-
- $ref: '#/definitions/HeaderWithSchemaWithExample'
442-
- $ref: '#/definitions/HeaderWithSchemaWithExamples'
443-
444-
HeaderWithSchemaWithExample:
445418
type: object
446-
required:
447-
- schema
448419
properties:
449420
description:
450421
type: string
@@ -469,40 +440,13 @@ definitions:
469440
default: false
470441
schema:
471442
$ref: '#/definitions/Schema'
443+
content:
444+
type: object
445+
additionalProperties:
446+
$ref: '#/definitions/MediaType'
447+
minProperties: 1
448+
maxProperties: 1
472449
example: {}
473-
patternProperties:
474-
'^x-': {}
475-
additionalProperties: false
476-
477-
HeaderWithSchemaWithExamples:
478-
type: object
479-
required:
480-
- schema
481-
- examples
482-
properties:
483-
description:
484-
type: string
485-
required:
486-
type: boolean
487-
default: false
488-
deprecated:
489-
type: boolean
490-
default: false
491-
allowEmptyValue:
492-
type: boolean
493-
default: false
494-
style:
495-
type: string
496-
enum:
497-
- simple
498-
default: simple
499-
explode:
500-
type: boolean
501-
allowReserved:
502-
type: boolean
503-
default: false
504-
schema:
505-
$ref: '#/definitions/Schema'
506450
examples:
507451
type: object
508452
additionalProperties:
@@ -512,32 +456,29 @@ definitions:
512456
patternProperties:
513457
'^x-': {}
514458
additionalProperties: false
459+
allOf:
460+
- description: Example and examples are mutually exclusive
461+
not:
462+
required: [example, examples]
515463

516-
HeaderWithContent:
517-
type: object
518-
required:
519-
- content
520-
properties:
521-
description:
522-
type: string
523-
required:
524-
type: boolean
525-
default: false
526-
deprecated:
527-
type: boolean
528-
default: false
529-
allowEmptyValue:
530-
type: boolean
531-
default: false
532-
content:
533-
type: object
534-
additionalProperties:
535-
$ref: '#/definitions/MediaType'
536-
minProperties: 1
537-
maxProperties: 1
538-
patternProperties:
539-
'^x-': {}
540-
additionalProperties: false
464+
- description: Schema and content are mutually exclusive, at least one is required
465+
not:
466+
required: [schema, content]
467+
oneOf:
468+
- required: [schema]
469+
- description: Content does not allow some properties
470+
required: [content]
471+
allOf:
472+
- not:
473+
required: [style]
474+
- not:
475+
required: [explode]
476+
- not:
477+
required: [allowReserved]
478+
- not:
479+
required: [example]
480+
- not:
481+
required: [examples]
541482

542483
Paths:
543484
type: object
@@ -857,9 +798,37 @@ definitions:
857798
additionalProperties: false
858799

859800
HTTPSecurityScheme:
801+
type: object
802+
required:
803+
- scheme
804+
- type
805+
properties:
806+
scheme:
807+
type: string
808+
bearerFormat:
809+
type: string
810+
description:
811+
type: string
812+
type:
813+
type: string
814+
enum:
815+
- http
816+
patternProperties:
817+
'^x-': {}
818+
additionalProperties: false
860819
oneOf:
861-
- $ref: '#/definitions/NonBearerHTTPSecurityScheme'
862-
- $ref: '#/definitions/BearerHTTPSecurityScheme'
820+
- description: Bearer
821+
properties:
822+
scheme:
823+
enum: [bearer]
824+
825+
- description: Non Bearer
826+
not:
827+
required: [bearerFormat]
828+
properties:
829+
scheme:
830+
not:
831+
enum: [bearer]
863832

864833
NonBearerHTTPSecurityScheme:
865834
type: object
@@ -1038,13 +1007,10 @@ definitions:
10381007
additionalProperties: false
10391008

10401009
Link:
1041-
oneOf:
1042-
- $ref: '#/definitions/LinkWithOperationRef'
1043-
- $ref: '#/definitions/LinkWithOperationId'
1044-
1045-
LinkWithOperationRef:
10461010
type: object
10471011
properties:
1012+
operationId:
1013+
type: string
10481014
operationRef:
10491015
type: string
10501016
format: uri-reference
@@ -1059,23 +1025,9 @@ definitions:
10591025
patternProperties:
10601026
'^x-': {}
10611027
additionalProperties: false
1062-
1063-
LinkWithOperationId:
1064-
type: object
1065-
properties:
1066-
operationId:
1067-
type: string
1068-
parameters:
1069-
type: object
1070-
additionalProperties: {}
1071-
requestBody: {}
1072-
description:
1073-
type: string
1074-
server:
1075-
$ref: '#/definitions/Server'
1076-
patternProperties:
1077-
'^x-': {}
1078-
additionalProperties: false
1028+
not:
1029+
description: Operation Id and Operation Ref are mutually exclusive
1030+
required: [operationId, operationRef]
10791031

10801032
Callback:
10811033
type: object

0 commit comments

Comments
 (0)