shacl2code 1.1.0__tar.gz → 1.2.0__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-1.1.0 → shacl2code-1.2.0}/.github/workflows/coverage-generate.yaml +14 -1
- shacl2code-1.2.0/.github/workflows/test.yaml +87 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/.gitignore +5 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/PKG-INFO +128 -7
- {shacl2code-1.1.0 → shacl2code-1.2.0}/README.md +115 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/SECURITY.md +2 -1
- {shacl2code-1.1.0 → shacl2code-1.2.0}/pyproject.toml +16 -6
- shacl2code-1.2.0/scripts/ajv-compile.js +76 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/scripts/format.sh +1 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/__init__.py +1 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/__main__.py +1 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/context.py +1 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/__init__.py +3 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/common.py +2 -2
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/golang.py +1 -1
- shacl2code-1.2.0/src/shacl2code/lang/rust.py +286 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/cpp/objectset.cpp.j2 +1 -2
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/cpp/walk.hpp.j2 +18 -16
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/golang/classes.go.j2 +23 -8
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/golang/decode.go.j2 +7 -7
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/golang/encode.go.j2 +1 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/golang/errorhandler.go.j2 +1 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/golang/errors.go.j2 +4 -3
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/golang/extensible.go.j2 +2 -3
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/golang/linkstate.go.j2 +1 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/golang/listproperty.go.j2 +2 -1
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/golang/optional.go.j2 +1 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/golang/path.go.j2 +1 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/golang/property.go.j2 +1 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/golang/ref.go.j2 +5 -3
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/golang/reflistproperty.go.j2 +1 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/golang/refproperty.go.j2 +1 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/golang/shaclobject.go.j2 +3 -2
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/golang/shaclobjectset.go.j2 +4 -4
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/golang/shacltype.go.j2 +1 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/golang/util.go.j2 +2 -1
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/golang/validator.go.j2 +12 -12
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/python/model.py.j2 +41 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/python/model.pyi.j2 +10 -0
- shacl2code-1.2.0/src/shacl2code/lang/templates/rust/Cargo.toml.j2 +15 -0
- shacl2code-1.2.0/src/shacl2code/lang/templates/rust/lib.rs.j2 +2174 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/main.py +11 -4
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/model.py +145 -3
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/urlcontext.py +1 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/util.py +1 -0
- shacl2code-1.2.0/src/shacl2code/version.py +8 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/tests/data/bad-node-kind.ttl +1 -1
- {shacl2code-1.1.0 → shacl2code-1.2.0}/tests/data/bad-pattern-class.ttl +1 -1
- {shacl2code-1.1.0 → shacl2code-1.2.0}/tests/data/bad-pattern-integer.ttl +1 -1
- {shacl2code-1.1.0 → shacl2code-1.2.0}/tests/data/bad-prop-type.ttl +1 -1
- {shacl2code-1.1.0 → shacl2code-1.2.0}/tests/data/context.j2 +0 -3
- {shacl2code-1.1.0 → shacl2code-1.2.0}/tests/data/missing-range.ttl +1 -1
- {shacl2code-1.1.0 → shacl2code-1.2.0}/tests/data/model/test-context.json +2 -2
- {shacl2code-1.1.0 → shacl2code-1.2.0}/tests/data/model/test.ttl +7 -1
- {shacl2code-1.1.0 → shacl2code-1.2.0}/tests/data/raw.j2 +2 -2
- {shacl2code-1.1.0 → shacl2code-1.2.0}/tests/data/reserved-words.ttl +1 -1
- {shacl2code-1.1.0 → shacl2code-1.2.0}/tests/test_cpp.py +74 -49
- {shacl2code-1.1.0 → shacl2code-1.2.0}/tests/test_golang.py +65 -20
- {shacl2code-1.1.0 → shacl2code-1.2.0}/tests/test_jsonschema.py +31 -3
- shacl2code-1.2.0/tests/test_lint.py +32 -0
- shacl2code-1.2.0/tests/test_model.py +32 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/tests/test_python.py +610 -86
- shacl2code-1.2.0/tests/test_rust.py +842 -0
- shacl2code-1.1.0/.github/workflows/test.yaml +0 -69
- shacl2code-1.1.0/src/shacl2code/version.py +0 -1
- {shacl2code-1.1.0 → shacl2code-1.2.0}/.clang-format +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/.flake8 +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/.github/dependabot.yml +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/.github/workflows/coverage-report.yaml +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/.github/workflows/publish.yaml +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/.github/workflows/scorecard.yml +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/LICENSE +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/cpp.py +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/jinja.py +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/jsonschema.py +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/lang.py +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/python.py +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/sources/cpp/json.hpp +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/cpp/Doxyfile.j2 +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/cpp/Makefile.j2 +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/cpp/api.hpp.j2 +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/cpp/datetime.cpp.j2 +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/cpp/datetime.hpp.j2 +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/cpp/decode.cpp.j2 +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/cpp/decode.hpp.j2 +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/cpp/encode.cpp.j2 +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/cpp/encode.hpp.j2 +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/cpp/errorhandler.cpp.j2 +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/cpp/errorhandler.hpp.j2 +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/cpp/exceptions.hpp.j2 +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/cpp/extensible.cpp.j2 +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/cpp/extensible.hpp.j2 +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/cpp/header.j2 +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/cpp/jsonld-header.j2 +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/cpp/jsonld-source.j2 +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/cpp/link.cpp.j2 +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/cpp/link.hpp.j2 +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/cpp/namedindividual.cpp.j2 +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/cpp/namedindividual.hpp.j2 +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/cpp/object.cpp.j2 +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/cpp/object.hpp.j2 +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/cpp/objectpath.cpp.j2 +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/cpp/objectpath.hpp.j2 +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/cpp/objectset.hpp.j2 +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/cpp/pkgconfig.pc.j2 +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/cpp/prop.hpp.j2 +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/cpp/property.cpp.j2 +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/cpp/property.hpp.j2 +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/cpp/propertyvalue.cpp.j2 +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/cpp/propertyvalue.hpp.j2 +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/cpp/ref.hpp.j2 +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/cpp/refproperty.cpp.j2 +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/cpp/refproperty.hpp.j2 +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/cpp/source.j2 +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/cpp/type.cpp.j2 +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/cpp/type.hpp.j2 +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/cpp/util.cpp.j2 +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/cpp/util.hpp.j2 +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/cpp/validate.j2 +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/jsonschema.j2 +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/python/__init__.py.j2 +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/python/__main__.py.j2 +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/src/shacl2code/lang/templates/python/cmd.py.j2 +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/testfixtures/testfixtures/__init__.py +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/testfixtures/testfixtures/httpserver.py +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/testfixtures/testfixtures/jsonvalidation.py +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/testfixtures/testfixtures/timetests.py +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/tests/conftest.py +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/tests/data/abort.j2 +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/tests/data/bad-id.j2 +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/tests/data/bad-reference.jsonld +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/tests/data/context-url.j2 +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/tests/data/links.json +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/tests/data/python/bad-object-type-inline.json +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/tests/data/python/bad-object-type-ref-after.json +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/tests/data/python/bad-object-type-ref-before.json +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/tests/data/roundtrip.json +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/tests/test_cli.py +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/tests/test_common_jinja.py +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/tests/test_common_prefix.py +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/tests/test_context.py +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/tests/test_convert_version_string.py +0 -0
- {shacl2code-1.1.0 → shacl2code-1.2.0}/tests/test_model_source.py +0 -0
|
@@ -28,9 +28,22 @@ jobs:
|
|
|
28
28
|
uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4.7.1
|
|
29
29
|
with:
|
|
30
30
|
python-version: "3.11"
|
|
31
|
+
- name: Setup Node
|
|
32
|
+
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
|
|
33
|
+
with:
|
|
34
|
+
node-version: 24
|
|
31
35
|
- name: Install dependencies
|
|
32
36
|
run: |
|
|
33
|
-
sudo apt install -y build-essential doxygen graphviz
|
|
37
|
+
sudo apt install -y build-essential cppcheck doxygen graphviz
|
|
38
|
+
npm install -g jsonld-cli
|
|
39
|
+
npm --prefix scripts ci
|
|
40
|
+
- name: Install Go static analysis tools
|
|
41
|
+
run: |
|
|
42
|
+
echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH"
|
|
43
|
+
go install honnef.co/go/tools/cmd/staticcheck@latest
|
|
44
|
+
- name: Install Rust static analysis tools
|
|
45
|
+
run: |
|
|
46
|
+
rustup component add clippy
|
|
34
47
|
- name: Install package
|
|
35
48
|
run: |
|
|
36
49
|
pip install -e .[dev]
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Test shacl2code
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
# Skip changes in docs and other workflows
|
|
6
|
+
paths: &trigger-paths
|
|
7
|
+
- "**"
|
|
8
|
+
- "!**/*.md"
|
|
9
|
+
- "!LICENSE"
|
|
10
|
+
- "!.github/ISSUE_TEMPLATE/**"
|
|
11
|
+
- "!.github/workflows/**"
|
|
12
|
+
- ".github/workflows/test.yaml"
|
|
13
|
+
pull_request:
|
|
14
|
+
paths: *trigger-paths
|
|
15
|
+
workflow_call:
|
|
16
|
+
|
|
17
|
+
jobs:
|
|
18
|
+
build:
|
|
19
|
+
runs-on: ${{ matrix.os }}
|
|
20
|
+
strategy:
|
|
21
|
+
matrix:
|
|
22
|
+
os: [ubuntu-latest]
|
|
23
|
+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
|
|
24
|
+
include:
|
|
25
|
+
- os: macos-latest
|
|
26
|
+
python-version: "3.10"
|
|
27
|
+
steps:
|
|
28
|
+
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
|
29
|
+
- name: Setup Python ${{ matrix.python-version }}
|
|
30
|
+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
|
|
31
|
+
with:
|
|
32
|
+
python-version: ${{ matrix.python-version }}
|
|
33
|
+
- name: Setup Node
|
|
34
|
+
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
|
|
35
|
+
with:
|
|
36
|
+
node-version: 24
|
|
37
|
+
- name: Install dependencies
|
|
38
|
+
run: |
|
|
39
|
+
python -m pip install --upgrade pip
|
|
40
|
+
pip install build
|
|
41
|
+
npm install -g jsonld-cli
|
|
42
|
+
npm --prefix scripts ci
|
|
43
|
+
- name: Install Linux packages
|
|
44
|
+
if: runner.os == 'Linux'
|
|
45
|
+
run: |
|
|
46
|
+
sudo apt update
|
|
47
|
+
sudo apt install -y build-essential cppcheck doxygen graphviz
|
|
48
|
+
- name: Install macOS packages
|
|
49
|
+
if: runner.os == 'macOS'
|
|
50
|
+
run: |
|
|
51
|
+
brew update
|
|
52
|
+
brew install cppcheck doxygen gcc go graphviz
|
|
53
|
+
- name: Install Go static analysis tools
|
|
54
|
+
run: |
|
|
55
|
+
echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH"
|
|
56
|
+
go install honnef.co/go/tools/cmd/staticcheck@latest
|
|
57
|
+
- name: Install Rust static analysis tools
|
|
58
|
+
run: |
|
|
59
|
+
rustup component add clippy
|
|
60
|
+
- name: Build package
|
|
61
|
+
run: |
|
|
62
|
+
python -m build
|
|
63
|
+
- name: Install package
|
|
64
|
+
run: |
|
|
65
|
+
pip install -e .[dev]
|
|
66
|
+
- name: Run tests
|
|
67
|
+
run: |
|
|
68
|
+
pytest -v
|
|
69
|
+
lint:
|
|
70
|
+
runs-on: ubuntu-latest
|
|
71
|
+
steps:
|
|
72
|
+
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
|
73
|
+
- name: Setup Python
|
|
74
|
+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
|
|
75
|
+
with:
|
|
76
|
+
# Black in this Python version must support all target-versions listed in pyproject.toml
|
|
77
|
+
python-version: "3.14"
|
|
78
|
+
- uses: psf/black@87928e6d6761a4a6d22250e1fee5601b3998086e # 26.5.1
|
|
79
|
+
- uses: py-actions/flake8@84ec6726560b6d5bd68f2a5bed83d62b52bb50ba # v2.3.0
|
|
80
|
+
- name: Install dependencies
|
|
81
|
+
run: |
|
|
82
|
+
python -m pip install --upgrade pip
|
|
83
|
+
pip install clang-format
|
|
84
|
+
- name: Check code formatting
|
|
85
|
+
run: |
|
|
86
|
+
./scripts/format.sh
|
|
87
|
+
git diff --exit-code
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: shacl2code
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.2.0
|
|
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
|
|
@@ -10,33 +10,40 @@ License-Expression: MIT
|
|
|
10
10
|
License-File: LICENSE
|
|
11
11
|
Classifier: Development Status :: 4 - Beta
|
|
12
12
|
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Programming Language :: C++
|
|
14
|
+
Classifier: Programming Language :: Go
|
|
13
15
|
Classifier: Programming Language :: Python :: 3
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
15
16
|
Classifier: Programming Language :: Python :: 3.9
|
|
16
17
|
Classifier: Programming Language :: Python :: 3.10
|
|
17
18
|
Classifier: Programming Language :: Python :: 3.11
|
|
18
19
|
Classifier: Programming Language :: Python :: 3.12
|
|
19
20
|
Classifier: Programming Language :: Python :: 3.13
|
|
20
21
|
Classifier: Programming Language :: Python :: 3.14
|
|
22
|
+
Classifier: Programming Language :: Rust
|
|
23
|
+
Classifier: Topic :: File Formats :: JSON :: JSON Schema
|
|
21
24
|
Classifier: Topic :: Software Development :: Build Tools
|
|
22
|
-
|
|
25
|
+
Classifier: Topic :: Software Development :: Code Generators
|
|
26
|
+
Requires-Python: >=3.9
|
|
23
27
|
Requires-Dist: jinja2>=3.1.2
|
|
24
28
|
Requires-Dist: rdflib>=7.0.0
|
|
25
29
|
Provides-Extra: dev
|
|
30
|
+
Requires-Dist: black>=25.11.0; extra == 'dev'
|
|
26
31
|
Requires-Dist: flake8-import-order>=0.19.2; extra == 'dev'
|
|
27
32
|
Requires-Dist: flake8>=7.0.0; extra == 'dev'
|
|
28
|
-
Requires-Dist: jsonschema>=4.
|
|
29
|
-
Requires-Dist: mypy>=1.
|
|
33
|
+
Requires-Dist: jsonschema>=4.25.1; extra == 'dev'
|
|
34
|
+
Requires-Dist: mypy>=1.19.1; extra == 'dev'
|
|
30
35
|
Requires-Dist: pyrefly>=0.55.0; extra == 'dev'
|
|
31
36
|
Requires-Dist: pyright>=1.1.403; extra == 'dev'
|
|
32
|
-
Requires-Dist: pyshacl
|
|
37
|
+
Requires-Dist: pyshacl!=0.40.0,>=0.25.0; extra == 'dev'
|
|
33
38
|
Requires-Dist: pytest-cov>=4.1; extra == 'dev'
|
|
39
|
+
Requires-Dist: pytest-xdist>=3.5; extra == 'dev'
|
|
34
40
|
Requires-Dist: pytest>=7.4; extra == 'dev'
|
|
35
|
-
Requires-Dist: types-jsonschema>=4.
|
|
41
|
+
Requires-Dist: types-jsonschema>=4.25.1; extra == 'dev'
|
|
36
42
|
Description-Content-Type: text/markdown
|
|
37
43
|
|
|
38
44
|
# Convert SHACL Model to code bindings
|
|
39
45
|
|
|
46
|
+
[](https://pypi.org/project/shacl2code/)
|
|
40
47
|
[](https://www.bestpractices.dev/projects/9999)
|
|
41
48
|
[](https://scorecard.dev/viewer/?uri=github.com/JPEWdev/shacl2code)
|
|
42
49
|
[](https://htmlpreview.github.io/?https://github.com/JPEWdev/shacl2code/blob/python-coverage-comment-action-data/htmlcov/index.html)
|
|
@@ -83,6 +90,59 @@ The available language bindings can be viewed by running:
|
|
|
83
90
|
shacl2code list
|
|
84
91
|
```
|
|
85
92
|
|
|
93
|
+
### Using JSON-LD contexts
|
|
94
|
+
|
|
95
|
+
When using JSON-LD contexts, the context document shall align with the model.
|
|
96
|
+
|
|
97
|
+
During model development, there may be cases where the context URL is known
|
|
98
|
+
but not yet live or resolvable. In these situations, you can use the
|
|
99
|
+
`--context-url` option to map your local context file to its future public home.
|
|
100
|
+
|
|
101
|
+
The `--context-url` option accepts two arguments:
|
|
102
|
+
|
|
103
|
+
1. `CONTEXT_LOCATION`: The actual path to the local or temporary file
|
|
104
|
+
containing the context.
|
|
105
|
+
2. `CONTEXT_URL`: The official public URL. While temporarily unresolvable
|
|
106
|
+
during development, this is the URL that production JSON-LD processors will
|
|
107
|
+
eventually rely on, so it must be recorded inside the generated JSON Schema.
|
|
108
|
+
|
|
109
|
+
### Generating the JSON Schema file
|
|
110
|
+
|
|
111
|
+
`shacl2code` can generate a JSON Schema directly from a model.
|
|
112
|
+
|
|
113
|
+
To view all options specific to JSON Schema generation, run:
|
|
114
|
+
|
|
115
|
+
```shell
|
|
116
|
+
shacl2code generate jsonschema -h
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
#### Example 1: Generating from publicly available URLs
|
|
120
|
+
|
|
121
|
+
To generate a schema using remote, publicly accessible assets
|
|
122
|
+
(such as SPDX 3.0.1):
|
|
123
|
+
|
|
124
|
+
```shell
|
|
125
|
+
shacl2code generate \
|
|
126
|
+
--input https://spdx.org/rdf/3.0.1/spdx-model.ttl \
|
|
127
|
+
--input https://spdx.org/rdf/3.0.1/spdx-json-serialize-annotations.ttl \
|
|
128
|
+
--context https://spdx.org/rdf/3.0.1/spdx-context.jsonld \
|
|
129
|
+
jsonschema \
|
|
130
|
+
--output spdx-json-schema.json
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
#### Example 2: Generating with a local context document
|
|
134
|
+
|
|
135
|
+
To generate a schema using a local context file while embedding its future
|
|
136
|
+
public URL:
|
|
137
|
+
|
|
138
|
+
```shell
|
|
139
|
+
shacl2code generate \
|
|
140
|
+
--input model-draft.ttl \
|
|
141
|
+
--context-url context-draft.jsonld https://example.com/context.jsonld \
|
|
142
|
+
jsonschema \
|
|
143
|
+
--output schema.json
|
|
144
|
+
```
|
|
145
|
+
|
|
86
146
|
## Developing
|
|
87
147
|
|
|
88
148
|
Developing on `shacl2code` is best done using a virtual environment. You can
|
|
@@ -250,5 +310,66 @@ classes are automatically concrete unless they indicate otherwise.
|
|
|
250
310
|
It is also possible to define a class as abstract by declaring it to be of
|
|
251
311
|
type: `http://spdx.invalid./AbstractClass`, but this is not preferred.
|
|
252
312
|
|
|
313
|
+
### Pre-Release models
|
|
314
|
+
|
|
315
|
+
`shacl2code` can detect if an ontology is a "pre-release" version (still
|
|
316
|
+
subject to breaking changes). For language bindings that support it (such as
|
|
317
|
+
Python), importing a pre-release ontology binding will emit a warning
|
|
318
|
+
(e.g. `FutureWarning`).
|
|
319
|
+
|
|
320
|
+
Pre-release status can be specified explicitly via command-line options,
|
|
321
|
+
or inferred automatically from various ontology annotations. For example,
|
|
322
|
+
|
|
323
|
+
```ttl
|
|
324
|
+
<http://example.org/my-ontology> a ow:Ontology ;
|
|
325
|
+
sh-to-code:isPreRelease true
|
|
326
|
+
.
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
Note that the IRI of the ontology must be the prefix of all IRIs that belong to
|
|
330
|
+
that ontology.
|
|
331
|
+
|
|
332
|
+
In the event of conflicting annotations, `shacl2code` evaluates pre-release
|
|
333
|
+
status using the following order of precedence (1 = the highest priority):
|
|
334
|
+
|
|
335
|
+
1. **`--pre-release` or `--no-pre-release` command-line options**:
|
|
336
|
+
Explicitly marks the generated bindings as pre-release or stable,
|
|
337
|
+
overriding any annotations in the input ontology.
|
|
338
|
+
2. **`sh-to-code:isPreRelease`**:
|
|
339
|
+
The `shacl2code` custom boolean annotation
|
|
340
|
+
(`sh-to-code:isPreRelease true` or `false`).
|
|
341
|
+
3. **`adms:status` (EU SEMIC Vocabulary)**:
|
|
342
|
+
If the status is
|
|
343
|
+
`<http://publications.europa.eu/resource/authority/dataset-status/DEVELOP>`,
|
|
344
|
+
it is considered a pre-release.
|
|
345
|
+
Other values in the dataset-status vocabulary space (e.g. `COMPLETED`)
|
|
346
|
+
indicate a stable release.
|
|
347
|
+
4. **`adms:status` (Original ADMS Vocabulary)**:
|
|
348
|
+
If the status is `<http://purl.org/adms/status/UnderDevelopment>`,
|
|
349
|
+
it is considered a pre-release.
|
|
350
|
+
Other values in the ADMS status namespace (e.g. `Completed`)
|
|
351
|
+
indicate a stable release.
|
|
352
|
+
5. **`bibo:status` (Bibliographic Ontology)**:
|
|
353
|
+
If set to `<http://purl.org/ontology/bibo/status/draft>`, it is
|
|
354
|
+
considered a pre-release.
|
|
355
|
+
Other values in the BIBO status namespace (e.g. `published`, `legal`)
|
|
356
|
+
indicate a stable release.
|
|
357
|
+
6. **`schema:creativeWorkStatus`**:
|
|
358
|
+
If set to `"Draft"` or `"Incomplete"`, it is considered a pre-release.
|
|
359
|
+
Other values (e.g. `"Published"`) indicate a stable release.
|
|
360
|
+
7. **`vs:term_status`**:
|
|
361
|
+
If set to `"unstable"` or `"testing"`, it is considered a pre-release.
|
|
362
|
+
Other values (e.g. `"stable"`) indicate a stable release.
|
|
363
|
+
8. **`owl:versionInfo` (pre-release extension)**:
|
|
364
|
+
If the version string contains a pre-release extension suffix
|
|
365
|
+
(e.g., `-alpha`, `-beta`, `-dev`, `-rc`, `-SNAPSHOT`, `.alpha`, etc.).
|
|
366
|
+
9. **`owl:versionInfo` (major version zero)**:
|
|
367
|
+
If the version string corresponds to a major version zero in
|
|
368
|
+
[Semantic Versioning][semver] (e.g., `0.7.1`).
|
|
369
|
+
10. **Default Fallback**:
|
|
370
|
+
If none of the above are present, the ontology is assumed to be a stable
|
|
371
|
+
release.
|
|
372
|
+
|
|
253
373
|
[pytest]: https://www.pytest.org
|
|
254
374
|
[pytest-cov]: https://pytest-cov.readthedocs.io/en/latest/
|
|
375
|
+
[semver]: https://semver.org/
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# Convert SHACL Model to code bindings
|
|
2
2
|
|
|
3
|
+
[](https://pypi.org/project/shacl2code/)
|
|
3
4
|
[](https://www.bestpractices.dev/projects/9999)
|
|
4
5
|
[](https://scorecard.dev/viewer/?uri=github.com/JPEWdev/shacl2code)
|
|
5
6
|
[](https://htmlpreview.github.io/?https://github.com/JPEWdev/shacl2code/blob/python-coverage-comment-action-data/htmlcov/index.html)
|
|
@@ -46,6 +47,59 @@ The available language bindings can be viewed by running:
|
|
|
46
47
|
shacl2code list
|
|
47
48
|
```
|
|
48
49
|
|
|
50
|
+
### Using JSON-LD contexts
|
|
51
|
+
|
|
52
|
+
When using JSON-LD contexts, the context document shall align with the model.
|
|
53
|
+
|
|
54
|
+
During model development, there may be cases where the context URL is known
|
|
55
|
+
but not yet live or resolvable. In these situations, you can use the
|
|
56
|
+
`--context-url` option to map your local context file to its future public home.
|
|
57
|
+
|
|
58
|
+
The `--context-url` option accepts two arguments:
|
|
59
|
+
|
|
60
|
+
1. `CONTEXT_LOCATION`: The actual path to the local or temporary file
|
|
61
|
+
containing the context.
|
|
62
|
+
2. `CONTEXT_URL`: The official public URL. While temporarily unresolvable
|
|
63
|
+
during development, this is the URL that production JSON-LD processors will
|
|
64
|
+
eventually rely on, so it must be recorded inside the generated JSON Schema.
|
|
65
|
+
|
|
66
|
+
### Generating the JSON Schema file
|
|
67
|
+
|
|
68
|
+
`shacl2code` can generate a JSON Schema directly from a model.
|
|
69
|
+
|
|
70
|
+
To view all options specific to JSON Schema generation, run:
|
|
71
|
+
|
|
72
|
+
```shell
|
|
73
|
+
shacl2code generate jsonschema -h
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
#### Example 1: Generating from publicly available URLs
|
|
77
|
+
|
|
78
|
+
To generate a schema using remote, publicly accessible assets
|
|
79
|
+
(such as SPDX 3.0.1):
|
|
80
|
+
|
|
81
|
+
```shell
|
|
82
|
+
shacl2code generate \
|
|
83
|
+
--input https://spdx.org/rdf/3.0.1/spdx-model.ttl \
|
|
84
|
+
--input https://spdx.org/rdf/3.0.1/spdx-json-serialize-annotations.ttl \
|
|
85
|
+
--context https://spdx.org/rdf/3.0.1/spdx-context.jsonld \
|
|
86
|
+
jsonschema \
|
|
87
|
+
--output spdx-json-schema.json
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
#### Example 2: Generating with a local context document
|
|
91
|
+
|
|
92
|
+
To generate a schema using a local context file while embedding its future
|
|
93
|
+
public URL:
|
|
94
|
+
|
|
95
|
+
```shell
|
|
96
|
+
shacl2code generate \
|
|
97
|
+
--input model-draft.ttl \
|
|
98
|
+
--context-url context-draft.jsonld https://example.com/context.jsonld \
|
|
99
|
+
jsonschema \
|
|
100
|
+
--output schema.json
|
|
101
|
+
```
|
|
102
|
+
|
|
49
103
|
## Developing
|
|
50
104
|
|
|
51
105
|
Developing on `shacl2code` is best done using a virtual environment. You can
|
|
@@ -213,5 +267,66 @@ classes are automatically concrete unless they indicate otherwise.
|
|
|
213
267
|
It is also possible to define a class as abstract by declaring it to be of
|
|
214
268
|
type: `http://spdx.invalid./AbstractClass`, but this is not preferred.
|
|
215
269
|
|
|
270
|
+
### Pre-Release models
|
|
271
|
+
|
|
272
|
+
`shacl2code` can detect if an ontology is a "pre-release" version (still
|
|
273
|
+
subject to breaking changes). For language bindings that support it (such as
|
|
274
|
+
Python), importing a pre-release ontology binding will emit a warning
|
|
275
|
+
(e.g. `FutureWarning`).
|
|
276
|
+
|
|
277
|
+
Pre-release status can be specified explicitly via command-line options,
|
|
278
|
+
or inferred automatically from various ontology annotations. For example,
|
|
279
|
+
|
|
280
|
+
```ttl
|
|
281
|
+
<http://example.org/my-ontology> a ow:Ontology ;
|
|
282
|
+
sh-to-code:isPreRelease true
|
|
283
|
+
.
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
Note that the IRI of the ontology must be the prefix of all IRIs that belong to
|
|
287
|
+
that ontology.
|
|
288
|
+
|
|
289
|
+
In the event of conflicting annotations, `shacl2code` evaluates pre-release
|
|
290
|
+
status using the following order of precedence (1 = the highest priority):
|
|
291
|
+
|
|
292
|
+
1. **`--pre-release` or `--no-pre-release` command-line options**:
|
|
293
|
+
Explicitly marks the generated bindings as pre-release or stable,
|
|
294
|
+
overriding any annotations in the input ontology.
|
|
295
|
+
2. **`sh-to-code:isPreRelease`**:
|
|
296
|
+
The `shacl2code` custom boolean annotation
|
|
297
|
+
(`sh-to-code:isPreRelease true` or `false`).
|
|
298
|
+
3. **`adms:status` (EU SEMIC Vocabulary)**:
|
|
299
|
+
If the status is
|
|
300
|
+
`<http://publications.europa.eu/resource/authority/dataset-status/DEVELOP>`,
|
|
301
|
+
it is considered a pre-release.
|
|
302
|
+
Other values in the dataset-status vocabulary space (e.g. `COMPLETED`)
|
|
303
|
+
indicate a stable release.
|
|
304
|
+
4. **`adms:status` (Original ADMS Vocabulary)**:
|
|
305
|
+
If the status is `<http://purl.org/adms/status/UnderDevelopment>`,
|
|
306
|
+
it is considered a pre-release.
|
|
307
|
+
Other values in the ADMS status namespace (e.g. `Completed`)
|
|
308
|
+
indicate a stable release.
|
|
309
|
+
5. **`bibo:status` (Bibliographic Ontology)**:
|
|
310
|
+
If set to `<http://purl.org/ontology/bibo/status/draft>`, it is
|
|
311
|
+
considered a pre-release.
|
|
312
|
+
Other values in the BIBO status namespace (e.g. `published`, `legal`)
|
|
313
|
+
indicate a stable release.
|
|
314
|
+
6. **`schema:creativeWorkStatus`**:
|
|
315
|
+
If set to `"Draft"` or `"Incomplete"`, it is considered a pre-release.
|
|
316
|
+
Other values (e.g. `"Published"`) indicate a stable release.
|
|
317
|
+
7. **`vs:term_status`**:
|
|
318
|
+
If set to `"unstable"` or `"testing"`, it is considered a pre-release.
|
|
319
|
+
Other values (e.g. `"stable"`) indicate a stable release.
|
|
320
|
+
8. **`owl:versionInfo` (pre-release extension)**:
|
|
321
|
+
If the version string contains a pre-release extension suffix
|
|
322
|
+
(e.g., `-alpha`, `-beta`, `-dev`, `-rc`, `-SNAPSHOT`, `.alpha`, etc.).
|
|
323
|
+
9. **`owl:versionInfo` (major version zero)**:
|
|
324
|
+
If the version string corresponds to a major version zero in
|
|
325
|
+
[Semantic Versioning][semver] (e.g., `0.7.1`).
|
|
326
|
+
10. **Default Fallback**:
|
|
327
|
+
If none of the above are present, the ontology is assumed to be a stable
|
|
328
|
+
release.
|
|
329
|
+
|
|
216
330
|
[pytest]: https://www.pytest.org
|
|
217
331
|
[pytest-cov]: https://pytest-cov.readthedocs.io/en/latest/
|
|
332
|
+
[semver]: https://semver.org/
|
|
@@ -6,7 +6,7 @@ dependencies = [
|
|
|
6
6
|
"jinja2 >= 3.1.2",
|
|
7
7
|
"rdflib >= 7.0.0",
|
|
8
8
|
]
|
|
9
|
-
requires-python = ">= 3.
|
|
9
|
+
requires-python = ">= 3.9"
|
|
10
10
|
authors = [
|
|
11
11
|
{name = "Joshua Watt", email = "JPEWhacker@gmail.com"},
|
|
12
12
|
]
|
|
@@ -15,29 +15,35 @@ classifiers = [
|
|
|
15
15
|
"Development Status :: 4 - Beta",
|
|
16
16
|
"Intended Audience :: Developers",
|
|
17
17
|
"Topic :: Software Development :: Build Tools",
|
|
18
|
+
"Topic :: Software Development :: Code Generators",
|
|
19
|
+
"Programming Language :: C++",
|
|
20
|
+
"Programming Language :: Go",
|
|
18
21
|
"Programming Language :: Python :: 3",
|
|
19
|
-
"Programming Language :: Python :: 3.8",
|
|
20
22
|
"Programming Language :: Python :: 3.9",
|
|
21
23
|
"Programming Language :: Python :: 3.10",
|
|
22
24
|
"Programming Language :: Python :: 3.11",
|
|
23
25
|
"Programming Language :: Python :: 3.12",
|
|
24
26
|
"Programming Language :: Python :: 3.13",
|
|
25
27
|
"Programming Language :: Python :: 3.14",
|
|
28
|
+
"Programming Language :: Rust",
|
|
29
|
+
"Topic :: File Formats :: JSON :: JSON Schema",
|
|
26
30
|
]
|
|
27
31
|
license = "MIT"
|
|
28
32
|
|
|
29
33
|
[project.optional-dependencies]
|
|
30
34
|
dev = [
|
|
35
|
+
"black >= 25.11.0",
|
|
31
36
|
"flake8 >= 7.0.0",
|
|
32
37
|
"flake8-import-order >= 0.19.2",
|
|
33
|
-
"jsonschema >= 4.
|
|
34
|
-
"mypy >= 1.
|
|
38
|
+
"jsonschema >= 4.25.1", # latest version for Python 3.9 is 4.25.x
|
|
39
|
+
"mypy >= 1.19.1", # latest version for Python 3.9 is 1.19.x
|
|
35
40
|
"pyrefly >= 0.55.0",
|
|
36
41
|
"pyright >= 1.1.403",
|
|
37
|
-
"pyshacl >= 0.25.0",
|
|
42
|
+
"pyshacl >= 0.25.0, != 0.40.0", # 0.40.0 uses `str | X` at runtime, breaks Python < 3.10
|
|
38
43
|
"pytest >= 7.4",
|
|
39
44
|
"pytest-cov >= 4.1",
|
|
40
|
-
"
|
|
45
|
+
"pytest-xdist >= 3.5",
|
|
46
|
+
"types-jsonschema >= 4.25.1",
|
|
41
47
|
]
|
|
42
48
|
|
|
43
49
|
[project.urls]
|
|
@@ -75,6 +81,9 @@ warn_redundant_casts = true
|
|
|
75
81
|
addopts = [
|
|
76
82
|
"--import-mode=importlib",
|
|
77
83
|
"--cov=shacl2code",
|
|
84
|
+
"-n",
|
|
85
|
+
"auto",
|
|
86
|
+
"--dist=loadfile",
|
|
78
87
|
]
|
|
79
88
|
# Suppress 3rd-party warnings to reduce log noise. Remove after libraries get updated.
|
|
80
89
|
filterwarnings = [
|
|
@@ -91,4 +100,5 @@ relative_files = true
|
|
|
91
100
|
patch = ["subprocess"]
|
|
92
101
|
|
|
93
102
|
[tool.black]
|
|
103
|
+
target-version = ["py39", "py310", "py311", "py312", "py313", "py314"]
|
|
94
104
|
include = '(\.pyi?(\.j2)?$)|(main\.py\.j2$)'
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// SPDX-FileContributor: Arthit Suriyawongkul
|
|
3
|
+
// SPDX-FileCopyrightText: 2026 Joshua Watt
|
|
4
|
+
// SPDX-FileType: SOURCE
|
|
5
|
+
// SPDX-License-Identifier: MIT
|
|
6
|
+
//
|
|
7
|
+
// Validate a JSON Schema file against its meta-schema using ajv v8.
|
|
8
|
+
// Usage: ajv-compile.js <schema.json> [draft-version]
|
|
9
|
+
// draft-version: 2020-12 or 2019-09 (default: inferred from "$schema")
|
|
10
|
+
const fs = require("fs");
|
|
11
|
+
|
|
12
|
+
const schemaFile = process.argv[2];
|
|
13
|
+
const draftArg = process.argv[3];
|
|
14
|
+
|
|
15
|
+
if (!schemaFile) {
|
|
16
|
+
console.error("Usage: ajv-compile.js <schema.json> [draft-version]");
|
|
17
|
+
process.exit(2);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const draftMap = {
|
|
21
|
+
"2020-12": "ajv/dist/2020",
|
|
22
|
+
"2019-09": "ajv/dist/2019",
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const schemaUriMap = {
|
|
26
|
+
"https://json-schema.org/draft/2020-12/schema": "2020-12",
|
|
27
|
+
"http://json-schema.org/draft/2020-12/schema": "2020-12",
|
|
28
|
+
"https://json-schema.org/draft/2019-09/schema": "2019-09",
|
|
29
|
+
"http://json-schema.org/draft/2019-09/schema": "2019-09",
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
let schema;
|
|
33
|
+
try {
|
|
34
|
+
schema = JSON.parse(fs.readFileSync(schemaFile, "utf8"));
|
|
35
|
+
} catch (e) {
|
|
36
|
+
console.error(`Failed to read/parse "${schemaFile}": ${e.message}`);
|
|
37
|
+
process.exit(2);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
let draft = draftArg;
|
|
41
|
+
if (!draft) {
|
|
42
|
+
draft = schemaUriMap[schema.$schema?.replace(/#$/, "")];
|
|
43
|
+
if (!draft) {
|
|
44
|
+
console.error(
|
|
45
|
+
`Unable to infer draft version from "$schema": ${schema.$schema}. ` +
|
|
46
|
+
"Pass the draft version explicitly as the second argument.",
|
|
47
|
+
);
|
|
48
|
+
process.exit(2);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const ajvModule = draftMap[draft];
|
|
53
|
+
if (!ajvModule) {
|
|
54
|
+
console.error(`Unsupported draft version: ${draft}. Supported: ${Object.keys(draftMap).join(", ")}`);
|
|
55
|
+
process.exit(2);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
let Ajv;
|
|
59
|
+
try {
|
|
60
|
+
Ajv = require(ajvModule);
|
|
61
|
+
} catch (e) {
|
|
62
|
+
console.error(
|
|
63
|
+
`Failed to load "${ajvModule}": ${e.message}\n` +
|
|
64
|
+
'Run "npm --prefix scripts install" to install dependencies.',
|
|
65
|
+
);
|
|
66
|
+
process.exit(2);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const ajv = new Ajv();
|
|
70
|
+
try {
|
|
71
|
+
ajv.compile(schema);
|
|
72
|
+
console.log("schema is valid");
|
|
73
|
+
} catch (e) {
|
|
74
|
+
console.error("schema is invalid:", e.message);
|
|
75
|
+
process.exit(1);
|
|
76
|
+
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
# Copyright (c) 2024 Joshua Watt
|
|
3
3
|
#
|
|
4
4
|
# SPDX-License-Identifier: MIT
|
|
5
|
+
"""Language binding renderers for shacl2code"""
|
|
5
6
|
|
|
6
7
|
# All renderers must be imported here to be registered
|
|
7
8
|
from .cpp import CppRender
|
|
@@ -10,6 +11,7 @@ from .jinja import JinjaRender
|
|
|
10
11
|
from .jsonschema import JsonSchemaRender
|
|
11
12
|
from .lang import LANGUAGES
|
|
12
13
|
from .python import PythonRender
|
|
14
|
+
from .rust import RustRender
|
|
13
15
|
|
|
14
16
|
__all__ = [
|
|
15
17
|
"LANGUAGES",
|
|
@@ -18,4 +20,5 @@ __all__ = [
|
|
|
18
20
|
"JinjaRender",
|
|
19
21
|
"JsonSchemaRender",
|
|
20
22
|
"PythonRender",
|
|
23
|
+
"RustRender",
|
|
21
24
|
]
|
|
@@ -119,17 +119,17 @@ class JinjaTemplateRender(object):
|
|
|
119
119
|
return ni
|
|
120
120
|
|
|
121
121
|
classes = ObjectList(model.classes)
|
|
122
|
+
ontologies = ObjectList(model.ontologies)
|
|
122
123
|
concrete_classes = ObjectList(
|
|
123
124
|
list(c for c in model.classes if not c.is_abstract)
|
|
124
125
|
)
|
|
125
126
|
abstract_classes = ObjectList(list(c for c in model.classes if c.is_abstract))
|
|
126
|
-
enums = ObjectList(model.enums)
|
|
127
127
|
|
|
128
128
|
render_args = {
|
|
129
129
|
"classes": classes,
|
|
130
|
+
"ontologies": ontologies,
|
|
130
131
|
"concrete_classes": concrete_classes,
|
|
131
132
|
"abstract_classes": abstract_classes,
|
|
132
|
-
"enums": enums,
|
|
133
133
|
"context": model.context,
|
|
134
134
|
**self.get_additional_render_args(model),
|
|
135
135
|
}
|