Azure / opendigitaltwins-dtdl

Digital Twins Definition Language
Creative Commons Attribution 4.0 International
466 stars 160 forks source link

Can't see properties for models with complex types (object) #106

Closed sanjaybhagia closed 3 years ago

sanjaybhagia commented 3 years ago

Hi, I'm trying to understand how to use the complex types of type 'Object' when defining the dtdl for a model.

I've the following model:

{
    "@id": "dtmi:mycompany:project:model;1",
    "@type": "Interface",
    "displayName": "TestModel",
    "@context": "dtmi:dtdl:context;2",
    "contents": [
        {
            "@type": "Property",
            "name": "name",
            "schema": "string"
        },
        {
            "@type": "Property",
            "name": "CustomObject",
            "schema": "dtmi:mycompany:project:customobject;1"
        }
    ],
    "schemas": [
        {
            "@id": "dtmi:mycompany:project:customobject;1",
            "@type": "Object",
            "fields": [
                {
                    "name": "x",
                    "schema": "double"
                },
                {
                    "name": "y",
                    "schema": "double"
                }
            ]
        }
    ]
}

I upload the model and when I create the twin based on this, I only see name property that I can update.

image

I'm following the schema from this documentation: https://github.com/Azure/opendigitaltwins-dtdl/blob/master/DTDL/v2/dtdlv2.md

Is this the desired behavior?

I want to set the twin properties so that I can represent custom objects ( Preferably a JSON array but as I understand that's not possible as of now, so trying to understand at least the objects part).

Appreciate any guidance on this.

briancr-ms commented 3 years ago

This looks like a limitation in the ADT Explorer sample. The model you posted is correct. Once you create your digital twin (testtwin), you can update it through the REST API or by using the ADT SDK with a patch body like this:

[
  {
    "op": "add",
    "path": "/CustomObject",
    "value": { "x": 1.2, "y": 2.3 }
  }
]

Once there's some data in your digital twin, then you can view and edit it in ADT Explorer.

sanjaybhagia commented 3 years ago

Thanks briancr-ms, I'll give it a try.

sanjaybhagia commented 3 years ago

Spot on Brian! It worked for me. Thanks