Skip to content

Commit b38414e

Browse files
author
Peter Amstutz
authored
Merge pull request #62 from common-workflow-language/update-salad
Update copy of schema-salad spec
2 parents 83bb027 + f7fe75c commit b38414e

34 files changed

+482
-309
lines changed

salad/schema_salad/metaschema/ident_res.yml

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,33 @@
55
specific objects. Processing must resolve relative identifiers to absolute
66
identifiers using the following rules:
77
8-
* If an identifier URI is prefixed with `#` it is a URI relative
9-
fragment identifier. It is resolved relative to the base URI by setting
10-
or replacing the fragment portion of the base URI.
11-
12-
* If an identifier URI does not contain a scheme and is not prefixed `#` it
13-
is a parent relative fragment identifier. It is resolved relative to the
14-
base URI by the following rule: if the base URI does not contain a
15-
document fragment, set the fragment portion of the base URI. If the base
16-
URI does contain a document fragment, append a slash `/` followed by the
17-
identifier field to the fragment portion of the base URI.
8+
* If an identifier URI begins with `#` it is a current document
9+
fragment identifier. It is resolved relative to the base URI by
10+
setting or replacing the fragment portion of the base URI.
11+
12+
* If an identifier URI contains `#` in some other position is a
13+
relative URI with fragment identifier. It is resolved relative
14+
to the base URI by stripping the last path segment from the base
15+
URI and adding the identifier followed by the fragment.
16+
17+
* If an identifier URI does not contain a scheme and does not
18+
contain `#` it is a parent relative fragment identifier.
19+
20+
* If an identifier URI is a parent relative fragment identifier
21+
and the base URI does not contain a document fragment, set the
22+
document fragment on the base URI.
23+
24+
* If an identifier URI is a parent relative fragment identifier
25+
and the object containing this identifier is assigned to a
26+
parent object field defined with `subscope` in
27+
`jsonldPredicate`, append a slash `/` to the base URI fragment
28+
followed by the value of the parent field `subscope`. Then
29+
append the identifier as described in the next rule.
30+
31+
* If an identifier URI is a parent relative fragment identifier
32+
and the base URI contains a document fragment, append a slash
33+
`/` to the fragment followed by the identifier field to the
34+
fragment portion of the base URI.
1835
1936
* If an identifier URI begins with a namespace prefix declared in
2037
`$namespaces` followed by a colon `:`, the prefix and colon must be

salad/schema_salad/metaschema/ident_res_proc.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@
1414
},
1515
{
1616
"id": "http://example.com/acid#six",
17+
},
18+
{
19+
"subscopeField": {
20+
"id": "http://example.com/base#one/thisIsASubscope/seven"
21+
}
1722
}
18-
]
23+
],
1924
}
2025
}

salad/schema_salad/metaschema/ident_res_schema.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@
99
"name": "id",
1010
"type": "string",
1111
"jsonldPredicate": "@id"
12+
}]}, {
13+
"name": "SubscopeType",
14+
"type": "record",
15+
"fields": [{
16+
"name": "subscopeField",
17+
"type": "ExampleType",
18+
"jsonldPredicate": {
19+
"subscope": "thisIsASubscope"
20+
}
1221
}]
1322
}]
1423
}

salad/schema_salad/metaschema/ident_res_src.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@
1414
},
1515
{
1616
"id": "acid:six",
17+
},
18+
{
19+
"subscopeField": {
20+
"id": "seven"
21+
}
1722
}
18-
]
23+
],
1924
}
2025
}

salad/schema_salad/metaschema/import_include.md

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -110,67 +110,3 @@ This becomes:
110110
}
111111
}
112112
```
113-
114-
115-
## Mixin
116-
117-
During preprocessing traversal, an implementation must resolve `$mixin`
118-
directives. An `$mixin` directive is an object consisting of the field
119-
`$mixin` specifying resource by URI string. If there are additional fields in
120-
the `$mixin` object, these fields override fields in the object which is loaded
121-
from the `$mixin` URI.
122-
123-
The URI string must be resolved to an absolute URI using the link resolution
124-
rules described previously. Implementations must support loading from `file`,
125-
`http` and `https` resources. The URI referenced by `$mixin` must be loaded
126-
and recursively preprocessed as a Salad document. The external imported
127-
document must inherit the context of the importing document, however the file
128-
URI for processing the imported document must be the URI used to retrieve the
129-
imported document. The `$mixin` URI must not include a document fragment.
130-
131-
Once loaded and processed, the `$mixin` node is replaced in the document
132-
structure by the object or array yielded from the import operation.
133-
134-
URIs may reference document fragments which refer to specific an object in
135-
the target document. This indicates that the `$mixin` node must be
136-
replaced by only the object with the appropriate fragment identifier.
137-
138-
It is a fatal error if an import directive refers to an external resource
139-
or resource fragment which does not exist or is not accessible.
140-
141-
### Mixin example
142-
143-
mixin.yml:
144-
```
145-
{
146-
"hello": "world",
147-
"carrot": "orange"
148-
}
149-
150-
```
151-
152-
parent.yml:
153-
```
154-
{
155-
"form": {
156-
"bar": {
157-
"$mixin": "mixin.yml"
158-
"carrot": "cake"
159-
}
160-
}
161-
}
162-
163-
```
164-
165-
This becomes:
166-
167-
```
168-
{
169-
"form": {
170-
"bar": {
171-
"hello": "world",
172-
"carrot": "cake"
173-
}
174-
}
175-
}
176-
```

salad/schema_salad/metaschema/metaschema.yml

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ $graph:
2020
- $include: import_include.md
2121
- $import: map_res.yml
2222
- $import: typedsl_res.yml
23+
- $import: sfdsl_res.yml
2324

2425
- name: "Link_Validation"
2526
type: documentation
@@ -35,10 +36,40 @@ $graph:
3536
`noLinkCheck` in the `jsonldPredicate` section of the field schema.
3637
3738
38-
- name: "Schema_validation"
39+
- name: "Schema_Validation"
3940
type: documentation
40-
doc: ""
41-
41+
doc: |
42+
# Validating a document against a schema
43+
44+
To validate a document against the schema, first [apply
45+
preprocessing](#Document_preprocessing), then, use the following
46+
algorithm.
47+
48+
1. The document root must be an object or a list. If the document root is an
49+
object containing the field `$graph` (which must be a list of
50+
objects), then validation applies to each object in the list.
51+
2. For each object, attempt to validate as one of the record types
52+
flagged with `documentRoot: true`.
53+
3. To validate a record, go through `fields` and recursively
54+
validate each field of the object.
55+
4. For fields with a list of types (type union), go through each
56+
type in the list and recursively validate the type. For the
57+
field to be valid, at least one type in the union must be valid.
58+
5. Missing fields are considered `null`. To validate, the allowed types
59+
for the field must include `null`
60+
6. Primitive types are null, boolean, int, long, float, double,
61+
string. To validate, the value in the document must have one
62+
of these type. For numerics, the value appearing in the
63+
document must fit into the specified type.
64+
7. To validate an array, the value in the document must be a list,
65+
and each item in the list must recursively validate as a type
66+
in `items`.
67+
8. To validate an enum, the value in the document be a string, and
68+
the value must be equal to the short name of one of the values
69+
listed in `symbols`.
70+
9. As a special case, a field with the `Expression` type validates string values
71+
which contain a CWL parameter reference or expression in the form
72+
`$(...)` or `${...}`
4273
4374
# - name: "JSON_LD_Context"
4475
# type: documentation
@@ -131,6 +162,10 @@ $graph:
131162
type: boolean?
132163
doc: |
133164
Field must be expanded based on the the Schema Salad type DSL.
165+
- name: secondaryFilesDSL
166+
type: boolean?
167+
doc: |
168+
Field must be expanded based on the the Schema Salad secondary file DSL.
134169
- name: subscope
135170
type: string?
136171
doc: |
@@ -168,10 +203,18 @@ $graph:
168203
doc: "The identifier for this type"
169204
- name: inVocab
170205
type: boolean?
206+
default: true
171207
doc: |
172-
By default or if "true", include the short name of this type in the
173-
vocabulary (the keys of the JSON-LD context). If false, do not include
174-
the short name in the vocabulary.
208+
If "true" (the default), include the short name of this type
209+
in the vocabulary. The vocabulary are all the symbols (field
210+
names and other identifiers, such as classes and enum values)
211+
which can be used in the document without a namespace prefix.
212+
These are the keys of the JSON-LD context. If false, do not
213+
include the short name in the vocabulary.
214+
215+
This is useful for specifying schema extensions that will be
216+
included in validation without introducing ambiguity by
217+
introducing non-standard terms into the vocabulary.
175218
176219
177220
- name: DocType

salad/schema_salad/metaschema/salad.md

Lines changed: 65 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Author:
44

5-
* Peter Amstutz <peter.amstutz@curoverse.com>, Curoverse
5+
* Peter Amstutz <pamstutz@veritasgenetics.com>, Veritas Genetics
66

77
Contributors:
88

@@ -70,25 +70,29 @@ and RDF schema, and production of RDF triples by applying the JSON-LD
7070
context. The schema language also provides for robust support of inline
7171
documentation.
7272

73-
## Introduction to v1.0
73+
## Introduction to v1.1
7474

75-
This is the second version of of the Schema Salad specification. It is
76-
developed concurrently with v1.0 of the Common Workflow Language for use in
75+
This is the third version of of the Schema Salad specification. It is
76+
developed concurrently with v1.1 of the Common Workflow Language for use in
7777
specifying the Common Workflow Language, however Schema Salad is intended to be
78-
useful to a broader audience. Compared to the draft-1 schema salad
78+
useful to a broader audience. Compared to the v1.0 schema salad
7979
specification, the following changes have been made:
8080

81-
* Use of [mapSubject and mapPredicate](#Identifier_maps) to transform maps to lists of records.
82-
* Resolution of the [domain Specific Language for types](#Domain_Specific_Language_for_types)
83-
* Consolidation of the formal [schema into section 5](#Schema).
81+
* Support for `default` values on record fields to specify default values
82+
* Add subscoped fields (fields which introduce a new inner scope for identifiers)
83+
* Add the *inVocab* flag (default true) to indicate if a type is added to the vocabulary of well known terms or must be prefixed
84+
* Add *secondaryFilesDSL* micro DSL (domain specific language) to convert text strings to a secondaryFiles record type used in CWL
85+
* The `$mixin` feature has been removed from the specification, as it
86+
is poorly documented, not included in conformance testing,
87+
and not widely supported.
8488

8589
## References to Other Specifications
8690

8791
**Javascript Object Notation (JSON)**: http://json.org
8892

8993
**JSON Linked Data (JSON-LD)**: http://json-ld.org
9094

91-
**YAML**: http://yaml.org
95+
**YAML**: https://yaml.org/spec/1.2/spec.html
9296

9397
**Avro**: https://avro.apache.org/docs/current/spec.html
9498

@@ -157,11 +161,19 @@ by a document schema, where each term maps to absolute URI.
157161

158162
## Syntax
159163

160-
Conforming Salad documents are serialized and loaded using YAML syntax and
161-
UTF-8 text encoding. Salad documents are written using the JSON-compatible
162-
subset of YAML. Features of YAML such as headers and type tags that are
163-
not found in the standard JSON data model must not be used in conforming
164-
Salad documents. It is a fatal error if the document is not valid YAML.
164+
Conforming Salad v1.1 documents are serialized and loaded using a
165+
subset of YAML 1.2 syntax and UTF-8 text encoding. Salad documents
166+
are written using the [JSON-compatible subset of YAML described in
167+
section 10.2](https://yaml.org/spec/1.2/spec.html#id2803231). The
168+
following features of YAML must not be used in conforming Salad
169+
documents:
170+
171+
* Use of explicit node tags with leading `!` or `!!`
172+
* Use of anchors with leading `&` and aliases with leading `*`
173+
* %YAML directives
174+
* %TAG directives
175+
176+
It is a fatal error if the document is not valid YAML.
165177

166178
A Salad document must consist only of either a single root object or an
167179
array of objects.
@@ -223,9 +235,9 @@ document schema. A schema may consist of:
223235
* Any number of documentation objects which allow in-line documentation of the schema.
224236

225237
The schema for defining a salad schema (the metaschema) is described in
226-
detail in "Schema validation".
238+
detail in the [Schema](#Schema) section.
227239

228-
### Record field annotations
240+
## Record field annotations
229241

230242
In a document schema, record field definitions may include the field
231243
`jsonldPredicate`, which may be either a string or object. Implementations
@@ -237,11 +249,11 @@ rules:
237249

238250
* If the value of `jsonldPredicate` is an object, and contains that
239251
object contains the field `_type` with the value `@id`, the field is a
240-
link field.
252+
link field subject to [link validation](#Link_validation).
241253

242-
* If the value of `jsonldPredicate` is an object, and contains that
243-
object contains the field `_type` with the value `@vocab`, the field is a
244-
vocabulary field, which is a subtype of link field.
254+
* If the value of `jsonldPredicate` is an object which contains the
255+
field `_type` with the value `@vocab`, the field value is subject to
256+
[vocabulary resolution](#Vocabulary_resolution).
245257

246258
## Document traversal
247259

@@ -250,6 +262,39 @@ validation, the document must be traversed starting from the fields or
250262
array items of the root object or array and recursively visiting each child
251263
item which contains an object or arrays.
252264

265+
## Short names
266+
267+
The "short name" of an fully qualified identifier is the portion of
268+
the identifier following the final slash `/` of either the fragment
269+
identifier following `#` or the path portion, if there is no fragment.
270+
Some examples:
271+
272+
* the short name of `http://example.com/foo` is `foo`
273+
* the short name of `http://example.com/#bar` is `bar`
274+
* the short name of `http://example.com/foo/bar` is `bar`
275+
* the short name of `http://example.com/foo#bar` is `bar`
276+
* the short name of `http://example.com/#foo/bar` is `bar`
277+
* the short name of `http://example.com/foo#bar/baz` is `baz`
278+
279+
## Inheritance and specialization
280+
281+
A record definition may inherit from one or more record definitions
282+
with the `extends` field. This copies the fields defined in the
283+
parent record(s) as the base for the new record. A record definition
284+
may `specialize` type declarations of the fields inherited from the
285+
base record. For each field inherited from the base record, any
286+
instance of the type in `specializeFrom` is replaced with the type in
287+
`specializeTo`. The type in `specializeTo` should extend from the
288+
type in `specializeFrom`.
289+
290+
A record definition may be `abstract`. This means the record
291+
definition is not used for validation on its own, but may be extended
292+
by other definitions. If an abstract type appears in a field
293+
definition, it is logically replaced with a union of all concrete
294+
subtypes of the abstract type. In other words, the field value does
295+
not validate as the abstract type, but must validate as some concrete
296+
type that inherits from the abstract type.
297+
253298
# Document preprocessing
254299

255300
After processing the explicit context (if any), document preprocessing

0 commit comments

Comments
 (0)