JPEWdev / shacl2code

Convert SHACL model to code bindings
MIT License
2 stars 4 forks source link

Question: Generating Schema #22

Open goneall opened 3 weeks ago

goneall commented 3 weeks ago

I attempted to use the shal2code to generate a JSON Schema with the latest SPDX 3.0.1 model.

The output did not include any namespaces - is this an expected argument to shacl2code?

The URI's also don't look right - they look like they are missing the /'s.

The schema processor I'm using in Java also complained about missing def's for the classes. e.g.:

WARNING: No match for #/$defs/https_spdxorgrdf301termsCoreElement

Attached is the input and the output.

The command I used was:

 C:\Users\gary\git\shacl2code>shacl2code generate -i c:\Users\gary\Documents\Development\Temp2\spec-parser-output\
spdx-model.json-ld jsonschema -o c:\Users\gary\Documents\Development\Temp2\spec-parser-output\spdx-schema.json

spdx-model.json-ld.txt spdx-schema.json.txt

goneall commented 3 weeks ago

It looks like my input file wasn't proper SHACL - I'll confirm and close if this resolves the issue.

Never mind - looks reasonably valid

goneall commented 2 weeks ago

I did a comparison against the schema file generated from the model repo, and it looks like it is just missing the @context references which is where the namespaces are defined.

I'll do some digging in the code to see if there is a parameter or something I missed.

goneall commented 2 weeks ago

Found the code requiring the context: https://github.com/JPEWdev/shacl2code/blob/ae7ba4e7a31dc302b87d971ca32e253fa0dae786/src/shacl2code/main.py#L104

JPEWdev commented 2 weeks ago

Correct. --context can be used to reference a published context URL, --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)