Skip to content

Commit efbc9c4

Browse files
author
Peter Amstutz
committed
Add scopedRef to metaschema. Tweak test.
1 parent 9fcd67d commit efbc9c4

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

schema_salad/metaschema/metaschema.yml

+10
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,16 @@ $graph:
139139
the item is transformed to a JSON object with the key assigned to the
140140
field specified by `mapSubject` and the value assigned to the field
141141
specified by `mapPredicate`.
142+
- name: scopedRef
143+
type: ["null", boolean]
144+
doc: |
145+
If the field contains a relative reference, it must be resolved by
146+
searching for valid document references in each successive parent
147+
scope. For example, a reference of "foo" in the context "#foo/bar/baz"
148+
will first check for the existence of "#foo/bar/baz/foo", followed
149+
by "#foo/bar/foo", then "#foo/foo" and then finally "#foo". The first
150+
valid URI in the search order shall be used as the fully resolved value
151+
of the identifier.
142152
143153
- name: SpecializeDef
144154
type: record

tests/test_examples.py

+16-2
Original file line numberDiff line numberDiff line change
@@ -119,20 +119,34 @@ def test_scoped_ref(self):
119119
"id": "foo",
120120
"blurb": {
121121
"id": "bar",
122+
"blurg": {
123+
"id": "quux",
124+
"blurb": {
125+
"id": "q2"
126+
}
127+
},
122128
"blurb": {
123129
"id": "baz",
124-
"ref": ["foo", "bar", "baz"]
130+
"ref": ["foo", "bar", "baz", "quux", "quux/q2"]
125131
}
126132
}
127133
}, "http://example2.com/")
128134

129135
self.assertEquals({'id': 'http://example2.com/#foo',
130136
'blurb': {
131137
'id': 'http://example2.com/#foo/bar',
138+
"blurg": {
139+
"id": "http://example2.com/#foo/bar/quux",
140+
"blurb": {
141+
"id": "http://example2.com/#foo/bar/quux/q2"
142+
}
143+
},
132144
'blurb': {
133145
'ref': ['http://example2.com/#foo',
134146
'http://example2.com/#foo/bar',
135-
'http://example2.com/#foo/bar/baz'],
147+
'http://example2.com/#foo/bar/baz',
148+
'http://example2.com/#foo/bar/quux',
149+
'http://example2.com/#foo/bar/quux/q2'],
136150
'id': 'http://example2.com/#foo/bar/baz'}}},
137151
ra)
138152

0 commit comments

Comments
 (0)