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

LinkML JSON Schema Generator - Type Conversion #20

Open
mahdanoura opened this issue Jul 9, 2024 · 2 comments
Open

LinkML JSON Schema Generator - Type Conversion #20

mahdanoura opened this issue Jul 9, 2024 · 2 comments
Assignees

Comments

@mahdanoura
Copy link
Contributor

mahdanoura commented Jul 9, 2024

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"

@mahdanoura
Copy link
Contributor Author

this issue is reported to the LinkML community.

@egekorkan
Copy link
Contributor

Should the generated schema have "type":"string", "format":"uri" or do you expect something more?

@mahdanoura mahdanoura changed the title LinkML JSON Schema Generator - Incorrect Type Conversion LinkML JSON Schema Generator - Type Conversion Jul 10, 2024
@mahdanoura mahdanoura self-assigned this Jul 10, 2024
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

2 participants