blob: edcd2a57baa53e34b73d93501bd49d68ae48cc35 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
Partial schemas
===============
It is possible to create small partial schemas that can be included in other schemas.
This feature do not use any built-in ``YAML`` or ``JSON`` linking.
To define a partial schema use the keyword ``schema;(schema-id):``. ``(schema-id)`` name must be globally unique. If collisions is detected then error will be raised.
To use a partial schema use the keyword ``include: (schema-id):``. This will work at any place you can specify the keyword ``type``. Include directive do not currently work inside a partial schema.
It is possible to define any number of partial schemas in any schema file as long as they are defined at top level of the schema.
For example, this schema contains one partial and the regular schema.
.. code-block:: yaml
# Schema
schema;map_str:
type: map
mapping:
foo:
type: str
type: seq
sequence:
- include: map_str
.. code-block:: yaml
# Data
- foo: opa
schema;(schema-name)
--------------------
See the ``Partial schemas`` section for details.
Names must be globally unique.
Example
.. code-block:: yaml
# Schema
schema;list_str:
type: seq
sequence:
- type: str
schema;list_int:
type: seq
sequence:
- type: int
Include
-------
Used in ``partial schema`` system. Includes are lazy and are loaded during parsing / validation.
Example
.. code-block:: yaml
# Schema [barfoo.yaml]
schema;list_str:
type: seq
sequence:
- type: str
.. code-block:: yaml
# Schema [foobar.yaml]
include: list_str
.. code-block:: yaml
# Data
- foobar
|