Skip to content

Commit 034f99d

Browse files
committed
fix for #2
Signed-off-by: Clemens Vasters <clemens@vasters.com>
1 parent fba976c commit 034f99d

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

draft-vasters-json-structure-core.md

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,9 @@ This schema constrains a JSON node to be of type `string`:
139139
~~~
140140

141141
In the case of a schema that references a compound type (`object`, `set`,
142-
`array`, `map`, `tuple`), the schema further describes the structure of the
143-
compound type. Schemas can be placed into a namespace ({{namespaces}}) for
144-
reuse in other schemas.
142+
`array`, `map`, `tuple`, `choice`), the schema further describes the structure
143+
of the compound type. Schemas can be placed into a namespace ({{namespaces}})
144+
for reuse in other schemas.
145145

146146
~~~ json
147147
{
@@ -611,9 +611,16 @@ The `tuple` type is used to define an ordered collection of elements with a
611611
specific length. It's represented as a JSON array where each element is of a
612612
specific type.
613613

614-
The elements are defined using a `properties` map as with the
615-
`object` ({{object}}) type and each element is named. All declared properties of
616-
a `tuple` are implicitly required.
614+
The elements are defined using a `properties` map as with the `object`
615+
({{object}}) type and each element is named. This permits straightforward
616+
mapping into application constructs. All declared properties of a `tuple` are
617+
implicitly REQUIRED.
618+
619+
The order of the elements in a tuple is declared using the `tuple` keyword
620+
{{tuple-keyword}}, which is REQUIRED. The `tuple` keyword MUST be a JSON array
621+
of strings, where each declared property name MUST be an element of the array.
622+
The order of the elements in the array defines the order of the properties in
623+
the tuple.
617624

618625
A `tuple` type MUST include a `name` attribute that defines the name of the
619626
type.
@@ -627,7 +634,8 @@ Example:
627634
"properties": {
628635
"name": { "type": "string" },
629636
"age": { "type": "int32" }
630-
}
637+
},
638+
"tuple": ["name", "age"]
631639
}
632640
~~~
633641

@@ -1371,6 +1379,17 @@ The `selector` keyword MUST only be used in schemas of type `choice` ({{choice}}
13711379

13721380
See `choice` ({{choice}}) for an example.
13731381

1382+
### The `tuple` Keyword {#tuple-keyword}
1383+
1384+
The `tuple` keyword defines the order of properties in a `tuple` type. The
1385+
value of `tuple` MUST be an array of strings, where each string is the name of a
1386+
property defined in the `properties` map. The order of the strings in the array
1387+
defines the order of the properties in the tuple.
1388+
1389+
The `tuple` keyword MUST only be used in schemas of type `tuple` ({{tuple}}).
1390+
1391+
See `tuple` ({{tuple}}) for an example.
1392+
13741393
## Type Annotation Keywords {#type-annotation-keywords}
13751394

13761395
Type annotation keywords provide additional metadata about the underlying type.

0 commit comments

Comments
 (0)