diff --git a/aas_core_codegen/cpp/jsonization/_generate.py b/aas_core_codegen/cpp/jsonization/_generate.py index 13f8c6853..b464fcbd2 100644 --- a/aas_core_codegen/cpp/jsonization/_generate.py +++ b/aas_core_codegen/cpp/jsonization/_generate.py @@ -1438,16 +1438,19 @@ def _generate_concretely_deserialize_implementation( ) ) else: - required_properties = [ - prop + names_of_required_properties = [ + prop.name for prop in cls.properties if not isinstance(prop.type_annotation, intermediate.OptionalTypeAnnotation) ] - if len(required_properties) > 0: + if cls.serialization.with_model_type: + names_of_required_properties.append(Identifier("model_type")) + + if len(names_of_required_properties) > 0: blocks.append(Stripped("// region Check required properties")) - for prop in required_properties: - json_prop_name = naming.json_property(prop.name) + for prop_name in names_of_required_properties: + json_prop_name = naming.json_property(prop_name) json_prop_name_literal = cpp_common.string_literal(json_prop_name) blocks.append( Stripped( @@ -1465,6 +1468,7 @@ def _generate_concretely_deserialize_implementation( }}""" ) ) + blocks.append(Stripped("// endregion Check required properties")) # region Initialization @@ -1515,6 +1519,84 @@ def _generate_concretely_deserialize_implementation( blocks.append(Stripped(f"// endregion De-serialize {json_prop_name}")) # endregion + if cls.serialization.with_model_type: + # NOTE (mristin): + # If the serialization requires a model type, we consequently check for it + # here. The model type thus obtained is *not* used for any dispatch. We only + # use this value for verification to make sure that the model type + # of the instances is consistent with the expected value for its concrete + # class. This will be performed even though the code might have had to parse + # model type before for the dispatch. We decided to double-check to cover + # the case where a dispatch is *unnecessary* (*e.g.*, the caller knows the + # expected runtime type), but the model type might still be invalid in the + # input. Hence, when the dispatch is *necessary*, the model type JSON + # property will be parsed twice, which is a cost we currently find + # acceptable. + + blocks.append( + Stripped( + """\ +// region Check model type +// This check is intended only for verification, not for dispatch.""" + ) + ) + + model_type = naming.json_model_type(cls.name) + + blocks.append( + Stripped( + f"""\ +common::optional< +{I}std::wstring +> model_type; + +std::tie( +{I}model_type, +{I}error +) = DeserializeWstring( +{I}json["modelType"] +); + +if (error.has_value()) {{ +{I}error->path.segments.emplace_front( +{II}common::make_unique( +{III}L"modelType" +{II}) +{I}); + +{I}return std::make_pair< +{II}common::optional >, +{II}common::optional +{I}>( +{II}common::nullopt, +{II}std::move(error) +{I}); +}} + +if (*model_type != L"{model_type}") {{ +{I}std::wstring message = common::Concat( +{II}L"Expected model type '{model_type}', " +{II}L"but got: ", +{II}*model_type +{I}); + +{I}error = common::make_optional( +{II}message +{I}); + +{I}return std::make_pair< +{II}common::optional >, +{II}common::optional +{I}>( +{II}common::nullopt, +{II}std::move(error) +{I}); +}}""" + ) + ) + + blocks.append(Stripped("// endregion Check model type")) + # region Pass arguments to the constructor property_names = [prop.name for prop in cls.properties] constructor_argument_names = [arg.name for arg in cls.constructor.arguments] diff --git a/test_data/cpp/test_main/aas_core_meta.v3/expected_output/jsonization.cpp b/test_data/cpp/test_main/aas_core_meta.v3/expected_output/jsonization.cpp index 0e465b69d..83663d2a6 100644 --- a/test_data/cpp/test_main/aas_core_meta.v3/expected_output/jsonization.cpp +++ b/test_data/cpp/test_main/aas_core_meta.v3/expected_output/jsonization.cpp @@ -3849,6 +3849,18 @@ std::pair< ); } + if (!json.contains("modelType")) { + return std::make_pair< + common::optional >, + common::optional + >( + common::nullopt, + common::make_optional( + L"The required property modelType is missing" + ) + ); + } + // endregion Check required properties // region Initialization @@ -4529,6 +4541,58 @@ std::pair< // endregion De-serialize submodels + // region Check model type + // This check is intended only for verification, not for dispatch. + + common::optional< + std::wstring + > model_type; + + std::tie( + model_type, + error + ) = DeserializeWstring( + json["modelType"] + ); + + if (error.has_value()) { + error->path.segments.emplace_front( + common::make_unique( + L"modelType" + ) + ); + + return std::make_pair< + common::optional >, + common::optional + >( + common::nullopt, + std::move(error) + ); + } + + if (*model_type != L"AssetAdministrationShell") { + std::wstring message = common::Concat( + L"Expected model type 'AssetAdministrationShell', " + L"but got: ", + *model_type + ); + + error = common::make_optional( + message + ); + + return std::make_pair< + common::optional >, + common::optional + >( + common::nullopt, + std::move(error) + ); + } + + // endregion Check model type + return std::make_pair( common::make_optional< std::shared_ptr @@ -5480,6 +5544,18 @@ std::pair< ); } + if (!json.contains("modelType")) { + return std::make_pair< + common::optional >, + common::optional + >( + common::nullopt, + common::make_optional( + L"The required property modelType is missing" + ) + ); + } + // endregion Check required properties // region Initialization @@ -6384,6 +6460,58 @@ std::pair< // endregion De-serialize submodelElements + // region Check model type + // This check is intended only for verification, not for dispatch. + + common::optional< + std::wstring + > model_type; + + std::tie( + model_type, + error + ) = DeserializeWstring( + json["modelType"] + ); + + if (error.has_value()) { + error->path.segments.emplace_front( + common::make_unique( + L"modelType" + ) + ); + + return std::make_pair< + common::optional >, + common::optional + >( + common::nullopt, + std::move(error) + ); + } + + if (*model_type != L"Submodel") { + std::wstring message = common::Concat( + L"Expected model type 'Submodel', " + L"but got: ", + *model_type + ); + + error = common::make_optional( + message + ); + + return std::make_pair< + common::optional >, + common::optional + >( + common::nullopt, + std::move(error) + ); + } + + // endregion Check model type + return std::make_pair( common::make_optional< std::shared_ptr @@ -6651,6 +6779,18 @@ std::pair< ); } + if (!json.contains("modelType")) { + return std::make_pair< + common::optional >, + common::optional + >( + common::nullopt, + common::make_optional( + L"The required property modelType is missing" + ) + ); + } + // endregion Check required properties // region Initialization @@ -7393,6 +7533,58 @@ std::pair< // endregion De-serialize second + // region Check model type + // This check is intended only for verification, not for dispatch. + + common::optional< + std::wstring + > model_type; + + std::tie( + model_type, + error + ) = DeserializeWstring( + json["modelType"] + ); + + if (error.has_value()) { + error->path.segments.emplace_front( + common::make_unique( + L"modelType" + ) + ); + + return std::make_pair< + common::optional >, + common::optional + >( + common::nullopt, + std::move(error) + ); + } + + if (*model_type != L"RelationshipElement") { + std::wstring message = common::Concat( + L"Expected model type 'RelationshipElement', " + L"but got: ", + *model_type + ); + + error = common::make_optional( + message + ); + + return std::make_pair< + common::optional >, + common::optional + >( + common::nullopt, + std::move(error) + ); + } + + // endregion Check model type + return std::make_pair( common::make_optional< std::shared_ptr @@ -7577,6 +7769,18 @@ std::pair< ); } + if (!json.contains("modelType")) { + return std::make_pair< + common::optional >, + common::optional + >( + common::nullopt, + common::make_optional( + L"The required property modelType is missing" + ) + ); + } + // endregion Check required properties // region Initialization @@ -8541,6 +8745,58 @@ std::pair< // endregion De-serialize value + // region Check model type + // This check is intended only for verification, not for dispatch. + + common::optional< + std::wstring + > model_type; + + std::tie( + model_type, + error + ) = DeserializeWstring( + json["modelType"] + ); + + if (error.has_value()) { + error->path.segments.emplace_front( + common::make_unique( + L"modelType" + ) + ); + + return std::make_pair< + common::optional >, + common::optional + >( + common::nullopt, + std::move(error) + ); + } + + if (*model_type != L"SubmodelElementList") { + std::wstring message = common::Concat( + L"Expected model type 'SubmodelElementList', " + L"but got: ", + *model_type + ); + + error = common::make_optional( + message + ); + + return std::make_pair< + common::optional >, + common::optional + >( + common::nullopt, + std::move(error) + ); + } + + // endregion Check model type + return std::make_pair( common::make_optional< std::shared_ptr @@ -8637,6 +8893,22 @@ std::pair< } } + // region Check required properties + + if (!json.contains("modelType")) { + return std::make_pair< + common::optional >, + common::optional + >( + common::nullopt, + common::make_optional( + L"The required property modelType is missing" + ) + ); + } + + // endregion Check required properties + // region Initialization common::optional error; @@ -9412,31 +9684,83 @@ std::pair< // endregion De-serialize value - return std::make_pair( - common::make_optional< - std::shared_ptr - >( - // NOTE (mristin): - // We deliberately do not use std::make_shared here to avoid an unnecessary - // upcast. - new types::SubmodelElementCollection( - std::move(the_extensions), - std::move(the_category), - std::move(the_id_short), - std::move(the_display_name), - std::move(the_description), - std::move(the_semantic_id), - std::move(the_supplemental_semantic_ids), - std::move(the_qualifiers), - std::move(the_embedded_data_specifications), - std::move(the_value) - ) - ), - common::nullopt - ); -} + // region Check model type + // This check is intended only for verification, not for dispatch. -std::map< + common::optional< + std::wstring + > model_type; + + std::tie( + model_type, + error + ) = DeserializeWstring( + json["modelType"] + ); + + if (error.has_value()) { + error->path.segments.emplace_front( + common::make_unique( + L"modelType" + ) + ); + + return std::make_pair< + common::optional >, + common::optional + >( + common::nullopt, + std::move(error) + ); + } + + if (*model_type != L"SubmodelElementCollection") { + std::wstring message = common::Concat( + L"Expected model type 'SubmodelElementCollection', " + L"but got: ", + *model_type + ); + + error = common::make_optional( + message + ); + + return std::make_pair< + common::optional >, + common::optional + >( + common::nullopt, + std::move(error) + ); + } + + // endregion Check model type + + return std::make_pair( + common::make_optional< + std::shared_ptr + >( + // NOTE (mristin): + // We deliberately do not use std::make_shared here to avoid an unnecessary + // upcast. + new types::SubmodelElementCollection( + std::move(the_extensions), + std::move(the_category), + std::move(the_id_short), + std::move(the_display_name), + std::move(the_description), + std::move(the_semantic_id), + std::move(the_supplemental_semantic_ids), + std::move(the_qualifiers), + std::move(the_embedded_data_specifications), + std::move(the_value) + ) + ), + common::nullopt + ); +} + +std::map< std::string, std::function< std::pair< @@ -9617,6 +9941,18 @@ std::pair< ); } + if (!json.contains("modelType")) { + return std::make_pair< + common::optional >, + common::optional + >( + common::nullopt, + common::make_optional( + L"The required property modelType is missing" + ) + ); + } + // endregion Check required properties // region Initialization @@ -10424,6 +10760,58 @@ std::pair< // endregion De-serialize valueId + // region Check model type + // This check is intended only for verification, not for dispatch. + + common::optional< + std::wstring + > model_type; + + std::tie( + model_type, + error + ) = DeserializeWstring( + json["modelType"] + ); + + if (error.has_value()) { + error->path.segments.emplace_front( + common::make_unique( + L"modelType" + ) + ); + + return std::make_pair< + common::optional >, + common::optional + >( + common::nullopt, + std::move(error) + ); + } + + if (*model_type != L"Property") { + std::wstring message = common::Concat( + L"Expected model type 'Property', " + L"but got: ", + *model_type + ); + + error = common::make_optional( + message + ); + + return std::make_pair< + common::optional >, + common::optional + >( + common::nullopt, + std::move(error) + ); + } + + // endregion Check model type + return std::make_pair( common::make_optional< std::shared_ptr @@ -10519,6 +10907,22 @@ std::pair< } } + // region Check required properties + + if (!json.contains("modelType")) { + return std::make_pair< + common::optional >, + common::optional + >( + common::nullopt, + common::make_optional( + L"The required property modelType is missing" + ) + ); + } + + // endregion Check required properties + // region Initialization common::optional error; @@ -11330,6 +11734,58 @@ std::pair< // endregion De-serialize valueId + // region Check model type + // This check is intended only for verification, not for dispatch. + + common::optional< + std::wstring + > model_type; + + std::tie( + model_type, + error + ) = DeserializeWstring( + json["modelType"] + ); + + if (error.has_value()) { + error->path.segments.emplace_front( + common::make_unique( + L"modelType" + ) + ); + + return std::make_pair< + common::optional >, + common::optional + >( + common::nullopt, + std::move(error) + ); + } + + if (*model_type != L"MultiLanguageProperty") { + std::wstring message = common::Concat( + L"Expected model type 'MultiLanguageProperty', " + L"but got: ", + *model_type + ); + + error = common::make_optional( + message + ); + + return std::make_pair< + common::optional >, + common::optional + >( + common::nullopt, + std::move(error) + ); + } + + // endregion Check model type + return std::make_pair( common::make_optional< std::shared_ptr @@ -11439,6 +11895,18 @@ std::pair< ); } + if (!json.contains("modelType")) { + return std::make_pair< + common::optional >, + common::optional + >( + common::nullopt, + common::make_optional( + L"The required property modelType is missing" + ) + ); + } + // endregion Check required properties // region Initialization @@ -12243,6 +12711,58 @@ std::pair< // endregion De-serialize max + // region Check model type + // This check is intended only for verification, not for dispatch. + + common::optional< + std::wstring + > model_type; + + std::tie( + model_type, + error + ) = DeserializeWstring( + json["modelType"] + ); + + if (error.has_value()) { + error->path.segments.emplace_front( + common::make_unique( + L"modelType" + ) + ); + + return std::make_pair< + common::optional >, + common::optional + >( + common::nullopt, + std::move(error) + ); + } + + if (*model_type != L"Range") { + std::wstring message = common::Concat( + L"Expected model type 'Range', " + L"but got: ", + *model_type + ); + + error = common::make_optional( + message + ); + + return std::make_pair< + common::optional >, + common::optional + >( + common::nullopt, + std::move(error) + ); + } + + // endregion Check model type + return std::make_pair( common::make_optional< std::shared_ptr @@ -12337,6 +12857,22 @@ std::pair< } } + // region Check required properties + + if (!json.contains("modelType")) { + return std::make_pair< + common::optional >, + common::optional + >( + common::nullopt, + common::make_optional( + L"The required property modelType is missing" + ) + ); + } + + // endregion Check required properties + // region Initialization common::optional error; @@ -13051,6 +13587,58 @@ std::pair< // endregion De-serialize value + // region Check model type + // This check is intended only for verification, not for dispatch. + + common::optional< + std::wstring + > model_type; + + std::tie( + model_type, + error + ) = DeserializeWstring( + json["modelType"] + ); + + if (error.has_value()) { + error->path.segments.emplace_front( + common::make_unique( + L"modelType" + ) + ); + + return std::make_pair< + common::optional >, + common::optional + >( + common::nullopt, + std::move(error) + ); + } + + if (*model_type != L"ReferenceElement") { + std::wstring message = common::Concat( + L"Expected model type 'ReferenceElement', " + L"but got: ", + *model_type + ); + + error = common::make_optional( + message + ); + + return std::make_pair< + common::optional >, + common::optional + >( + common::nullopt, + std::move(error) + ); + } + + // endregion Check model type + return std::make_pair( common::make_optional< std::shared_ptr @@ -13158,6 +13746,18 @@ std::pair< ); } + if (!json.contains("modelType")) { + return std::make_pair< + common::optional >, + common::optional + >( + common::nullopt, + common::make_optional( + L"The required property modelType is missing" + ) + ); + } + // endregion Check required properties // region Initialization @@ -13873,21 +14473,53 @@ std::pair< } } - // endregion De-serialize value + // endregion De-serialize value + + // region De-serialize contentType + + std::tie( + the_content_type, + error + ) = DeserializeWstring( + json["contentType"] + ); + + if (error.has_value()) { + error->path.segments.emplace_front( + common::make_unique( + L"contentType" + ) + ); + + return std::make_pair< + common::optional >, + common::optional + >( + common::nullopt, + std::move(error) + ); + } + + // endregion De-serialize contentType - // region De-serialize contentType + // region Check model type + // This check is intended only for verification, not for dispatch. + + common::optional< + std::wstring + > model_type; std::tie( - the_content_type, + model_type, error ) = DeserializeWstring( - json["contentType"] + json["modelType"] ); if (error.has_value()) { error->path.segments.emplace_front( common::make_unique( - L"contentType" + L"modelType" ) ); @@ -13900,7 +14532,27 @@ std::pair< ); } - // endregion De-serialize contentType + if (*model_type != L"Blob") { + std::wstring message = common::Concat( + L"Expected model type 'Blob', " + L"but got: ", + *model_type + ); + + error = common::make_optional( + message + ); + + return std::make_pair< + common::optional >, + common::optional + >( + common::nullopt, + std::move(error) + ); + } + + // endregion Check model type return std::make_pair( common::make_optional< @@ -14010,6 +14662,18 @@ std::pair< ); } + if (!json.contains("modelType")) { + return std::make_pair< + common::optional >, + common::optional + >( + common::nullopt, + common::make_optional( + L"The required property modelType is missing" + ) + ); + } + // endregion Check required properties // region Initialization @@ -14752,6 +15416,58 @@ std::pair< // endregion De-serialize contentType + // region Check model type + // This check is intended only for verification, not for dispatch. + + common::optional< + std::wstring + > model_type; + + std::tie( + model_type, + error + ) = DeserializeWstring( + json["modelType"] + ); + + if (error.has_value()) { + error->path.segments.emplace_front( + common::make_unique( + L"modelType" + ) + ); + + return std::make_pair< + common::optional >, + common::optional + >( + common::nullopt, + std::move(error) + ); + } + + if (*model_type != L"File") { + std::wstring message = common::Concat( + L"Expected model type 'File', " + L"but got: ", + *model_type + ); + + error = common::make_optional( + message + ); + + return std::make_pair< + common::optional >, + common::optional + >( + common::nullopt, + std::move(error) + ); + } + + // endregion Check model type + return std::make_pair( common::make_optional< std::shared_ptr @@ -14873,6 +15589,18 @@ std::pair< ); } + if (!json.contains("modelType")) { + return std::make_pair< + common::optional >, + common::optional + >( + common::nullopt, + common::make_optional( + L"The required property modelType is missing" + ) + ); + } + // endregion Check required properties // region Initialization @@ -15710,6 +16438,58 @@ std::pair< // endregion De-serialize annotations + // region Check model type + // This check is intended only for verification, not for dispatch. + + common::optional< + std::wstring + > model_type; + + std::tie( + model_type, + error + ) = DeserializeWstring( + json["modelType"] + ); + + if (error.has_value()) { + error->path.segments.emplace_front( + common::make_unique( + L"modelType" + ) + ); + + return std::make_pair< + common::optional >, + common::optional + >( + common::nullopt, + std::move(error) + ); + } + + if (*model_type != L"AnnotatedRelationshipElement") { + std::wstring message = common::Concat( + L"Expected model type 'AnnotatedRelationshipElement', " + L"but got: ", + *model_type + ); + + error = common::make_optional( + message + ); + + return std::make_pair< + common::optional >, + common::optional + >( + common::nullopt, + std::move(error) + ); + } + + // endregion Check model type + return std::make_pair( common::make_optional< std::shared_ptr @@ -15821,6 +16601,18 @@ std::pair< ); } + if (!json.contains("modelType")) { + return std::make_pair< + common::optional >, + common::optional + >( + common::nullopt, + common::make_optional( + L"The required property modelType is missing" + ) + ); + } + // endregion Check required properties // region Initialization @@ -16786,6 +17578,58 @@ std::pair< // endregion De-serialize specificAssetIds + // region Check model type + // This check is intended only for verification, not for dispatch. + + common::optional< + std::wstring + > model_type; + + std::tie( + model_type, + error + ) = DeserializeWstring( + json["modelType"] + ); + + if (error.has_value()) { + error->path.segments.emplace_front( + common::make_unique( + L"modelType" + ) + ); + + return std::make_pair< + common::optional >, + common::optional + >( + common::nullopt, + std::move(error) + ); + } + + if (*model_type != L"Entity") { + std::wstring message = common::Concat( + L"Expected model type 'Entity', " + L"but got: ", + *model_type + ); + + error = common::make_optional( + message + ); + + return std::make_pair< + common::optional >, + common::optional + >( + common::nullopt, + std::move(error) + ); + } + + // endregion Check model type + return std::make_pair( common::make_optional< std::shared_ptr @@ -17377,6 +18221,18 @@ std::pair< ); } + if (!json.contains("modelType")) { + return std::make_pair< + common::optional >, + common::optional + >( + common::nullopt, + common::make_optional( + L"The required property modelType is missing" + ) + ); + } + // endregion Check required properties // region Initialization @@ -18340,32 +19196,84 @@ std::pair< // region De-serialize maxInterval - if (json.contains("maxInterval")) { - std::tie( - the_max_interval, - error - ) = DeserializeWstring( - json["maxInterval"] + if (json.contains("maxInterval")) { + std::tie( + the_max_interval, + error + ) = DeserializeWstring( + json["maxInterval"] + ); + + if (error.has_value()) { + error->path.segments.emplace_front( + common::make_unique( + L"maxInterval" + ) + ); + + return std::make_pair< + common::optional >, + common::optional + >( + common::nullopt, + std::move(error) + ); + } + } + + // endregion De-serialize maxInterval + + // region Check model type + // This check is intended only for verification, not for dispatch. + + common::optional< + std::wstring + > model_type; + + std::tie( + model_type, + error + ) = DeserializeWstring( + json["modelType"] + ); + + if (error.has_value()) { + error->path.segments.emplace_front( + common::make_unique( + L"modelType" + ) + ); + + return std::make_pair< + common::optional >, + common::optional + >( + common::nullopt, + std::move(error) + ); + } + + if (*model_type != L"BasicEventElement") { + std::wstring message = common::Concat( + L"Expected model type 'BasicEventElement', " + L"but got: ", + *model_type ); - if (error.has_value()) { - error->path.segments.emplace_front( - common::make_unique( - L"maxInterval" - ) - ); + error = common::make_optional( + message + ); - return std::make_pair< - common::optional >, - common::optional - >( - common::nullopt, - std::move(error) - ); - } + return std::make_pair< + common::optional >, + common::optional + >( + common::nullopt, + std::move(error) + ); } - // endregion De-serialize maxInterval + // endregion Check model type return std::make_pair( common::make_optional< @@ -18468,6 +19376,22 @@ std::pair< } } + // region Check required properties + + if (!json.contains("modelType")) { + return std::make_pair< + common::optional >, + common::optional + >( + common::nullopt, + common::make_optional( + L"The required property modelType is missing" + ) + ); + } + + // endregion Check required properties + // region Initialization common::optional error; @@ -19433,6 +20357,58 @@ std::pair< // endregion De-serialize inoutputVariables + // region Check model type + // This check is intended only for verification, not for dispatch. + + common::optional< + std::wstring + > model_type; + + std::tie( + model_type, + error + ) = DeserializeWstring( + json["modelType"] + ); + + if (error.has_value()) { + error->path.segments.emplace_front( + common::make_unique( + L"modelType" + ) + ); + + return std::make_pair< + common::optional >, + common::optional + >( + common::nullopt, + std::move(error) + ); + } + + if (*model_type != L"Operation") { + std::wstring message = common::Concat( + L"Expected model type 'Operation', " + L"but got: ", + *model_type + ); + + error = common::make_optional( + message + ); + + return std::make_pair< + common::optional >, + common::optional + >( + common::nullopt, + std::move(error) + ); + } + + // endregion Check model type + return std::make_pair( common::make_optional< std::shared_ptr @@ -19647,6 +20623,22 @@ std::pair< } } + // region Check required properties + + if (!json.contains("modelType")) { + return std::make_pair< + common::optional >, + common::optional + >( + common::nullopt, + common::make_optional( + L"The required property modelType is missing" + ) + ); + } + + // endregion Check required properties + // region Initialization common::optional error; @@ -20327,6 +21319,58 @@ std::pair< // endregion De-serialize embeddedDataSpecifications + // region Check model type + // This check is intended only for verification, not for dispatch. + + common::optional< + std::wstring + > model_type; + + std::tie( + model_type, + error + ) = DeserializeWstring( + json["modelType"] + ); + + if (error.has_value()) { + error->path.segments.emplace_front( + common::make_unique( + L"modelType" + ) + ); + + return std::make_pair< + common::optional >, + common::optional + >( + common::nullopt, + std::move(error) + ); + } + + if (*model_type != L"Capability") { + std::wstring message = common::Concat( + L"Expected model type 'Capability', " + L"but got: ", + *model_type + ); + + error = common::make_optional( + message + ); + + return std::make_pair< + common::optional >, + common::optional + >( + common::nullopt, + std::move(error) + ); + } + + // endregion Check model type + return std::make_pair( common::make_optional< std::shared_ptr @@ -20431,6 +21475,18 @@ std::pair< ); } + if (!json.contains("modelType")) { + return std::make_pair< + common::optional >, + common::optional + >( + common::nullopt, + common::make_optional( + L"The required property modelType is missing" + ) + ); + } + // endregion Check required properties // region Initialization @@ -21047,6 +22103,58 @@ std::pair< // endregion De-serialize isCaseOf + // region Check model type + // This check is intended only for verification, not for dispatch. + + common::optional< + std::wstring + > model_type; + + std::tie( + model_type, + error + ) = DeserializeWstring( + json["modelType"] + ); + + if (error.has_value()) { + error->path.segments.emplace_front( + common::make_unique( + L"modelType" + ) + ); + + return std::make_pair< + common::optional >, + common::optional + >( + common::nullopt, + std::move(error) + ); + } + + if (*model_type != L"ConceptDescription") { + std::wstring message = common::Concat( + L"Expected model type 'ConceptDescription', " + L"but got: ", + *model_type + ); + + error = common::make_optional( + message + ); + + return std::make_pair< + common::optional >, + common::optional + >( + common::nullopt, + std::move(error) + ); + } + + // endregion Check model type + return std::make_pair( common::make_optional< std::shared_ptr @@ -23759,6 +24867,18 @@ std::pair< ); } + if (!json.contains("modelType")) { + return std::make_pair< + common::optional >, + common::optional + >( + common::nullopt, + common::make_optional( + L"The required property modelType is missing" + ) + ); + } + // endregion Check required properties // region Initialization @@ -24375,6 +25495,58 @@ std::pair< // endregion De-serialize levelType + // region Check model type + // This check is intended only for verification, not for dispatch. + + common::optional< + std::wstring + > model_type; + + std::tie( + model_type, + error + ) = DeserializeWstring( + json["modelType"] + ); + + if (error.has_value()) { + error->path.segments.emplace_front( + common::make_unique( + L"modelType" + ) + ); + + return std::make_pair< + common::optional >, + common::optional + >( + common::nullopt, + std::move(error) + ); + } + + if (*model_type != L"DataSpecificationIec61360") { + std::wstring message = common::Concat( + L"Expected model type 'DataSpecificationIec61360', " + L"but got: ", + *model_type + ); + + error = common::make_optional( + message + ); + + return std::make_pair< + common::optional >, + common::optional + >( + common::nullopt, + std::move(error) + ); + } + + // endregion Check model type + return std::make_pair( common::make_optional< std::shared_ptr