Skip to content

LinkML JSON Schema Generator - Type Conversion #20

@mahdanoura

Description

@mahdanoura

Describe the bug
The LinkML JSON Schema generator = translates custom data types such as rdf:langString and specific URI-related types (uri, uriorcurie) always to "type": "string" types in the generated JSON schema.
For instance, the following LinkML schema,

classes:
  supportContact:
    description: >-
      Provides information about the TD maintainer as URI scheme.
    range: uriorcurie
    from_schema: schema:contactPoint

generates the following JSON Schema snippet

"supportContact": {
                    "description": "Provides information about the TD maintainer as URI scheme",
                    "type": "string"
                }

The same is true when I try to define customised data types, for instance:

types:
  languageString:
    base: rdf:langString
    uri: rdf:langString
    structured_pattern:
      syntax: "{text}@{tag}"
slots:
  title:
    description: >-
      Provides a human-readable title (e.g., display a text for UI representation) based on a default language.
    range: languageString
    required: true
    slot_uri: td:title

In this case, the generated JSON Schema is,

"title": {
      "description": "Provides a human-readable title (e.g., display a text for UI representation) based on a default language.",
        "type": "string"
                }

while ignoring the range:languageString

To Reproduce
My environment is follows:
python = "^3.11"
linkml-runtime = "^1.8.0rc2"
linkml = "^1.8.0rc2"

I use the the following code snippet for generating the JSON Schema from the LinkML schema:

from linkml.generators.jsonschemagen import JsonSchemaGenerator

json_schema_generator = JsonSchemaGenerator(YAML_SCHEMA_PATH, mergeimports=True)
(output_dir / 'jsonschema.json').write_text(json_schema_generator.serialize())

Expected behavior
The JSON Schema generator should for instance consider the format in JSON Schema "type":"string", "format":"uri"

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions