shacl2code 0.0.8__tar.gz → 0.0.10__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {shacl2code-0.0.8 → shacl2code-0.0.10}/PKG-INFO +1 -1
- {shacl2code-0.0.8 → shacl2code-0.0.10}/src/shacl2code/lang/templates/jsonschema.j2 +48 -25
- {shacl2code-0.0.8 → shacl2code-0.0.10}/src/shacl2code/lang/templates/python.j2 +757 -326
- {shacl2code-0.0.8 → shacl2code-0.0.10}/src/shacl2code/model.py +28 -52
- shacl2code-0.0.10/src/shacl2code/version.py +1 -0
- {shacl2code-0.0.8 → shacl2code-0.0.10}/tests/data/model/test-context.json +16 -0
- {shacl2code-0.0.8 → shacl2code-0.0.10}/tests/data/model/test.ttl +69 -3
- shacl2code-0.0.10/tests/data/python/bad-object-type-inline.json +13 -0
- shacl2code-0.0.10/tests/data/python/bad-object-type-ref-after.json +14 -0
- shacl2code-0.0.10/tests/data/python/bad-object-type-ref-before.json +14 -0
- {shacl2code-0.0.8 → shacl2code-0.0.10}/tests/data/python/roundtrip.json +5 -0
- {shacl2code-0.0.8 → shacl2code-0.0.10}/tests/expect/jsonschema/test-context.json +422 -109
- {shacl2code-0.0.8 → shacl2code-0.0.10}/tests/expect/jsonschema/test.json +422 -109
- {shacl2code-0.0.8 → shacl2code-0.0.10}/tests/expect/python/test-context.py +884 -466
- {shacl2code-0.0.8 → shacl2code-0.0.10}/tests/expect/python/test.py +880 -429
- {shacl2code-0.0.8 → shacl2code-0.0.10}/tests/expect/raw/test-context.txt +5 -1
- shacl2code-0.0.10/tests/expect/raw/test.txt +19 -0
- {shacl2code-0.0.8 → shacl2code-0.0.10}/tests/test_jsonschema.py +106 -0
- {shacl2code-0.0.8 → shacl2code-0.0.10}/tests/test_python.py +476 -119
- shacl2code-0.0.8/src/shacl2code/version.py +0 -1
- shacl2code-0.0.8/tests/expect/raw/test.txt +0 -17
- {shacl2code-0.0.8 → shacl2code-0.0.10}/.flake8 +0 -0
- {shacl2code-0.0.8 → shacl2code-0.0.10}/.github/workflows/coverage-generate.yaml +0 -0
- {shacl2code-0.0.8 → shacl2code-0.0.10}/.github/workflows/coverage-report.yaml +0 -0
- {shacl2code-0.0.8 → shacl2code-0.0.10}/.github/workflows/publish.yaml +0 -0
- {shacl2code-0.0.8 → shacl2code-0.0.10}/.github/workflows/test.yaml +0 -0
- {shacl2code-0.0.8 → shacl2code-0.0.10}/.gitignore +0 -0
- {shacl2code-0.0.8 → shacl2code-0.0.10}/LICENSE +0 -0
- {shacl2code-0.0.8 → shacl2code-0.0.10}/README.md +0 -0
- {shacl2code-0.0.8 → shacl2code-0.0.10}/pyproject.toml +0 -0
- {shacl2code-0.0.8 → shacl2code-0.0.10}/src/shacl2code/__init__.py +0 -0
- {shacl2code-0.0.8 → shacl2code-0.0.10}/src/shacl2code/__main__.py +0 -0
- {shacl2code-0.0.8 → shacl2code-0.0.10}/src/shacl2code/context.py +0 -0
- {shacl2code-0.0.8 → shacl2code-0.0.10}/src/shacl2code/lang/__init__.py +0 -0
- {shacl2code-0.0.8 → shacl2code-0.0.10}/src/shacl2code/lang/common.py +0 -0
- {shacl2code-0.0.8 → shacl2code-0.0.10}/src/shacl2code/lang/jinja.py +0 -0
- {shacl2code-0.0.8 → shacl2code-0.0.10}/src/shacl2code/lang/jsonschema.py +0 -0
- {shacl2code-0.0.8 → shacl2code-0.0.10}/src/shacl2code/lang/lang.py +0 -0
- {shacl2code-0.0.8 → shacl2code-0.0.10}/src/shacl2code/lang/python.py +0 -0
- {shacl2code-0.0.8 → shacl2code-0.0.10}/src/shacl2code/main.py +0 -0
- {shacl2code-0.0.8 → shacl2code-0.0.10}/src/shacl2code/urlcontext.py +0 -0
- {shacl2code-0.0.8 → shacl2code-0.0.10}/tests/conftest.py +0 -0
- {shacl2code-0.0.8 → shacl2code-0.0.10}/tests/data/abort.j2 +0 -0
- {shacl2code-0.0.8 → shacl2code-0.0.10}/tests/data/bad-id.j2 +0 -0
- {shacl2code-0.0.8 → shacl2code-0.0.10}/tests/data/bad-node-kind.ttl +0 -0
- {shacl2code-0.0.8 → shacl2code-0.0.10}/tests/data/bad-pattern-class.ttl +0 -0
- {shacl2code-0.0.8 → shacl2code-0.0.10}/tests/data/bad-pattern-integer.ttl +0 -0
- {shacl2code-0.0.8 → shacl2code-0.0.10}/tests/data/bad-reference.jsonld +0 -0
- {shacl2code-0.0.8 → shacl2code-0.0.10}/tests/data/context-url.j2 +0 -0
- {shacl2code-0.0.8 → shacl2code-0.0.10}/tests/data/context.j2 +0 -0
- {shacl2code-0.0.8 → shacl2code-0.0.10}/tests/data/missing-range.ttl +0 -0
- {shacl2code-0.0.8 → shacl2code-0.0.10}/tests/data/python/links.json +0 -0
- {shacl2code-0.0.8 → shacl2code-0.0.10}/tests/data/raw.j2 +0 -0
- {shacl2code-0.0.8 → shacl2code-0.0.10}/tests/expect/make_expect.py +0 -0
- {shacl2code-0.0.8 → shacl2code-0.0.10}/tests/test_cli.py +0 -0
- {shacl2code-0.0.8 → shacl2code-0.0.10}/tests/test_common_jinja.py +0 -0
- {shacl2code-0.0.8 → shacl2code-0.0.10}/tests/test_common_prefix.py +0 -0
- {shacl2code-0.0.8 → shacl2code-0.0.10}/tests/test_context.py +0 -0
- {shacl2code-0.0.8 → shacl2code-0.0.10}/tests/test_model_source.py +0 -0
|
@@ -36,11 +36,13 @@
|
|
|
36
36
|
|
|
37
37
|
"oneOf": [
|
|
38
38
|
{
|
|
39
|
+
"type": "object",
|
|
39
40
|
"properties": {
|
|
40
41
|
"@graph": {
|
|
41
42
|
"description": "Top level container for JSON-LD objects",
|
|
42
43
|
"type": "array",
|
|
43
44
|
"items": {
|
|
45
|
+
"type": "object",
|
|
44
46
|
"$ref": "#/$defs/AnyClass",
|
|
45
47
|
"unevaluatedProperties": false
|
|
46
48
|
}
|
|
@@ -60,9 +62,20 @@
|
|
|
60
62
|
"{{ varname(class.clsname) }}": {
|
|
61
63
|
"allOf": [
|
|
62
64
|
{
|
|
65
|
+
"type": "object",
|
|
66
|
+
{%- if class.is_extensible %}
|
|
67
|
+
"unevaluatedProperties": true,
|
|
68
|
+
{%- endif %}
|
|
63
69
|
"properties": {
|
|
64
70
|
"{{ class.id_property or "@id" }}": { "$ref": "#/$defs/{{ class.node_kind.split("#")[-1] }}" },
|
|
65
|
-
"{{ context.compact("@type") }}": {
|
|
71
|
+
"{{ context.compact("@type") }}": {
|
|
72
|
+
"oneOf": [
|
|
73
|
+
{%- if class.is_extensible %}
|
|
74
|
+
{ "$ref": "#/$defs/IRI" },
|
|
75
|
+
{%- endif %}
|
|
76
|
+
{ "const": "{{ context.compact_vocab(class._id) }}" }
|
|
77
|
+
]
|
|
78
|
+
}
|
|
66
79
|
}{%- if class.node_kind == SH.IRI %},
|
|
67
80
|
"required": ["{{ class.id_property or "@id" }}"]
|
|
68
81
|
{%- endif %}
|
|
@@ -75,18 +88,22 @@
|
|
|
75
88
|
{%- for d in get_all_derived(class) + [class._id] %}
|
|
76
89
|
{%- set ns.json_refs = ns.json_refs + ["#/$defs/" + varname(classes.get(d).clsname)] %}
|
|
77
90
|
{%- endfor %}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
91
|
+
"anyOf": [
|
|
92
|
+
{%- if ns.json_refs %}
|
|
93
|
+
{
|
|
94
|
+
"type": "object",
|
|
95
|
+
{%- if not class.is_extensible %}
|
|
96
|
+
"unevaluatedProperties": false,
|
|
97
|
+
{%- endif %}
|
|
98
|
+
"anyOf": [
|
|
99
|
+
{%- for r in ns.json_refs %}
|
|
100
|
+
{ "$ref": "{{ r }}" }{% if not loop.last %},{% endif %}
|
|
101
|
+
{%- endfor %}
|
|
102
|
+
]
|
|
103
|
+
},
|
|
104
|
+
{%- endif %}
|
|
105
|
+
{ "$ref": "#/$defs/BlankNodeOrIRI" }
|
|
106
|
+
]
|
|
90
107
|
},
|
|
91
108
|
"{{ varname(class.clsname) }}_props": {
|
|
92
109
|
"allOf": [
|
|
@@ -99,6 +116,7 @@
|
|
|
99
116
|
{%- endif %}
|
|
100
117
|
{%- set required = [] %}
|
|
101
118
|
{
|
|
119
|
+
"type": "object",
|
|
102
120
|
"properties": {
|
|
103
121
|
{%- for prop in class.properties %}
|
|
104
122
|
{%- if not prop.min_count is none and prop.min_count > 0 %}
|
|
@@ -143,14 +161,14 @@
|
|
|
143
161
|
},
|
|
144
162
|
{%- for prop in class.properties %}
|
|
145
163
|
"prop_{{ varname(class.clsname) }}_{{ varname(prop.varname) }}": {
|
|
146
|
-
{%- if prop.
|
|
147
|
-
"$ref": "#/$defs/{{ varname(classes.get(prop.class_id).clsname) }}_derived"
|
|
148
|
-
{%- elif prop.enum_id %}
|
|
164
|
+
{%- if prop.enum_values %}
|
|
149
165
|
"enum": [
|
|
150
|
-
{%- for e in
|
|
151
|
-
"{{ context.compact_vocab(e
|
|
166
|
+
{%- for e in prop.enum_values %}
|
|
167
|
+
"{{ context.compact_vocab(e, prop.path) }}"{% if not loop.last %},{% endif %}
|
|
152
168
|
{%- endfor %}
|
|
153
169
|
]
|
|
170
|
+
{%- elif prop.class_id %}
|
|
171
|
+
"$ref": "#/$defs/{{ varname(classes.get(prop.class_id).clsname) }}_derived"
|
|
154
172
|
{%- else %}
|
|
155
173
|
{%- if prop.datatype == "http://www.w3.org/2001/XMLSchema#string" %}
|
|
156
174
|
{%- if prop.pattern %}
|
|
@@ -213,11 +231,11 @@
|
|
|
213
231
|
{%- endfor %}
|
|
214
232
|
"IRI": {
|
|
215
233
|
"type": "string",
|
|
216
|
-
"pattern": "^(?!_:)
|
|
234
|
+
"pattern": "^(?!_:).+:.+"
|
|
217
235
|
},
|
|
218
236
|
"BlankNode": {
|
|
219
237
|
"type": "string",
|
|
220
|
-
"pattern": "^_
|
|
238
|
+
"pattern": "^_:.+"
|
|
221
239
|
},
|
|
222
240
|
"BlankNodeOrIRI": {
|
|
223
241
|
"oneOf": [
|
|
@@ -244,17 +262,22 @@
|
|
|
244
262
|
"type": "object",
|
|
245
263
|
"properties": {
|
|
246
264
|
"{{ context.compact("@type") }}": {
|
|
247
|
-
"
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
265
|
+
"oneOf": [
|
|
266
|
+
{ "$ref": "#/$defs/IRI" },
|
|
267
|
+
{
|
|
268
|
+
"enum": [
|
|
269
|
+
{%- for class in classes %}
|
|
270
|
+
"{{ context.compact_vocab(class._id) }}"{% if not loop.last %},{% endif %}
|
|
271
|
+
{%- endfor %}
|
|
272
|
+
]
|
|
273
|
+
}
|
|
251
274
|
]
|
|
252
275
|
}
|
|
253
276
|
},
|
|
254
277
|
"required": ["{{ context.compact("@type") }}"]
|
|
255
278
|
},
|
|
256
279
|
"AnyClass": {
|
|
257
|
-
"
|
|
280
|
+
"anyOf": [
|
|
258
281
|
{%- for class in classes %}
|
|
259
282
|
{ "$ref": "#/$defs/{{ varname(class.clsname) }}" }{% if not loop.last %},{% endif %}
|
|
260
283
|
{%- endfor %}
|