w3c / wot-thing-description-toolchain-tmp

work area for WoT Thing Description toolchain
0 stars 1 forks source link

LinkML JSON Schema Generator - Type Conversion #20

Open mahdanoura opened 2 weeks ago

mahdanoura commented 2 weeks ago

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 commented 2 weeks ago

this issue is reported to the LinkML community.

egekorkan commented 2 weeks ago

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