Skip to content

Commit 0e2a388

Browse files
committed
Refactor API controllers and DTOs to remove unnecessary attributes and improve method signatures for better readability
1 parent 1856e77 commit 0e2a388

9 files changed

Lines changed: 11 additions & 50 deletions

File tree

source/AAS.TwinEngine.DataEngine/Api/AasRegistry/Responses/ShellDescriptorDto.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System.Text.Json.Serialization;
2-
using System.ComponentModel;
32

43
using AAS.TwinEngine.DataEngine.Api.Shared;
54
using AAS.TwinEngine.DataEngine.Api.SubmodelRegistry.Responses;
@@ -31,7 +30,6 @@ public class ShellDescriptorDto
3130
public IList<EndpointDto>? Endpoints { get; init; }
3231

3332
[JsonPropertyName("globalAssetId")]
34-
[DefaultValue("https://example.com/ids/asset/4711")]
3533
public string? GlobalAssetId { get; set; }
3634

3735
[JsonPropertyName("idShort")]

source/AAS.TwinEngine.DataEngine/Api/AasRegistry/Responses/ShellDescriptorsDto.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System.Text.Json.Serialization;
2-
using System.ComponentModel;
32

43
using AAS.TwinEngine.DataEngine.Api.Shared;
54

source/AAS.TwinEngine.DataEngine/Api/AasRegistry/ShellDescriptorController.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,7 @@ public class ShellDescriptorController(
3838
[ProducesResponseType(typeof(ServiceErrorResponse), (int)HttpStatusCode.NotFound)]
3939
[ProducesResponseType(typeof(ServiceErrorResponse), (int)HttpStatusCode.InternalServerError)]
4040
[ProducesResponseType(typeof(ServiceErrorResponse), (int)HttpStatusCode.BadRequest)]
41-
public async Task<ActionResult<ShellDescriptorsDto>> GetAllShellDescriptorsAsync(
42-
[FromQuery] int? limit,
43-
[FromQuery] string? cursor,
44-
CancellationToken cancellationToken)
41+
public async Task<ActionResult<ShellDescriptorsDto>> GetAllShellDescriptorsAsync([FromQuery] int? limit, [FromQuery] string? cursor, CancellationToken cancellationToken)
4542
{
4643
logger.LogInformation("Get All ShellDescriptors");
4744
var request = new GetShellDescriptorsRequest(limit, cursor);
@@ -63,9 +60,7 @@ public async Task<ActionResult<ShellDescriptorsDto>> GetAllShellDescriptorsAsync
6360
[ProducesResponseType(typeof(ServiceErrorResponse), (int)HttpStatusCode.BadRequest)]
6461
[ProducesResponseType(typeof(ServiceErrorResponse), (int)HttpStatusCode.NotFound)]
6562
[ProducesResponseType(typeof(ServiceErrorResponse), (int)HttpStatusCode.InternalServerError)]
66-
public async Task<ActionResult<ShellDescriptorDto>> GetShellDescriptorByIdAsync(
67-
[FromRoute, Description("Base64url encoded AAS identifier.")] string aasIdentifier,
68-
CancellationToken cancellationToken)
63+
public async Task<ActionResult<ShellDescriptorDto>> GetShellDescriptorByIdAsync([FromRoute] string aasIdentifier, CancellationToken cancellationToken)
6964
{
7065
logger.LogInformation("Get ShellDescriptor");
7166
var request = new GetShellDescriptorRequest(aasIdentifier);

source/AAS.TwinEngine.DataEngine/Api/AasRepository/AasRepositoryController.cs

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,7 @@ public class AasRepositoryController(
3939
[ProducesResponseType(typeof(ShellsDto), (int)HttpStatusCode.OK)]
4040
[ProducesResponseType(typeof(ServiceErrorResponse), (int)HttpStatusCode.BadRequest)]
4141
[ProducesResponseType(typeof(ServiceErrorResponse), (int)HttpStatusCode.InternalServerError)]
42-
public async Task<ActionResult<ShellsDto>> GetShellsByAssetIdAsync(
43-
[FromQuery] string[]? assetIds,
44-
[FromQuery] int? limit,
45-
[FromQuery] string? cursor,
42+
public async Task<ActionResult<ShellsDto>> GetShellsByAssetIdAsync([FromQuery] string[]? assetIds, [FromQuery] int? limit, [FromQuery] string? cursor,
4643
CancellationToken cancellationToken)
4744
{
4845
logger.LogInformation("Start request to get shells by asset identifiers");
@@ -64,9 +61,7 @@ public async Task<ActionResult<ShellsDto>> GetShellsByAssetIdAsync(
6461
[ProducesResponseType(typeof(ServiceErrorResponse), (int)HttpStatusCode.BadRequest)]
6562
[ProducesResponseType(typeof(ServiceErrorResponse), (int)HttpStatusCode.NotFound)]
6663
[ProducesResponseType(typeof(ServiceErrorResponse), (int)HttpStatusCode.InternalServerError)]
67-
public async Task<ActionResult<JsonObject>> GetShellByIdAsync(
68-
[FromRoute] string aasIdentifier,
69-
CancellationToken cancellationToken)
64+
public async Task<ActionResult<JsonObject>> GetShellByIdAsync([FromRoute] string aasIdentifier, CancellationToken cancellationToken)
7065
{
7166
logger.LogInformation("Start request to get shell");
7267
var request = new GetShellRequest(aasIdentifier);
@@ -88,9 +83,7 @@ public async Task<ActionResult<JsonObject>> GetShellByIdAsync(
8883
[ProducesResponseType(typeof(ServiceErrorResponse), (int)HttpStatusCode.BadRequest)]
8984
[ProducesResponseType(typeof(ServiceErrorResponse), (int)HttpStatusCode.NotFound)]
9085
[ProducesResponseType(typeof(ServiceErrorResponse), (int)HttpStatusCode.InternalServerError)]
91-
public async Task<ActionResult<JsonObject>> GetAssetInformationByIdAsync(
92-
[FromRoute] string aasIdentifier,
93-
CancellationToken cancellationToken)
86+
public async Task<ActionResult<JsonObject>> GetAssetInformationByIdAsync([FromRoute] string aasIdentifier, CancellationToken cancellationToken)
9487
{
9588
logger.LogInformation("Start request to get asset information");
9689
var request = new GetAssetInformationRequest(aasIdentifier);
@@ -114,11 +107,7 @@ public async Task<ActionResult<JsonObject>> GetAssetInformationByIdAsync(
114107
[ProducesResponseType(typeof(ServiceErrorResponse), (int)HttpStatusCode.BadRequest)]
115108
[ProducesResponseType(typeof(ServiceErrorResponse), (int)HttpStatusCode.NotFound)]
116109
[ProducesResponseType(typeof(ServiceErrorResponse), (int)HttpStatusCode.InternalServerError)]
117-
public async Task<ActionResult<SubmodelRefDto>> GetSubmodelRefByIdAsync(
118-
[FromRoute] string aasIdentifier,
119-
[FromQuery] int? limit,
120-
[FromQuery] string? cursor,
121-
CancellationToken cancellationToken)
110+
public async Task<ActionResult<JsonObject>> GetSubmodelRefByIdAsync([FromRoute] string aasIdentifier, [FromQuery] int? limit, [FromQuery] string? cursor, CancellationToken cancellationToken)
122111
{
123112
logger.LogInformation("Start request to get submodel-refs for shell");
124113
var request = new GetSubmodelRefRequest(aasIdentifier, limit, cursor);

source/AAS.TwinEngine.DataEngine/Api/Discovery/Requests/AssetLinkDto.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44

55
namespace AAS.TwinEngine.DataEngine.Api.Discovery.Requests;
66

7-
/// <summary>
8-
/// IDTA discovery asset link used to search for matching AAS identifiers.
9-
/// </summary>
107
public class AssetLinkDto
118
{
129
[JsonPropertyName("name")]
Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,9 @@
11
using System.Text.Json.Serialization;
2-
using System.ComponentModel;
32

43
namespace AAS.TwinEngine.DataEngine.Api.Shared;
54

6-
/// <summary>
7-
/// Cursor-based pagination metadata.
8-
/// </summary>
95
public class PagingMetaDataDto
106
{
11-
/// <summary>
12-
/// Opaque cursor token that can be used to request the next page.
13-
/// </summary>
14-
/// <example>eyJvZmZzZXQiOjEwMH0</example>
157
[JsonPropertyName("cursor")]
16-
[Description("Opaque cursor token for pagination continuation.")]
178
public string? Cursor { get; set; }
189
}

source/AAS.TwinEngine.DataEngine/Api/SubmodelRegistry/SubmodelDescriptorController.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ public class SubmodelDescriptorController(
3737
[ProducesResponseType(typeof(ServiceErrorResponse), (int)HttpStatusCode.BadRequest)]
3838
[ProducesResponseType(typeof(ServiceErrorResponse), (int)HttpStatusCode.NotFound)]
3939
[ProducesResponseType(typeof(ServiceErrorResponse), (int)HttpStatusCode.InternalServerError)]
40-
public async Task<ActionResult<SubmodelDescriptorDto>> GetSubmodelDescriptorByIdAsync(
41-
[FromRoute] string submodelIdentifier,
42-
CancellationToken cancellationToken)
40+
public async Task<ActionResult<SubmodelDescriptorDto>> GetSubmodelDescriptorByIdAsync([FromRoute] string submodelIdentifier, CancellationToken cancellationToken)
4341
{
4442
logger.LogInformation("Get Submodel Descriptor");
4543
var request = new GetSubmodelDescriptorRequest(submodelIdentifier);

source/AAS.TwinEngine.DataEngine/Api/SubmodelRepository/SubmodelRepositoryController.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.ComponentModel;
22
using System.Net;
3+
using System.Text.Json.Nodes;
34

45
using AAS.TwinEngine.DataEngine.Api.SubmodelRepository.Handler;
56
using AAS.TwinEngine.DataEngine.Api.SubmodelRepository.Requests;
@@ -37,9 +38,7 @@ public class SubmodelRepositoryController(
3738
[ProducesResponseType(typeof(ServiceErrorResponse), (int)HttpStatusCode.BadRequest)]
3839
[ProducesResponseType(typeof(ServiceErrorResponse), (int)HttpStatusCode.NotFound)]
3940
[ProducesResponseType(typeof(ServiceErrorResponse), (int)HttpStatusCode.InternalServerError)]
40-
public async Task<ActionResult<Submodel>> GetSubmodelAsync(
41-
[FromRoute] string submodelIdentifier,
42-
CancellationToken cancellationToken)
41+
public async Task<ActionResult<Submodel>> GetSubmodelAsync([FromRoute] string submodelIdentifier, CancellationToken cancellationToken)
4342
{
4443
logger.LogInformation("Get Submodel");
4544
var request = new GetSubmodelRequest(submodelIdentifier);
@@ -61,14 +60,11 @@ public async Task<ActionResult<Submodel>> GetSubmodelAsync(
6160
[ProducesResponseType(typeof(ServiceErrorResponse), (int)HttpStatusCode.BadRequest)]
6261
[ProducesResponseType(typeof(ServiceErrorResponse), (int)HttpStatusCode.NotFound)]
6362
[ProducesResponseType(typeof(ServiceErrorResponse), (int)HttpStatusCode.InternalServerError)]
64-
public async Task<ActionResult<ISubmodelElement>> GetSubmodelElementAsync(
65-
[FromRoute] string submodelIdentifier,
66-
[FromRoute] string idShortPath,
67-
CancellationToken cancellationToken)
63+
public async Task<ActionResult<JsonObject>> GetSubmodelElementAsync([FromRoute] string submodelIdentifier, [FromRoute] string idShortPath, CancellationToken cancellationToken)
6864
{
6965
logger.LogInformation("Get Submodel Element");
7066
var request = new GetSubmodelElementRequest(submodelIdentifier, idShortPath);
7167
var response = await submodelRepositoryHandler.GetSubmodelElement(request, cancellationToken).ConfigureAwait(false);
72-
return Ok(response);
68+
return Ok(Jsonization.Serialize.ToJsonObject(response));
7369
}
7470
}

source/AAS.TwinEngine.Plugin.TestPlugin/AAS.TwinEngine.Plugin.TestPlugin.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
<TargetFramework>net10.0</TargetFramework>
55
<Nullable>enable</Nullable>
66
<ImplicitUsings>enable</ImplicitUsings>
7-
<GenerateDocumentationFile>true</GenerateDocumentationFile>
8-
<NoWarn>$(NoWarn);1591</NoWarn>
97
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
108
<DockerfileContext>.</DockerfileContext>
119
<UserSecretsId>2ba5fa1c-2588-4655-bd1f-bc7cd274eba9</UserSecretsId>

0 commit comments

Comments
 (0)