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

Are reference nodes allowed in DTDL? #132

Open
jbkoh opened this issue Sep 6, 2022 · 1 comment
Open

Are reference nodes allowed in DTDL? #132

jbkoh opened this issue Sep 6, 2022 · 1 comment

Comments

@jbkoh
Copy link

jbkoh commented Sep 6, 2022

Hi, there.

I'm trying to define a schema with DTDL v2. I see many fields are "required" while they can be referenced only. For example, I can globally define an Enum and refer to it by @id in other Property definitions. JSON-LD defines node reference:

A node reference is a node object containing only the @id property, which may represent a reference to a node object found elsewhere in the document.

However, in the DTDL v2 spec, @type, enumValues, and valueSchema are required which should not exist in referencing objects.

Do DTDL respect reference nodes, where the above properties should be optional), or should I always denormalize all the references?

Thanks!

@rido-min
Copy link
Member

Hi @jbkoh

You can reference custom schemas and referencing those types, eg:

{
  "@context": "dtmi:dtdl:context;2",
  "@id": "dtmi:samples:customSchemas;1",
  "@type": "Interface",
  "schemas": [
    {
      "@id": "dtmi:samples:customSchemas:OffOnEnum;1",
      "@type": "Enum",
      "valueSchema": "integer",
      "enumValues": [
        {
          "name": "On",
          "enumValue": 1
        },
        {
          "name": "Off",
          "enumValue": 0
        }
      ]
    }
  ],
  "contents": [
    {
      "@type": "Property",
      "name": "myEnumOnOff",
      "schema": "dtmi:samples:customSchemas:OffOnEnum;1"
    }
  ]
}

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