Skip to content

Commit 1e6dab6

Browse files
author
Peter Amstutz
committed
Using typeDSL in metaschema.
1 parent 3055f70 commit 1e6dab6

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

schema_salad/metaschema/metaschema.yml

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ $graph:
8484
URI resolution and JSON-LD context generation.
8585
fields:
8686
- name: _id
87-
type: ["null", string]
87+
type: string?
8888
jsonldPredicate:
8989
_id: sld:_id
9090
_type: "@id"
@@ -93,7 +93,7 @@ $graph:
9393
The predicate URI that this field corresponds to.
9494
Corresponds to JSON-LD `@id` directive.
9595
- name: _type
96-
type: ["null", string]
96+
type: string?
9797
doc: |
9898
The context type hint, corresponds to JSON-LD `@type` directive.
9999
@@ -106,32 +106,32 @@ $graph:
106106
resolved using the vocabulary resolution rules.
107107
108108
- name: _container
109-
type: ["null", string]
109+
type: string?
110110
doc: |
111111
Structure hint, corresponds to JSON-LD `@container` directive.
112112
- name: identity
113-
type: ["null", boolean]
113+
type: boolean?
114114
doc: |
115115
If true and `_type` is `@id` this indicates that the parent field must
116116
be resolved according to identity resolution rules instead of link
117117
resolution rules. In addition, the field value is considered an
118118
assertion that the linked value exists; absence of an object in the loaded document
119119
with the URI is not an error.
120120
- name: noLinkCheck
121-
type: ["null", boolean]
121+
type: boolean?
122122
doc: |
123123
If true, this indicates that link validation traversal must stop at
124124
this field. This field (it is is a URI) or any fields under it (if it
125125
is an object or array) are not subject to link checking.
126126
- name: mapSubject
127-
type: ["null", string]
127+
type: string?
128128
doc: |
129129
If the value of the field is a JSON object, it must be transformed
130130
into an array of JSON objects, where each key-value pair from the
131131
source JSON object is a list item, the list items must be JSON objects,
132132
and the key is assigned to the field specified by `mapSubject`.
133133
- name: mapPredicate
134-
type: ["null", string]
134+
type: string?
135135
doc: |
136136
Only applies if `mapSubject` is also provided. If the value of the
137137
field is a JSON object, it is transformed as described in `mapSubject`,
@@ -140,9 +140,7 @@ $graph:
140140
field specified by `mapSubject` and the value assigned to the field
141141
specified by `mapPredicate`.
142142
- name: refScope
143-
type:
144-
- "null"
145-
- int
143+
type: int?
146144
doc: |
147145
If the field contains a relative reference, it must be resolved by
148146
searching for valid document references in each successive parent scope
@@ -157,7 +155,7 @@ $graph:
157155
`#foo/foo` and the `#foo`. The last scope searched must be the top
158156
level scope before determining if the identifier cannot be resolved.
159157
- name: typeDSL
160-
type: ["null", boolean]
158+
type: boolean?
161159
doc: |
162160
Field must be expanded based on the the Schema Salad type DSL.
163161
@@ -204,7 +202,7 @@ $graph:
204202
jsonldPredicate: "sld:doc"
205203

206204
- name: docParent
207-
type: ["null", string]
205+
type: string?
208206
doc: |
209207
Hint to indicate that during documentation generation, documentation
210208
for this type should appear in a subsection under `docParent`.
@@ -226,7 +224,7 @@ $graph:
226224
_type: "@id"
227225

228226
- name: docAfter
229-
type: ["null", string]
227+
type: string?
230228
doc: |
231229
Hint to indicate that during documentation generation, documentation
232230
for this type should appear after the `docAfter` section at the same
@@ -253,7 +251,7 @@ $graph:
253251
jsonldPredicate: "sld:jsonldPredicate"
254252

255253
- name: documentRoot
256-
type: ["null", boolean]
254+
type: boolean?
257255
doc: |
258256
If true, indicates that the type is a valid at the document root. At
259257
least one type in a schema must be tagged with `documentRoot: true`.
@@ -270,7 +268,7 @@ $graph:
270268
The name of the field
271269
272270
- name: doc
273-
type: ["null", string]
271+
type: string?
274272
doc: |
275273
A documentation string for this field
276274
jsonldPredicate: "sld:doc"
@@ -344,7 +342,7 @@ $graph:
344342
specializeTo: "#SaladRecordField"
345343
fields:
346344
- name: abstract
347-
type: ["null", boolean]
345+
type: boolean?
348346
doc: |
349347
If true, this record is abstract and may be used as a base for other
350348
records, but is not valid on its own.

schema_salad/ref_resolver.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ def _type_dsl(self, t):
364364
"items": r}
365365
if m.group(3):
366366
r = ["null", r]
367+
print t, "DSL to", r
367368
return r
368369

369370
def _resolve_type_dsl(self, document, loader):

0 commit comments

Comments
 (0)