Skip to content

Commit

Permalink
Generate JSON Schema using shacl2code
Browse files Browse the repository at this point in the history
Generates the JSON schema for validating JSON-LD documents using
`shacl2code`

Signed-off-by: Joshua Watt <[email protected]>
  • Loading branch information
JPEWdev authored and goneall committed Apr 3, 2024
1 parent c86fbb9 commit 8f171e5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/publish_v3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ jobs:
run: pip install -r spec-parser/requirements.txt
- name: Build model
run: python3 spec-parser/main.py spdx-3-model/model spdx-spec/docs/model
- name: Copy JSON annotations
run: cp spdx-spec/serialization/jsonld/annotations.ttl spdx-spec/docs/model/jsonld-annotations.ttl
- name: Generate JSON schema
run: |
shacl2code generate \
--input spdx-spec/docs/model/ontology.rdf.ttl \
--input spdx-spec/docs/model/jsonld-annotations.ttl \
--context-url spdx-spec/docs/model/context.jsonld https://spdx.org/rdf/3.0.0/spdx-context.jsonld \
jsonschema \
--output spdx-spec/docs/model/schema.json
- name: Set git identity
run: git config user.name ci-bot; git config user.email [email protected]
working-directory: spdx-spec
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ mkdocs==1.5.3
json-schema-for-humans==0.47
mkdocs-pdf-export-plugin==0.5.10
mike==1.1.2
shacl2code==0.0.9
10 changes: 10 additions & 0 deletions serialization/jsonld/annotations.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@base <https://rdf.spdx.org/v3/> .
@prefix sh-to-code: <https://jpewdev.github.io/shacl2code/schema#> .

<Core/Element> ;
sh-to-code:idPropertyName "spdxId"
.

<Extension/Extension> ;
sh-to-code:isExtensible true
.

0 comments on commit 8f171e5

Please sign in to comment.