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

Clarification of 'schema' property data type #184

Open
dmocek opened this issue Sep 9, 2024 · 1 comment
Open

Clarification of 'schema' property data type #184

dmocek opened this issue Sep 9, 2024 · 1 comment

Comments

@dmocek
Copy link

dmocek commented Sep 9, 2024

What is the data type for a 'schema' value when the value is a DTMI reference to an Interface schema? For example, in the DTDL v3 Spec, there is this example:

{
  "@context": "dtmi:dtdl:context;3",
  "@id": "dtmi:com:example:ReusableTypeExample;1",
  "@type": "Interface",
  "contents": [
    {
      "@type": "Telemetry",
      "name": "accelerometer1",
      "schema": "dtmi:com:example:acceleration;1"
    },
    {
      "@type": "Telemetry",
      "name": "accelerometer2",
      "schema": "dtmi:com:example:acceleration;1"
    }
  ],
  "schemas": [
    {
      "@id": "dtmi:com:example:acceleration;1",
      "@type": "Object",
      "fields": [
        {
          "name": "x",
          "schema": "double"
        },
        {
          "name": "y",
          "schema": "double"
        },
        {
          "name": "z",
          "schema": "double"
        }
      ]
    }
  ]
}

Per the spec, the schema for accelerometer1 is supposed to be of a data type 'Schema' and indeed it references the Interface schema 'Object' complex schema described below it. However, the data type of the value in this property:

  "schema": "dtmi:com:example:acceleration;1"

is not a Primitive Schema nor a Complex Schema, but a DTMI reference to the Interface schema 'Object' complex schema. In the 'Complex Schema' section of the DTDL spec it states: "A complex schema can be specified directly as the value of a schema property or described in the Interface schemas set and referenced in a schema property.". What is the data type when "the complex schema is referenced in a schema property"? It seems to me that in the spec, the data type for "schema" should be either a 'Schema' (as already specified) or 'DTMI' (when it's a reference) which is a reference to an Interface schema.

@jrdouceur
Copy link
Collaborator

The datatype is 'Schema', whether it is inlined or referred to indirectly. You can see the schema type in the JSON-LD metamodel definition of DTDL v3 Telemetry, wherein the relevant parts are:

    {
      "@id": "dtmi:dtdl:class:Telemetry;3",
      "sh:property": [
        {
          "sh:path": "dtmi:dtdl:property:schema;3",
          "sh:or": [
            { "sh:class": "dtmi:dtdl:class:Schema;3" },
            { "sh:class": "dtmi:dtdl:class:Schema;2" }
          ]
        }
      ]
    }

You can also see in the DTDL Parser code that the Schema property on the DTTelemetryInfo class has type DTSchemaInfo.

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