Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: "JSON-LD Schema" export #143

Open
nissimsan opened this issue May 5, 2021 · 4 comments
Open

Feature request: "JSON-LD Schema" export #143

nissimsan opened this issue May 5, 2021 · 4 comments

Comments

@nissimsan
Copy link

nissimsan commented May 5, 2021

I'm keen to bridge the plugin capabilities to generate schemas which can be used for
https://github.com/w3c-ccg/traceability-vocab
which pulls together JSON schemas, generating Verifiable Credential schemas.

The traceability-vocab is based on a clever approach to include the JSON-LD references into schemas, including it into the $comment element. example:
"$comment": "{\"term\": \"ParcelDelivery\", \"@id\": \"https://schema.org/ParcelDelivery\"}"

This level of precision can't otherwise be included in JSON Schema, and currently gets lost in all our exporting options. So alongside YAML, JSON, JSON Schema, I propose a additional option JSON-LD Schema option, targeted having this included and also with a few tweaks (compared to existing JSON Schema) tailored for fitting in with the traceability-vocab structure:

  1. For all elements (both root element and its properties), include:
    "$comment": "{\"term\": \"ConsignmentItem\", \"@id\": \"https://service.unece.org/trade/uncefact/vocabulary/uncefact/#ConsignmentItem\"}",
    "title": "Consignment Item",
  1. For the root (exported) element, include its URI in the "@id" tag (which is currently just empty):
    "$id": "https://service.unece.org/trade/uncefact/vocabulary/uncefact/#ConsignmentItem",

^^ IGNORE POINT 2, REF KSENIYA'S COMMENT

  1. Change the "description" of the root element, to use the actual description of the element rather than the name of the exported view:
  "description": "An item within a consignment of goods separately identified for transport and customs purposes.",
  1. Skip the "definitions", instead just list the properties directly under the "properties" element. Please see attached examples.

  2. Always include "@context" and "type" elements. These can just be hard coded to:

        "@context": {
            "type": "array"
        },
        "type": {
            "oneOf": [
                {
                    "type": "string"
                },
                {
                    "type": "array"
                }
            ]
        },

Examples.zip

@kshychko
Copy link
Contributor

kshychko commented May 5, 2021

@nissimsan , I'll go through the requirments and get back to you soon.
Just a note, I think for $id we swill hould use resovable URL that allows to fetch the schema itself. It will work for JSON validation libraries that supports network fetching. Please check for details - https://json-schema.org/understanding-json-schema/structuring.html#id
That would mean that the schemas need to be hosted somewhere, but we can add as a configuration option the base url for the schemas export.

@nissimsan
Copy link
Author

@kshychko , thanks for pointing that out. Now I also understand why you have just left "@id" empty previously. You're of course right - please ignore my point 2 above, let's just keep leaving this blank.

@nissimsan
Copy link
Author

@kshychko and @onthebreeze - thoughts on this?

@onthebreeze
Copy link
Contributor

Thought we had this already - but happy to support it - @Kseniya can you add it to your to-do list please

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

No branches or pull requests

3 participants