Azure / opendigitaltwins-dtdl

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

Wrong documentation about maxMultiplicity in ver. 2 #78

Closed foreverstupid closed 3 years ago

foreverstupid commented 4 years ago

DTDL v.2 descritpion says that the default value of maxMultiplicity for Relationship is positive infinity, but when uploaded a model to the ADT, I got the following message:

{
   "error":{
      "code":"DTDLParserError",
      "message":"None of the models in this request could be created due to a problem with one or more models: Element dtmi:test:Main:_contents:_consistsOf;1 path minMultiplicity has value 1, which violates maxInclusive constraint value 0 | Element dtmi:test:Part:_contents:_manages;1 path minMultiplicity has value 1, which violates maxInclusive constraint value 0. See model documentation(http://aka.ms/ADTv2Models) for supported format."
   }
}

As I understand that means that the default value of maxMultiplicity is actually 0.

The model that I uploaded consists of two interfaces:

{
    "@id": "dtmi:test:Main;1",
    "@type": "Interface",
    "displayName": "Main",
    "contents": [
        {
            "@type": "Relationship",
            "name": "consistsOf",
            "displayName": "Consists of",
            "minMultiplicity": 1,
            "target": "dtmi:test:Part;1"
        }
    ],
    "@context": "dtmi:dtdl:context;2"
}

and

{
    "@id": "dtmi:test:Part;1",
    "@type": "Interface",
    "displayName": "Part",
    "contents": [
        {
            "@type": "Property",
            "name": "id",
            "displayName": "Id",
            "schema": "string"
        }
    ],
    "@context": "dtmi:dtdl:context;2"
}
briancr-ms commented 4 years ago

Thanks for raising this issue. I looked into this and the DTDL v2 documentation and ADT service behavior is correct. I think the problem is that the error message is hard to read (we are improving the error messages).

The error message is complaining about minMultiplicity, which must be 0 for now.

The error message says this: "Element dtmi:test:Main:_contents:_consistsOf;1 path minMultiplicity has value 1, which violates maxInclusive constraint value 0", which means:

The minMultiplicity property of the consistsOf element has value 1. This value violates the max constraint (for the minMultiplicity property) which is set to 0 (that is, the maximum value you can put in minMultiplicity is 0).

This matches the DTDL v2 documentation for minMultiplicity which says, "During public preview, minMultiplicity must always be 0."