Conversation
Added JsonStringEnumConverter to AssetKind/AssetType in ShellDescriptorDto to ensure enums are serialized as strings. Updated TemplateProvider to set Submodel.Kind to ModellingKind.Instance after deserialization. Added and updated unit tests to verify these behaviors. Also included necessary using directives for serialization and enum handling.
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
There was a problem hiding this comment.
Pull request overview
This PR adjusts template handling and API DTO serialization to better align with expected AAS semantics: submodel templates returned from the template provider are forced to ModellingKind.Instance, and ShellDescriptorDto asset enum properties are serialized as strings.
Changes:
- Set
ISubmodel.Kind = ModellingKind.Instancefor submodels returned byTemplateProvider.GetSubmodelTemplateAsync. - Serialize
ShellDescriptorDto.AssetKind/AssetTypeas strings viaJsonStringEnumConverter. - Add unit tests covering the new submodel kind behavior and enum-string JSON serialization.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| source/AAS.TwinEngine.DataEngine/Infrastructure/Providers/TemplateProvider/Services/TemplateProvider.cs | Mutates deserialized submodel templates so their Kind is always Instance. |
| source/AAS.TwinEngine.DataEngine/Api/AasRegistry/Responses/ShellDescriptorDto.cs | Adds enum-to-string JSON serialization for asset enum properties. |
| source/AAS.TwinEngine.DataEngine.UnitTests/Infrastructure/Providers/TemplateProvider/Services/TemplateProviderTests.cs | Verifies returned submodel template Kind is set to Instance. |
| source/AAS.TwinEngine.DataEngine.UnitTests/Api/AasRegistry/MappingProfiles/ShellDescriptorMapperProfileTests.cs | Adds a test asserting serialized DTO JSON contains string enum values. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
source/AAS.TwinEngine.DataEngine/Api/AasRegistry/Responses/ShellDescriptorDto.cs
Outdated
Show resolved
Hide resolved
...ne.DataEngine.UnitTests/Api/AasRegistry/MappingProfiles/ShellDescriptorMapperProfileTests.cs
Outdated
Show resolved
Hide resolved
Removed per-property JsonStringEnumConverter attributes from ShellDescriptorDto and configured global enum string serialization in Program.cs. Added missing using for System.Text.Json.Serialization. This ensures all enums are serialized as strings consistently across the API.
Changed TestData to use string "Type" for assetKind and assetType instead of integer 0. Removed redundant test for enum string serialization in ShellDescriptorMapperProfileTests.
Replaced integer enum values with string representations for fields like "assetKind", "assetType", and "type" in test JSON files. Changed submodel "kind" from "Template" to "Instance" to align with updated API/model expectations and improve clarity.
Test & Coverage ReportTest Results Summary
Code CoverageUnit Tests Coverage
Minimum allowed line rate is Module Tests Coverage
|
|
mm-asha
approved these changes
Apr 1, 2026
mm-mcn
approved these changes
Apr 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



This pull request ensures that submodel templates returned by the template provider are always marked as
Instanceand improves the serialization of enum properties inShellDescriptorDto. The changes include updates to JSON serialization behavior, new unit tests to verify these behaviors, and a helper method to set the submodel kind.Serialization improvements:
Updated
ShellDescriptorDtoso that theAssetKindandAssetTypeproperties are serialized as strings instead of integers by adding theJsonStringEnumConverterattribute.Added a unit test in
ShellDescriptorMapperProfileTeststo verify that serialized DTOs use string values for asset enums.Template provider enhancements:
Modified
TemplateProviderto set theKindproperty of returned submodel templates toModellingKind.Instanceby introducing theUpdateSubmodelTemplateKindhelper method.Added a unit test in
TemplateProviderTeststo confirm that the returned submodel template hasKindset toInstance.