Skip to content

Conversation

@goneall
Copy link

@goneall goneall commented Aug 29, 2024

Add the syntax for generating the schema file to the README.md file.

Closes #22

@goneall
Copy link
Author

goneall commented Aug 30, 2024

This time I tested the command line. @JPEWdev Feel free to replace this with a better description, just thought it would be helpful to document this special case since it took me some digging to figure it out.


`shacl2code` can generate a JSON schema with the following command:
```shell
shacl2code generate -i spdx-model.json-ld -u spdx-context.jsonld https://spdx.org/rdf/3.0.1/spdx-context.jsonld jsonschema -o json-schema-3.0.1.json
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JPEWdev JPEWdev force-pushed the main branch 2 times, most recently from 044f11f to 5fadc0d Compare February 6, 2025 15:34
@bact
Copy link
Collaborator

bact commented Apr 10, 2025

Since shacl2code can be used in non-SPDX context, we may like to have the documentation be more generic, what about:


Generating a JSON Schema File

shacl2code can generate a JSON schema using the following command structure:

shacl2code generate -i <input_model> -x <context_url> jsonschema -o <output_schema>

Note that -u or --context-url can be used to reference a local context file as if it were at the specified URL (useful for locally developing before the context is published):

shacl2code generate -i <input_model> -u <context_file> <context_url> jsonschema -o <output_schema>

For instance, to generate the SPDX 3.0.1 JSON schema, you would use:

shacl2code generate \
            -i spdx-model.ttl \
            -i annotations.ttl \
            -u spdx-context.jsonld https://spdx.org/rdf/3.0.1/spdx-context.jsonld \
            jsonschema \
            -o schema.json

Note that the context file (spdx-context.jsonld in this example) should align with the model described in the input files (spdx-model.ttl and annotations.ttl).

For a complete list of available options, run shacl2code generate -h.


This will make the doc more generic and at the same time retain the example that is useful for SPDX users.

The above text is based on @goneall text in this PR and from @JPEWdev comment here #22 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Question: Generating Schema

2 participants