Générer un JSON schema

This utility generates a JSON Schema document from a SHACL specification. Detailed documentation is available below.

  Shapes

Annuler Sélectionner un fichier Modifier
Vous pouvez sélectionnez plusieurs fichiers. Extensions supportées : .rdf, .ttl, .n3, .trig ou .zip. Excel est également supporté (voir SHACL in Excel).
URL d'un fichier RDF valide - supporte les mêmes extensions que l'upload ci-dessus.
Syntaxes supportées : Turtle, RDF/XML, JSON-LD, TriG, TriX, N-Quads. Privilégiez Turtle.

  Options

Le contexte JSON-LD utilisé par le JSON pour lequel le JSON schema est généré. Exactement comme la valeur qui serait mise dans le champ "@context" du JSON-LD (sans "@context" lui-même).
URI de la Node Shape qui sera utilisé comme point d'entrée pour la génération du schema JSON. Sélectionnez d'abord votre fichier SHACL ci-dessus, puis cliquez sur la liste déroulante pour charger les URI des NodeShapes.
Cette option est utile lorsque la spécification SHACL contient des valeurs ou des listes de valeurs qui peuvent évoluer. En n'incluant pas ces valeurs dans le schema généré, celles-ci peuvent évoluer sans impacter les utilisateurs du schema JSON.
Cette propriété est utile lorsque le schema peut évoluer et que des nouvelles propriétés peuvent être ajoutées. Les nouvelles entités avec ces nouvelles propriétés ne généreront pas d'erreur pour les utilisateurs des anciennes version du schema.

Documentation

JSON Schema document generation algorithm

The algorithm follow these steps to generate the JSON Schema:

Constant declarations
  • A declaration is always added for @context since we are targeting JSON-LD
  • schema version is always set to https://json-schema.org/draft/2020-12/schema
  • a container_language declaration is always added with a patternProperty declaration with properties being language codes to deal with "@container": "language" properties.
Schema header
  • title is populated from an owl:Ontology dct:title or rdfs:label
  • version is populated from an owl:Ontology owl:versionInfo
  • description is populated from an owl:Ontology dct:description
Node shapes conversion

Each node shape with at least one non-deactivated property shape is turned into an object schema in the $defs section of the schema, with the URI local name as the name of the schema. Node shapes with no non-deactivated property shapes are turned into string schemas being simple iri-reference.

  • title is populated from the node shape rdfs:label
  • description is populated from the node shape rdfs:comment
  • There is always a required id property
  • If node shape is closed, then additionalProperties is set to false
  • Then each property shape is processed as described below
Property shapes conversion

Non-deactivated property shapes are processed this way:

  • The corresponding JSON key is read from shacl-play:shortName annotation, otherwise the local name of the property in sh:path is used as the JSON key
  • title is populated from the property shape sh:name
  • description is populated from the property shape sh:description
  • The property shape is mapped to a schema this way:
    • If the property shape has an sh:hasValue, a const schema is created with the value
    • If the property shape has an sh:in, an enum schema is created with the list of possible values
    • If the property shape has an sh:node, then :
      • If the property shape is annotated with shacl-play:embed shacl-play:EmbedNever, then a string schema with format iri-reference is generated
      • Otherwise, create a $ref schema with a reference to one of the schemas in the #/$defs section
      • If there is no sh:maxCount or a sh:maxCount that is > 1, then wrap the generated schema into an array schema
    • If the property shape has an sh:pattern, then turn it into a string schema with a pattern constraint.
    • If the property shape has an sh:datatype (with a consistent value for the same property across the SHACL spec), then:
    • If the property shape has an sh:nodeKind pointing to sh:IRI, generate a string schema of format iri-reference.
    • Otherwise, return an empty schema
  • If the sh:minCount is > 0, the JSON key is added to the list of requiredProperties of the schema
Root node shape

With the provided root node shape IRI, create a reference to the corresponding schema from the #/$defs section.