Skip to content

Commit 26cf125

Browse files
committed
Simplify Schema or Reference
1 parent 88dd430 commit 26cf125

File tree

2 files changed

+46
-58
lines changed

2 files changed

+46
-58
lines changed

schemas/v3.0/README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Minimizing schema
2+
3+
## Schema or Reference
4+
5+
All references to `#/definitions/Schema` are happening in such form:
6+
7+
```yaml
8+
oneOf:
9+
- $ref: '#/definitions/Reference'
10+
- $ref: '#/definitions/Schema'
11+
```
12+
13+
Therefore `#/definitions/Reference` can be merged into `#/definitions/Schema` to simplify usages:
14+
15+
```yaml
16+
$ref: '#/definitions/Schema'
17+
```
18+
19+
Validation difference after this change is that additional unknown properties are no longer accepted for References.
20+
Such data would become invalid:
21+
22+
```json
23+
{"$ref": "#", "unknown": 1}
24+
```

schemas/v3.0/schema.yaml

Lines changed: 22 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,7 @@ definitions:
134134
type: object
135135
patternProperties:
136136
'^[a-zA-Z0-9\.\-_]+$':
137-
oneOf:
138-
- $ref: '#/definitions/Reference'
139-
- $ref: '#/definitions/Schema'
137+
$ref: '#/definitions/Schema'
140138
responses:
141139
type: object
142140
patternProperties:
@@ -264,41 +262,28 @@ definitions:
264262
- object
265263
- string
266264
not:
267-
oneOf:
268-
- $ref: '#/definitions/Schema'
269-
- $ref: '#/definitions/Reference'
265+
$ref: '#/definitions/Schema'
270266
allOf:
271267
type: array
272268
items:
273-
oneOf:
274-
- $ref: '#/definitions/Schema'
275-
- $ref: '#/definitions/Reference'
269+
$ref: '#/definitions/Schema'
276270
oneOf:
277271
type: array
278272
items:
279-
oneOf:
280-
- $ref: '#/definitions/Schema'
281-
- $ref: '#/definitions/Reference'
273+
$ref: '#/definitions/Schema'
282274
anyOf:
283275
type: array
284276
items:
285-
oneOf:
286-
- $ref: '#/definitions/Schema'
287-
- $ref: '#/definitions/Reference'
277+
$ref: '#/definitions/Schema'
288278
items:
289-
oneOf:
290-
- $ref: '#/definitions/Schema'
291-
- $ref: '#/definitions/Reference'
279+
$ref: '#/definitions/Schema'
292280
properties:
293281
type: object
294282
additionalProperties:
295-
oneOf:
296-
- $ref: '#/definitions/Schema'
297-
- $ref: '#/definitions/Reference'
283+
$ref: '#/definitions/Schema'
298284
additionalProperties:
299285
oneOf:
300286
- $ref: '#/definitions/Schema'
301-
- $ref: '#/definitions/Reference'
302287
- type: boolean
303288
default: true
304289
description:
@@ -326,6 +311,9 @@ definitions:
326311
xml:
327312
$ref: '#/definitions/XML'
328313
patternProperties:
314+
'^\$ref$':
315+
type: string
316+
format: uri-reference
329317
'^x-': {}
330318
additionalProperties: false
331319

@@ -397,9 +385,7 @@ definitions:
397385
type: object
398386
properties:
399387
schema:
400-
oneOf:
401-
- $ref: '#/definitions/Schema'
402-
- $ref: '#/definitions/Reference'
388+
$ref: '#/definitions/Schema'
403389
example: {}
404390
encoding:
405391
type: object
@@ -415,9 +401,7 @@ definitions:
415401
- examples
416402
properties:
417403
schema:
418-
oneOf:
419-
- $ref: '#/definitions/Schema'
420-
- $ref: '#/definitions/Reference'
404+
$ref: '#/definitions/Schema'
421405
examples:
422406
type: object
423407
additionalProperties:
@@ -484,9 +468,7 @@ definitions:
484468
type: boolean
485469
default: false
486470
schema:
487-
oneOf:
488-
- $ref: '#/definitions/Schema'
489-
- $ref: '#/definitions/Reference'
471+
$ref: '#/definitions/Schema'
490472
example: {}
491473
patternProperties:
492474
'^x-': {}
@@ -520,9 +502,7 @@ definitions:
520502
type: boolean
521503
default: false
522504
schema:
523-
oneOf:
524-
- $ref: '#/definitions/Schema'
525-
- $ref: '#/definitions/Reference'
505+
$ref: '#/definitions/Schema'
526506
examples:
527507
type: object
528508
additionalProperties:
@@ -767,9 +747,7 @@ definitions:
767747
type: boolean
768748
default: false
769749
schema:
770-
oneOf:
771-
- $ref: '#/definitions/Schema'
772-
- $ref: '#/definitions/Reference'
750+
$ref: '#/definitions/Schema'
773751
example: {}
774752
patternProperties:
775753
'^x-': {}
@@ -813,9 +791,7 @@ definitions:
813791
type: boolean
814792
default: false
815793
schema:
816-
oneOf:
817-
- $ref: '#/definitions/Schema'
818-
- $ref: '#/definitions/Reference'
794+
$ref: '#/definitions/Schema'
819795
example: {}
820796
patternProperties:
821797
'^x-': {}
@@ -856,9 +832,7 @@ definitions:
856832
type: boolean
857833
default: false
858834
schema:
859-
oneOf:
860-
- $ref: '#/definitions/Schema'
861-
- $ref: '#/definitions/Reference'
835+
$ref: '#/definitions/Schema'
862836
example: {}
863837
patternProperties:
864838
'^x-': {}
@@ -899,9 +873,7 @@ definitions:
899873
type: boolean
900874
default: false
901875
schema:
902-
oneOf:
903-
- $ref: '#/definitions/Schema'
904-
- $ref: '#/definitions/Reference'
876+
$ref: '#/definitions/Schema'
905877
example: {}
906878
patternProperties:
907879
'^x-': {}
@@ -954,9 +926,7 @@ definitions:
954926
type: boolean
955927
default: false
956928
schema:
957-
oneOf:
958-
- $ref: '#/definitions/Schema'
959-
- $ref: '#/definitions/Reference'
929+
$ref: '#/definitions/Schema'
960930
examples:
961931
type: object
962932
additionalProperties:
@@ -1006,9 +976,7 @@ definitions:
1006976
type: boolean
1007977
default: false
1008978
schema:
1009-
oneOf:
1010-
- $ref: '#/definitions/Schema'
1011-
- $ref: '#/definitions/Reference'
979+
$ref: '#/definitions/Schema'
1012980
examples:
1013981
type: object
1014982
additionalProperties:
@@ -1055,9 +1023,7 @@ definitions:
10551023
type: boolean
10561024
default: false
10571025
schema:
1058-
oneOf:
1059-
- $ref: '#/definitions/Schema'
1060-
- $ref: '#/definitions/Reference'
1026+
$ref: '#/definitions/Schema'
10611027
examples:
10621028
type: object
10631029
additionalProperties:
@@ -1104,9 +1070,7 @@ definitions:
11041070
type: boolean
11051071
default: false
11061072
schema:
1107-
oneOf:
1108-
- $ref: '#/definitions/Schema'
1109-
- $ref: '#/definitions/Reference'
1073+
$ref: '#/definitions/Schema'
11101074
examples:
11111075
type: object
11121076
additionalProperties:

0 commit comments

Comments
 (0)