Skip to content

Commit 0114153

Browse files
authored
In vocab flag (#97)
* Mark named items as "not in vocabulary" so that they can only be referenced by fully qualified URI and not by short name. Enables adding validated spec extensions without adding new keywords.
1 parent 39516e5 commit 0114153

File tree

4 files changed

+17
-15
lines changed

4 files changed

+17
-15
lines changed

schema_salad/jsonld_context.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,6 @@ def pred(datatype, # type: Dict[str, Union[Dict, str]]
6969
"Dictionaries")
7070
else:
7171
raise Exception("jsonldPredicate must be a List of Dictionaries.")
72-
# if not v:
73-
# if field and "jsonldPrefix" in field:
74-
# defaultBase = field["jsonldPrefix"]
75-
# elif "jsonldPrefix" in datatype:
76-
# defaultBase = datatype["jsonldPrefix"]
7772

7873
ret = v or vee
7974

@@ -108,14 +103,14 @@ def process_type(t, # type: Dict[str, Any]
108103
g.add((classnode, RDF.type, RDFS.Class))
109104

110105
split = urlparse.urlsplit(recordname)
111-
if "jsonldPrefix" in t:
112-
predicate = "%s:%s" % (t["jsonldPrefix"], recordname)
113-
elif split.scheme:
114-
(ns, ln) = rdflib.namespace.split_uri(unicode(recordname))
115-
predicate = recordname
116-
recordname = ln
117-
else:
118-
predicate = "%s:%s" % (defaultPrefix, recordname)
106+
predicate = recordname
107+
if t.get("inVocab", True):
108+
if split.scheme:
109+
(ns, ln) = rdflib.namespace.split_uri(unicode(recordname))
110+
predicate = recordname
111+
recordname = ln
112+
else:
113+
predicate = "%s:%s" % (defaultPrefix, recordname)
119114

120115
if context.get(recordname, predicate) != predicate:
121116
raise Exception("Predicate collision on '%s', '%s' != '%s'" % (

schema_salad/metaschema/metaschema.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,12 @@ $graph:
162162
type: string
163163
jsonldPredicate: "@id"
164164
doc: "The identifier for this type"
165+
- name: inVocab
166+
type: boolean?
167+
doc: |
168+
By default or if "true", include the short name of this type in the
169+
vocabulary (the keys of the JSON-LD context). If false, do not include
170+
the short name in the vocabulary.
165171
166172
167173
- name: DocType

schema_salad/schema.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,8 @@ def make_valid_avro(items, # type: Avro
399399
if isinstance(items, dict):
400400
items = copy.copy(items)
401401
if items.get("name"):
402-
items["name"] = avro_name(items["name"])
402+
if items.get("inVocab", True):
403+
items["name"] = avro_name(items["name"])
403404

404405
if "type" in items and items["type"] in ("https://w3id.org/cwl/salad#record", "https://w3id.org/cwl/salad#enum", "record", "enum"):
405406
if (hasattr(items, "get") and items.get("abstract")) or ("abstract"

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
extras_require = {} # TODO: to be removed when the above is added
4848

4949
setup(name='schema-salad',
50-
version='2.3',
50+
version='2.4',
5151
description='Schema Annotations for Linked Avro Data (SALAD)',
5252
long_description=open(README).read(),
5353
author='Common workflow language working group',

0 commit comments

Comments
 (0)