diff --git a/dotnet/src/DTDLParser/generated/ContextCollection.g.cs b/dotnet/src/DTDLParser/generated/ContextCollection.g.cs index 21a31c3c..6179631d 100644 --- a/dotnet/src/DTDLParser/generated/ContextCollection.g.cs +++ b/dotnet/src/DTDLParser/generated/ContextCollection.g.cs @@ -42,8 +42,9 @@ static ContextCollection() EndogenousAffiliateContextHistories["dtmi:dtdl:extension:mqtt"] = GetAffiliate2ContextHistory(); EndogenousAffiliateContextHistories["dtmi:dtdl:extension:overriding"] = GetAffiliate3ContextHistory(); EndogenousAffiliateContextHistories["dtmi:dtdl:extension:quantitativeTypes"] = GetAffiliate4ContextHistory(); - EndogenousAffiliateContextHistories["dtmi:dtdl:limits:onvif"] = GetAffiliate5ContextHistory(); - EndogenousAffiliateContextHistories["dtmi:iotcentral:context"] = GetAffiliate6ContextHistory(); + EndogenousAffiliateContextHistories["dtmi:dtdl:extension:requirement"] = GetAffiliate5ContextHistory(); + EndogenousAffiliateContextHistories["dtmi:dtdl:limits:onvif"] = GetAffiliate6ContextHistory(); + EndogenousAffiliateContextHistories["dtmi:iotcentral:context"] = GetAffiliate7ContextHistory(); } private static ContextHistory GetAffiliate0ContextHistory() @@ -897,7 +898,8 @@ private static ContextHistory GetAffiliate5ContextHistory() { List versionedContexts = new List(); - VersionedContext context1_0 = new VersionedContext("dtmi:dtdl:limits:onvif;1", 1, 0, 4, "onvif_1", mergeDefinitions: false); + VersionedContext context1_0 = new VersionedContext("dtmi:dtdl:extension:requirement;1", 1, 0, 0, null, mergeDefinitions: false); + context1_0.AddTermDefinition("Required", new Dtmi("dtmi:dtdl:extension:requirement:v1:Required"), isMergeableType: false); versionedContexts.Add(context1_0); return new ContextHistory(versionedContexts); @@ -907,6 +909,16 @@ private static ContextHistory GetAffiliate6ContextHistory() { List versionedContexts = new List(); + VersionedContext context1_0 = new VersionedContext("dtmi:dtdl:limits:onvif;1", 1, 0, 4, "onvif_1", mergeDefinitions: false); + versionedContexts.Add(context1_0); + + return new ContextHistory(versionedContexts); + } + + private static ContextHistory GetAffiliate7ContextHistory() + { + List versionedContexts = new List(); + VersionedContext context2_0 = new VersionedContext("dtmi:iotcentral:context;2", 2, 0, 0, null, mergeDefinitions: false); context2_0.ReserveIdDefinitionPrefix("dtmi:iotcentral:"); context2_0.AddTermDefinition("AccelerationVector", new Dtmi("dtmi:iotcentral:class:AccelerationVector;2"), isMergeableType: false); diff --git a/dotnet/src/DTDLParser/generated/SupplementalTypeCollection.g.cs b/dotnet/src/DTDLParser/generated/SupplementalTypeCollection.g.cs index 51ac2f23..41fbb1c6 100644 --- a/dotnet/src/DTDLParser/generated/SupplementalTypeCollection.g.cs +++ b/dotnet/src/DTDLParser/generated/SupplementalTypeCollection.g.cs @@ -37,6 +37,7 @@ static SupplementalTypeCollection() Dtmi dtdlExtensionOverridingContextIdV2 = new Dtmi("dtmi:dtdl:extension:overriding;2"); Dtmi dtdlExtensionQuantitativeTypesContextIdV1 = new Dtmi("dtmi:dtdl:extension:quantitativeTypes;1"); Dtmi dtdlExtensionQuantitativeTypesContextIdV2 = new Dtmi("dtmi:dtdl:extension:quantitativeTypes;2"); + Dtmi dtdlExtensionRequirementContextIdV1 = new Dtmi("dtmi:dtdl:extension:requirement;1"); Dtmi dtdlLimitsOnvifContextIdV1 = new Dtmi("dtmi:dtdl:limits:onvif;1"); Dtmi iotcentralContextIdV2 = new Dtmi("dtmi:iotcentral:context;2"); @@ -190,6 +191,7 @@ static SupplementalTypeCollection() Dtmi voltageTypeIdCV2 = new Dtmi("dtmi:dtdl:extension:quantitativeTypes:v2:class:Voltage"); Dtmi volumeTypeIdCV2 = new Dtmi("dtmi:dtdl:extension:quantitativeTypes:v2:class:Volume"); Dtmi volumeFlowRateTypeIdCV2 = new Dtmi("dtmi:dtdl:extension:quantitativeTypes:v2:class:VolumeFlowRate"); + Dtmi requiredTypeIdCV1 = new Dtmi("dtmi:dtdl:extension:requirement:v1:Required"); Dtmi accelerationVectorTypeIdEV2 = new Dtmi("dtmi:iotcentral:class:AccelerationVector;2"); Dtmi eventTypeIdEV2 = new Dtmi("dtmi:iotcentral:class:Event;2"); Dtmi locationTypeIdEV2 = new Dtmi("dtmi:iotcentral:class:Location;2"); @@ -996,6 +998,10 @@ static SupplementalTypeCollection() volumeFlowRateInfoCV2.AllowedCotypeKinds = new HashSet() { DTEntityKind.CommandRequest, DTEntityKind.CommandResponse, DTEntityKind.Field, DTEntityKind.MapValue, DTEntityKind.Property, DTEntityKind.Telemetry }; volumeFlowRateInfoCV2.AllowedCotypeVersions = new HashSet() { 4 }; + DTSupplementalTypeInfo requiredInfoCV1 = new DTSupplementalTypeInfo(DTExtensionKind.AdjunctType, dtdlExtensionRequirementContextIdV1, requiredTypeIdCV1, isAbstract: false, isMergeable: false, adjunctTypeTypeIdEV4); + requiredInfoCV1.AllowedCotypeKinds = new HashSet() { DTEntityKind.Field }; + requiredInfoCV1.AllowedCotypeVersions = new HashSet() { 3, 4 }; + DTSupplementalTypeInfo accelerationVectorInfoEV2 = new DTSupplementalTypeInfo(DTExtensionKind.SemanticType, iotcentralContextIdV2, accelerationVectorTypeIdEV2, isAbstract: false, isMergeable: false, semanticTypeTypeIdEV2); accelerationVectorInfoEV2.AddProperty("dtmi:dtdl:property:unit;2", new Dtmi("dtmi:standard:class:AccelerationUnit;2"), 1, null, null, null, null, regex: null, hasUniqueValue: false, isPlural: false, isOptional: true, defaultLanguage: null, dtmiSeg: null, dictionaryKey: null, idRequired: false, typeRequired: true, childOf: null, instanceProperty: null, requiredValues: null, requiredValuesString: null, requiredLiteral: null); accelerationVectorInfoEV2.AddPropertyValueConstraint("schema", new ValueConstraint() { RequiredValues = new List() { new Dtmi("dtmi:iotcentral:schema:vector;2") }, RequiredValuesString = "vector" }); @@ -1477,6 +1483,7 @@ static SupplementalTypeCollection() EndogenousSupplementalTypes[voltageTypeIdCV2] = voltageInfoCV2; EndogenousSupplementalTypes[volumeTypeIdCV2] = volumeInfoCV2; EndogenousSupplementalTypes[volumeFlowRateTypeIdCV2] = volumeFlowRateInfoCV2; + EndogenousSupplementalTypes[requiredTypeIdCV1] = requiredInfoCV1; EndogenousSupplementalTypes[accelerationVectorTypeIdEV2] = accelerationVectorInfoEV2; EndogenousSupplementalTypes[eventTypeIdEV2] = eventInfoEV2; EndogenousSupplementalTypes[locationTypeIdEV2] = locationInfoEV2; diff --git a/dotnet/src/DTDLParser/generated/SupportedExtensions.g.md b/dotnet/src/DTDLParser/generated/SupportedExtensions.g.md index a954d724..98c7d9bd 100644 --- a/dotnet/src/DTDLParser/generated/SupportedExtensions.g.md +++ b/dotnet/src/DTDLParser/generated/SupportedExtensions.g.md @@ -15,3 +15,4 @@ The chart below itemizes the extension contexts that are currently supported. | [Overriding v2](https://github.com/Azure/opendigitaltwins-dtdl/blob/master/DTDL/v3/DTDL.overriding.v2.md) | `dtmi:dtdl:extension:overriding;2` | [3](https://github.com/Azure/opendigitaltwins-dtdl/blob/master/DTDL/v3/DTDL.v3.md), [4](https://github.com/Azure/opendigitaltwins-dtdl/blob/master/DTDL/v4/DTDL.v4.md) | | [Mqtt v1](https://github.com/Azure/opendigitaltwins-dtdl/blob/master/DTDL/v3/DTDL.mqtt.v1.md) | `dtmi:dtdl:extension:mqtt;1` | [3](https://github.com/Azure/opendigitaltwins-dtdl/blob/master/DTDL/v3/DTDL.v3.md) | | [Mqtt v2](https://github.com/Azure/opendigitaltwins-dtdl/blob/master/DTDL/v3/DTDL.mqtt.v2.md) | `dtmi:dtdl:extension:mqtt;2` | [3](https://github.com/Azure/opendigitaltwins-dtdl/blob/master/DTDL/v3/DTDL.v3.md), [4](https://github.com/Azure/opendigitaltwins-dtdl/blob/master/DTDL/v4/DTDL.v4.md) | +| [Requirement v1](https://github.com/Azure/opendigitaltwins-dtdl/blob/master/DTDL/v3/DTDL.requirement.v1.md) | `dtmi:dtdl:extension:requirement;1` | [3](https://github.com/Azure/opendigitaltwins-dtdl/blob/master/DTDL/v3/DTDL.v3.md), [4](https://github.com/Azure/opendigitaltwins-dtdl/blob/master/DTDL/v4/DTDL.v4.md) | diff --git a/dotnet/tests/ParserUnitTest/generated/DocExampleUnitTest.g.cs b/dotnet/tests/ParserUnitTest/generated/DocExampleUnitTest.g.cs index d288ec15..bc66cb0f 100644 --- a/dotnet/tests/ParserUnitTest/generated/DocExampleUnitTest.g.cs +++ b/dotnet/tests/ParserUnitTest/generated/DocExampleUnitTest.g.cs @@ -95,6 +95,8 @@ public class DocExampleUnitTest [DataRow("RelationshipDocExample-en-US-3-V2")] [DataRow("RelationshipDocExample-en-US-3-V3")] [DataRow("RelationshipDocExample-en-US-3-V4")] + [DataRow("requirementDocExample-en-US-1-V1")] + [DataRow("requirementDocExample-en-US-2-V1")] [DataRow("SpecExample-Array-V2")] [DataRow("SpecExample-Array-V3")] [DataRow("SpecExample-Array-V4")] diff --git a/dtdl/dtdl.json b/dtdl/dtdl.json index 81af2025..eaa93ba3 100644 --- a/dtdl/dtdl.json +++ b/dtdl/dtdl.json @@ -8,7 +8,8 @@ "historization": [ "1", "2" ], "annotation": [ "1", "2" ], "overriding": [ "1", "2" ], - "mqtt": [ "1", "2" ] + "mqtt": [ "1", "2" ], + "requirement": [ "1" ] }, "limitExtensions": { "onvif": [ "1" ] diff --git a/dtdl/dtdl_digest.json b/dtdl/dtdl_digest.json index 5b17a824..3c3adb8f 100644 --- a/dtdl/dtdl_digest.json +++ b/dtdl/dtdl_digest.json @@ -1411,6 +1411,9 @@ "zepto": "dtmi:dtdl:extension:quantitativeTypes:v2:unitprefix:zepto", "zetta": "dtmi:dtdl:extension:quantitativeTypes:v2:unitprefix:zetta" }, + "dtmi:dtdl:extension:requirement;1": { + "Required": "dtmi:dtdl:extension:requirement:v1:Required" + }, "dtmi:dtdl:limits:onvif;1": {}, "dtmi:iotcentral:context;2": { "AccelerationVector": "dtmi:iotcentral:class:AccelerationVector;2", @@ -13761,6 +13764,11 @@ "en-us": "A set of standard semantic types, unit types, and units." } }, + "dtmi:dtdl:extension:requirement;1": { + "description": { + "en-us": "Selectively designate one or more fields in an Object as required." + } + }, "dtmi:dtdl:limits:onvif;1": { "description": { "en-us": "Some limits." @@ -37784,6 +37792,24 @@ }, "siblings": [] }, + "dtmi:dtdl:extension:requirement:v1:Required": { + "abstract": false, + "constraints": [], + "cotypes": [ + "Field" + ], + "cotypeVersions": [ + 3, + 4 + ], + "elements": [], + "extensionContext": "dtmi:dtdl:extension:requirement;1", + "extensionKind": "AdjunctType", + "mergeable": false, + "parent": "dtmi:dtdl:class:AdjunctType;4", + "properties": {}, + "siblings": [] + }, "dtmi:iotcentral:class:AccelerationVector;2": { "abstract": false, "constraints": [ diff --git a/test-cases/doc-examples/requirementDocExample-en-US-1-V1.json b/test-cases/doc-examples/requirementDocExample-en-US-1-V1.json new file mode 100644 index 00000000..d5dde85a --- /dev/null +++ b/test-cases/doc-examples/requirementDocExample-en-US-1-V1.json @@ -0,0 +1,27 @@ +{ + "valid": true, + "options": [], + "input": [ + { + "@context": "dtmi:dtdl:context;3", + "@id": "dtmi:com:example:Locator;1", + "@type": "Interface", + "schemas": [ + { + "@id": "dtmi:ex:Point2D;1", + "@type": "Object", + "fields": [ + { + "name": "x", + "schema": "double" + }, + { + "name": "y", + "schema": "double" + } + ] + } + ] + } + ] +} diff --git a/test-cases/doc-examples/requirementDocExample-en-US-2-V1.json b/test-cases/doc-examples/requirementDocExample-en-US-2-V1.json new file mode 100644 index 00000000..e487d502 --- /dev/null +++ b/test-cases/doc-examples/requirementDocExample-en-US-2-V1.json @@ -0,0 +1,38 @@ +{ + "valid": true, + "options": [], + "input": [ + { + "@context": [ + "dtmi:dtdl:context;3", + "dtmi:dtdl:extension:requirement;1" + ], + "@id": "dtmi:com:example:Locator;1", + "@type": "Interface", + "schemas": [ + { + "@id": "dtmi:ex:Point2D;1", + "@type": "Object", + "fields": [ + { + "@type": [ + "Field", + "Required" + ], + "name": "x", + "schema": "double" + }, + { + "@type": [ + "Field", + "Required" + ], + "name": "y", + "schema": "double" + } + ] + } + ] + } + ] +}