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.
Files changed (59) hide show
  1. {shacl2code-0.0.8 → shacl2code-0.0.10}/PKG-INFO +1 -1
  2. {shacl2code-0.0.8 → shacl2code-0.0.10}/src/shacl2code/lang/templates/jsonschema.j2 +48 -25
  3. {shacl2code-0.0.8 → shacl2code-0.0.10}/src/shacl2code/lang/templates/python.j2 +757 -326
  4. {shacl2code-0.0.8 → shacl2code-0.0.10}/src/shacl2code/model.py +28 -52
  5. shacl2code-0.0.10/src/shacl2code/version.py +1 -0
  6. {shacl2code-0.0.8 → shacl2code-0.0.10}/tests/data/model/test-context.json +16 -0
  7. {shacl2code-0.0.8 → shacl2code-0.0.10}/tests/data/model/test.ttl +69 -3
  8. shacl2code-0.0.10/tests/data/python/bad-object-type-inline.json +13 -0
  9. shacl2code-0.0.10/tests/data/python/bad-object-type-ref-after.json +14 -0
  10. shacl2code-0.0.10/tests/data/python/bad-object-type-ref-before.json +14 -0
  11. {shacl2code-0.0.8 → shacl2code-0.0.10}/tests/data/python/roundtrip.json +5 -0
  12. {shacl2code-0.0.8 → shacl2code-0.0.10}/tests/expect/jsonschema/test-context.json +422 -109
  13. {shacl2code-0.0.8 → shacl2code-0.0.10}/tests/expect/jsonschema/test.json +422 -109
  14. {shacl2code-0.0.8 → shacl2code-0.0.10}/tests/expect/python/test-context.py +884 -466
  15. {shacl2code-0.0.8 → shacl2code-0.0.10}/tests/expect/python/test.py +880 -429
  16. {shacl2code-0.0.8 → shacl2code-0.0.10}/tests/expect/raw/test-context.txt +5 -1
  17. shacl2code-0.0.10/tests/expect/raw/test.txt +19 -0
  18. {shacl2code-0.0.8 → shacl2code-0.0.10}/tests/test_jsonschema.py +106 -0
  19. {shacl2code-0.0.8 → shacl2code-0.0.10}/tests/test_python.py +476 -119
  20. shacl2code-0.0.8/src/shacl2code/version.py +0 -1
  21. shacl2code-0.0.8/tests/expect/raw/test.txt +0 -17
  22. {shacl2code-0.0.8 → shacl2code-0.0.10}/.flake8 +0 -0
  23. {shacl2code-0.0.8 → shacl2code-0.0.10}/.github/workflows/coverage-generate.yaml +0 -0
  24. {shacl2code-0.0.8 → shacl2code-0.0.10}/.github/workflows/coverage-report.yaml +0 -0
  25. {shacl2code-0.0.8 → shacl2code-0.0.10}/.github/workflows/publish.yaml +0 -0
  26. {shacl2code-0.0.8 → shacl2code-0.0.10}/.github/workflows/test.yaml +0 -0
  27. {shacl2code-0.0.8 → shacl2code-0.0.10}/.gitignore +0 -0
  28. {shacl2code-0.0.8 → shacl2code-0.0.10}/LICENSE +0 -0
  29. {shacl2code-0.0.8 → shacl2code-0.0.10}/README.md +0 -0
  30. {shacl2code-0.0.8 → shacl2code-0.0.10}/pyproject.toml +0 -0
  31. {shacl2code-0.0.8 → shacl2code-0.0.10}/src/shacl2code/__init__.py +0 -0
  32. {shacl2code-0.0.8 → shacl2code-0.0.10}/src/shacl2code/__main__.py +0 -0
  33. {shacl2code-0.0.8 → shacl2code-0.0.10}/src/shacl2code/context.py +0 -0
  34. {shacl2code-0.0.8 → shacl2code-0.0.10}/src/shacl2code/lang/__init__.py +0 -0
  35. {shacl2code-0.0.8 → shacl2code-0.0.10}/src/shacl2code/lang/common.py +0 -0
  36. {shacl2code-0.0.8 → shacl2code-0.0.10}/src/shacl2code/lang/jinja.py +0 -0
  37. {shacl2code-0.0.8 → shacl2code-0.0.10}/src/shacl2code/lang/jsonschema.py +0 -0
  38. {shacl2code-0.0.8 → shacl2code-0.0.10}/src/shacl2code/lang/lang.py +0 -0
  39. {shacl2code-0.0.8 → shacl2code-0.0.10}/src/shacl2code/lang/python.py +0 -0
  40. {shacl2code-0.0.8 → shacl2code-0.0.10}/src/shacl2code/main.py +0 -0
  41. {shacl2code-0.0.8 → shacl2code-0.0.10}/src/shacl2code/urlcontext.py +0 -0
  42. {shacl2code-0.0.8 → shacl2code-0.0.10}/tests/conftest.py +0 -0
  43. {shacl2code-0.0.8 → shacl2code-0.0.10}/tests/data/abort.j2 +0 -0
  44. {shacl2code-0.0.8 → shacl2code-0.0.10}/tests/data/bad-id.j2 +0 -0
  45. {shacl2code-0.0.8 → shacl2code-0.0.10}/tests/data/bad-node-kind.ttl +0 -0
  46. {shacl2code-0.0.8 → shacl2code-0.0.10}/tests/data/bad-pattern-class.ttl +0 -0
  47. {shacl2code-0.0.8 → shacl2code-0.0.10}/tests/data/bad-pattern-integer.ttl +0 -0
  48. {shacl2code-0.0.8 → shacl2code-0.0.10}/tests/data/bad-reference.jsonld +0 -0
  49. {shacl2code-0.0.8 → shacl2code-0.0.10}/tests/data/context-url.j2 +0 -0
  50. {shacl2code-0.0.8 → shacl2code-0.0.10}/tests/data/context.j2 +0 -0
  51. {shacl2code-0.0.8 → shacl2code-0.0.10}/tests/data/missing-range.ttl +0 -0
  52. {shacl2code-0.0.8 → shacl2code-0.0.10}/tests/data/python/links.json +0 -0
  53. {shacl2code-0.0.8 → shacl2code-0.0.10}/tests/data/raw.j2 +0 -0
  54. {shacl2code-0.0.8 → shacl2code-0.0.10}/tests/expect/make_expect.py +0 -0
  55. {shacl2code-0.0.8 → shacl2code-0.0.10}/tests/test_cli.py +0 -0
  56. {shacl2code-0.0.8 → shacl2code-0.0.10}/tests/test_common_jinja.py +0 -0
  57. {shacl2code-0.0.8 → shacl2code-0.0.10}/tests/test_common_prefix.py +0 -0
  58. {shacl2code-0.0.8 → shacl2code-0.0.10}/tests/test_context.py +0 -0
  59. {shacl2code-0.0.8 → shacl2code-0.0.10}/tests/test_model_source.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: shacl2code
3
- Version: 0.0.8
3
+ Version: 0.0.10
4
4
  Summary: Convert SHACL model file to code bindings
5
5
  Project-URL: Homepage, https://github.com/JPEWdev/shacl2code
6
6
  Project-URL: Repository, https://github.com/JPEWdev/shacl2code.git
@@ -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") }}": { "const": "{{ context.compact_vocab(class._id) }}" }
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
- {%- set ns.json_refs = ns.json_refs + ["#/$defs/BlankNodeOrIRI"] %}
79
-
80
- {%- if ns.json_refs | length == 1 %}
81
- "$ref": "{{ ns.json_refs[0] }}",
82
- {%- elif ns.json_refs %}
83
- "oneOf": [
84
- {%- for r in ns.json_refs %}
85
- { "$ref": "{{ r }}" }{% if not loop.last %},{% endif %}
86
- {%- endfor %}
87
- ],
88
- {%- endif %}
89
- "unevaluatedProperties": false
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.class_id %}
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 enums.get(prop.enum_id).values %}
151
- "{{ context.compact_vocab(e._id, prop.path) }}"{% if not loop.last %},{% endif %}
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
- "enum": [
248
- {%- for class in classes %}
249
- "{{ context.compact_vocab(class._id) }}"{% if not loop.last %},{% endif %}
250
- {%- endfor %}
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
- "oneOf": [
280
+ "anyOf": [
258
281
  {%- for class in classes %}
259
282
  { "$ref": "#/$defs/{{ varname(class.clsname) }}" }{% if not loop.last %},{% endif %}
260
283
  {%- endfor %}