Skip to content

Commit

Permalink
Fix nullable handling and issue #295 (#296)
Browse files Browse the repository at this point in the history
* update release note builde

* fix nullables and routing
  • Loading branch information
Freezor authored Jun 22, 2024
1 parent 6c81fe1 commit 9ab6300
Show file tree
Hide file tree
Showing 29 changed files with 159 additions and 165 deletions.
4 changes: 2 additions & 2 deletions .github/changelog_configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@
"order": "ASC",
"on_property": "mergedAt"
},
"template": "# 📦 Changelog\n\n#{{CHANGELOG}}\n\n#{{UNCATEGORIZED}}\n\n# Full Changelog\n[🔗 Release Diff](#{{RELEASE_DIFF}})\n\n# 👥 New Contributors\n\nMust be added manually.",
"template": "# 📦 Changelog\n\n#{{CHANGELOG}}\n\n#{{UNCATEGORIZED}}\n\n# Full Changelog\n[🔗 Release Diff](#{{RELEASE_DIFF}})\n\n# 👥Contributors\n\n ",
"pr_template": "- #{{TITLE}} by @#{{AUTHOR}} in #{{URL}}",
"empty_template": "No changes detected. See the [Changelog](CHANGELOG.md) for more information.",
"empty_template": "No changes detected. See the [Changelog](CHANGELOG.md) or [Release Diff](#{{RELEASE_DIFF}}) for more information.",
"label_extractor": [
{
"pattern": "(.*)",
Expand Down
2 changes: 1 addition & 1 deletion src/IO.Swagger.Lib.V3/Controllers/AASXFileServerAPIApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public AASXFileServerAPIApiController(IAppLogger<AASXFileServerAPIApiController>
_decoderService = decoderService ?? throw new ArgumentNullException(nameof(decoderService)); ;
_fileService = fileService ?? throw new ArgumentNullException(nameof(fileService));
_paginationService = paginationService ?? throw new ArgumentNullException(nameof(paginationService));
_authorizationService = authorizationService ?? throw new ArgumentNullException(nameof(paginationService));
_authorizationService = authorizationService ?? throw new ArgumentNullException(nameof(authorizationService));
}
/// <summary>
/// Deletes a specific AASX package from the server
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,6 @@ public virtual IActionResult DeleteThumbnailAasRepository([FromRoute] [Required]
[SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")]
[SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")]
// TODO (jtikekar, 2023-09-04): assetIds: string or specific asset id, and what about Base64Uel encoding
//public virtual IActionResult GetAllAssetAdministrationShells([FromQuery] List<string> assetIds, [FromQuery] string idShort, [FromQuery] int? limit, [FromQuery] string cursor)
public virtual IActionResult GetAllAssetAdministrationShells([FromQuery] List<SpecificAssetId>? assetIds, [FromQuery] string? idShort, [FromQuery] int? limit,
[FromQuery] string? cursor)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public ConceptDescriptionRepositoryAPIApiController(IAppLogger<ConceptDescriptio
_cdService = cdService ?? throw new ArgumentNullException(nameof(cdService));
_jsonQueryDeserializer = jsonQueryDeserializer ?? throw new ArgumentNullException(nameof(jsonQueryDeserializer));
_paginationService = paginationService ?? throw new ArgumentNullException(nameof(paginationService));
_authorizationService = authorizationService ?? throw new ArgumentNullException(nameof(paginationService));
_authorizationService = authorizationService ?? throw new ArgumentNullException(nameof(authorizationService));
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions src/IO.Swagger.Lib.V3/Controllers/SubmodelRepositoryAPIApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ public SubmodelRepositoryAPIApiController(IAppLogger<SubmodelRepositoryAPIApiCon
_jsonQueryDeserializer = jsonQueryDeserializer ?? throw new ArgumentNullException(nameof(jsonQueryDeserializer));
_mappingService = mappingService ?? throw new ArgumentNullException(nameof(mappingService));
_pathModifierService = pathModifierService ?? throw new ArgumentNullException(nameof(pathModifierService));
_levelExtentModifierService = levelExtentModifierService ?? throw new ArgumentNullException(nameof(pathModifierService));
_paginationService = paginationService ?? throw new ArgumentNullException(nameof(pathModifierService));
_levelExtentModifierService = levelExtentModifierService ?? throw new ArgumentNullException(nameof(levelExtentModifierService));
_paginationService = paginationService ?? throw new ArgumentNullException(nameof(paginationService));
_authorizationService = authorizationService ?? throw new ArgumentNullException(nameof(authorizationService));
}

Expand Down
16 changes: 9 additions & 7 deletions src/IO.Swagger.Lib.V3/Filters/BasePathFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,21 @@ public BasePathFilter(string basePath)
/// <param name="context">FilterContext</param>
public void Apply(OpenApiDocument swaggerDoc, DocumentFilterContext context)
{
swaggerDoc.Servers.Add(new OpenApiServer() { Url = this.BasePath });
swaggerDoc.Servers.Add(new OpenApiServer() {Url = BasePath});

var pathsToModify = swaggerDoc.Paths.Where(p => p.Key.StartsWith(this.BasePath)).ToList();
var pathsToModify = swaggerDoc.Paths.Where(p => p.Key.StartsWith(BasePath)).ToList();

foreach (var path in pathsToModify)
{
if (path.Key.StartsWith(this.BasePath))
if (!path.Key.StartsWith(BasePath))
{
string newKey = Regex.Replace(path.Key, $"^{this.BasePath}", string.Empty);
swaggerDoc.Paths.Remove(path.Key);
swaggerDoc.Paths.Add(newKey, path.Value);
continue;
}

var newKey = Regex.Replace(path.Key, $"^{BasePath}", string.Empty);
swaggerDoc.Paths.Remove(path.Key);
swaggerDoc.Paths.Add(newKey, path.Value);
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,8 @@ public void Apply(OpenApiOperation operation, OperationFilterContext context)
var regexAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RegularExpressionAttribute));
if (regexAttr != null)
{
string regex = (string)regexAttr.ConstructorArguments[0].Value;
if (swaggerParam is OpenApiParameter)
{
((OpenApiParameter)swaggerParam).Schema.Pattern = regex;
}
var regex = (string)regexAttr.ConstructorArguments[0].Value;
swaggerParam.Schema.Pattern = regex;
}

// String Length [StringLength]
Expand Down Expand Up @@ -83,11 +80,8 @@ public void Apply(OpenApiOperation operation, OperationFilterContext context)
var rangeMin = (int)(rangeAttr.ConstructorArguments[0].Value ?? 0);
var rangeMax = (int)(rangeAttr.ConstructorArguments[1].Value ?? 1);

if (swaggerParam is OpenApiParameter)
{
((OpenApiParameter)swaggerParam).Schema.Minimum = rangeMin;
((OpenApiParameter)swaggerParam).Schema.Maximum = rangeMax;
}
swaggerParam.Schema.Minimum = rangeMin;
swaggerParam.Schema.Maximum = rangeMax;
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/IO.Swagger.Lib.V3/Formatters/AasRequestFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public class AasRequestFormatter : InputFormatter
{
public AasRequestFormatter()
{
this.SupportedMediaTypes.Clear();
this.SupportedMediaTypes.Add(MediaTypeHeaderValue.Parse("application/json"));
SupportedMediaTypes.Clear();
SupportedMediaTypes.Add(MediaTypeHeaderValue.Parse("application/json"));
}

public override bool CanRead(InputFormatterContext context)
Expand Down
4 changes: 2 additions & 2 deletions src/IO.Swagger.Lib.V3/Formatters/AasResponseFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public class AasResponseFormatter : OutputFormatter
{
public AasResponseFormatter()
{
this.SupportedMediaTypes.Clear();
this.SupportedMediaTypes.Add(MediaTypeHeaderValue.Parse("application/json"));
SupportedMediaTypes.Clear();
SupportedMediaTypes.Add(MediaTypeHeaderValue.Parse("application/json"));
}
public static bool IsGenericListOfIClass(object o)
{
Expand Down
12 changes: 6 additions & 6 deletions src/IO.Swagger.Lib.V3/Models/BaseOperationResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ public bool Equals(BaseOperationResult? other)
return
(
ExecutionState == other.ExecutionState ||
ExecutionState != null &&
ExecutionState.Equals(other.ExecutionState)
(ExecutionState != null &&
ExecutionState.Equals(other.ExecutionState))
) &&
(
Success == other.Success ||
Success != null &&
Success.Equals(other.Success)
(Success != null &&
Success.Equals(other.Success))
);
}

Expand All @@ -110,9 +110,9 @@ public override int GetHashCode()
var hashCode = 41;
// Suitable nullity checks etc, of course :)
if (ExecutionState != null)
hashCode = hashCode * 59 + ExecutionState.GetHashCode();
hashCode = (hashCode * 59) + ExecutionState.GetHashCode();
if (Success != null)
hashCode = hashCode * 59 + Success.GetHashCode();
hashCode = (hashCode * 59) + Success.GetHashCode();
return hashCode;
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/IO.Swagger.Lib.V3/Models/Description.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ public bool Equals(Description? other)
return
(
Profiles == other.Profiles ||
Profiles != null &&
Profiles.SequenceEqual(other.Profiles)
(Profiles != null &&
Profiles.SequenceEqual(other.Profiles))
);
}

Expand All @@ -184,7 +184,7 @@ public override int GetHashCode()
var hashCode = 41;
// Suitable nullity checks etc, of course :)
if (Profiles != null)
hashCode = hashCode * 59 + Profiles.GetHashCode();
hashCode = (hashCode * 59) + Profiles.GetHashCode();
return hashCode;
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/IO.Swagger.Lib.V3/Models/GetPathItemsResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ public bool Equals(GetPathItemsResult? other)
return
(
Result == other.Result ||
Result != null &&
Result.SequenceEqual(other.Result)
(Result != null &&
Result.SequenceEqual(other.Result))
);
}

Expand All @@ -89,7 +89,7 @@ public override int GetHashCode()
var hashCode = 41;
// Suitable nullity checks etc, of course :)
if (Result != null)
hashCode = hashCode * 59 + Result.GetHashCode();
hashCode = (hashCode * 59) + Result.GetHashCode();
return hashCode;
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/IO.Swagger.Lib.V3/Models/GetReferencesResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ public bool Equals(GetReferencesResult? other)
return
(
Result == other.Result ||
Result != null &&
Result.SequenceEqual(other.Result)
(Result != null &&
Result.SequenceEqual(other.Result))
);
}

Expand All @@ -89,7 +89,7 @@ public override int GetHashCode()
var hashCode = 41;
// Suitable nullity checks etc, of course :)
if (Result != null)
hashCode = hashCode * 59 + Result.GetHashCode();
hashCode = (hashCode * 59) + Result.GetHashCode();
return hashCode;
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/IO.Swagger.Lib.V3/Models/GetSubmodelElementsResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ public bool Equals(GetSubmodelElementsResult? other)
return
(
Result == other.Result ||
Result != null &&
Result.SequenceEqual(other.Result)
(Result != null &&
Result.SequenceEqual(other.Result))
);
}

Expand All @@ -89,7 +89,7 @@ public override int GetHashCode()
var hashCode = 41;
// Suitable nullity checks etc, of course :)
if (Result != null)
hashCode = hashCode * 59 + Result.GetHashCode();
hashCode = (hashCode * 59) + Result.GetHashCode();
return hashCode;
}
}
Expand Down
30 changes: 16 additions & 14 deletions src/IO.Swagger.Lib.V3/Models/OperationRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* The entire Repository Service Specification as part of Details of the Asset Administration Shell Part 2
*
* OpenAPI spec version: V3.0
*
*
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/

Expand Down Expand Up @@ -103,23 +103,23 @@ public bool Equals(OperationRequest? other)
return
(
InoutputArguments == other.InoutputArguments ||
InoutputArguments != null &&
InoutputArguments.SequenceEqual(other.InoutputArguments)
(InoutputArguments != null &&
InoutputArguments.SequenceEqual(other.InoutputArguments))
) &&
(
InputArguments == other.InputArguments ||
InputArguments != null &&
InputArguments.SequenceEqual(other.InputArguments)
(InputArguments != null &&
InputArguments.SequenceEqual(other.InputArguments))
) &&
(
RequestId == other.RequestId ||
RequestId != null &&
RequestId.Equals(other.RequestId)
(RequestId != null &&
RequestId.Equals(other.RequestId))
) &&
(
Timeout == other.Timeout ||
Timeout != null &&
Timeout.Equals(other.Timeout)
(Timeout != null &&
Timeout.Equals(other.Timeout))
);
}

Expand All @@ -134,18 +134,19 @@ public override int GetHashCode()
var hashCode = 41;
// Suitable nullity checks etc, of course :)
if (InoutputArguments != null)
hashCode = hashCode * 59 + InoutputArguments.GetHashCode();
hashCode = (hashCode * 59) + InoutputArguments.GetHashCode();
if (InputArguments != null)
hashCode = hashCode * 59 + InputArguments.GetHashCode();
hashCode = (hashCode * 59) + InputArguments.GetHashCode();
if (RequestId != null)
hashCode = hashCode * 59 + RequestId.GetHashCode();
hashCode = (hashCode * 59) + RequestId.GetHashCode();
if (Timeout != null)
hashCode = hashCode * 59 + Timeout.GetHashCode();
hashCode = hashCode * 0x3B + Timeout.GetHashCode();
return hashCode;
}
}

#region Operators

#pragma warning disable 1591

public static bool operator ==(OperationRequest left, OperationRequest right)
Expand All @@ -159,6 +160,7 @@ public override int GetHashCode()
}

#pragma warning restore 1591

#endregion Operators
}
}
}
30 changes: 15 additions & 15 deletions src/IO.Swagger.Lib.V3/Models/OperationResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,28 +111,28 @@ public bool Equals(OperationResult? other)
return
(
ExecutionResult == other.ExecutionResult ||
ExecutionResult != null &&
ExecutionResult.Equals(other.ExecutionResult)
(ExecutionResult != null &&
ExecutionResult.Equals(other.ExecutionResult))
) &&
(
ExecutionState == other.ExecutionState ||
ExecutionState != null &&
ExecutionState.Equals(other.ExecutionState)
(ExecutionState != null &&
ExecutionState.Equals(other.ExecutionState))
) &&
(
InoutputArguments == other.InoutputArguments ||
InoutputArguments != null &&
InoutputArguments.SequenceEqual(other.InoutputArguments)
(InoutputArguments != null &&
InoutputArguments.SequenceEqual(other.InoutputArguments))
) &&
(
OutputArguments == other.OutputArguments ||
OutputArguments != null &&
OutputArguments.SequenceEqual(other.OutputArguments)
(OutputArguments != null &&
OutputArguments.SequenceEqual(other.OutputArguments))
) &&
(
RequestId == other.RequestId ||
RequestId != null &&
RequestId.Equals(other.RequestId)
(RequestId != null &&
RequestId.Equals(other.RequestId))
);
}

Expand All @@ -147,15 +147,15 @@ public override int GetHashCode()
var hashCode = 41;
// Suitable nullity checks etc, of course :)
if (ExecutionResult != null)
hashCode = hashCode * 59 + ExecutionResult.GetHashCode();
hashCode = (hashCode * 59) + ExecutionResult.GetHashCode();
if (ExecutionState != null)
hashCode = hashCode * 59 + ExecutionState.GetHashCode();
hashCode = (hashCode * 59) + ExecutionState.GetHashCode();
if (InoutputArguments != null)
hashCode = hashCode * 59 + InoutputArguments.GetHashCode();
hashCode = (hashCode * 59) + InoutputArguments.GetHashCode();
if (OutputArguments != null)
hashCode = hashCode * 59 + OutputArguments.GetHashCode();
hashCode = (hashCode * 59) + OutputArguments.GetHashCode();
if (RequestId != null)
hashCode = hashCode * 59 + RequestId.GetHashCode();
hashCode = (hashCode * 59) + RequestId.GetHashCode();
return hashCode;
}
}
Expand Down
10 changes: 4 additions & 6 deletions src/IO.Swagger.Lib.V3/Models/Result.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,9 @@ public bool Equals(Result? other)
if (ReferenceEquals(this, other)) return true;

return
(
Messages == other.Messages ||
Messages != null &&
Messages.SequenceEqual(other.Messages)
);
Messages == other.Messages ||
(Messages != null &&
Messages.SequenceEqual(other.Messages));
}

/// <summary>
Expand All @@ -93,7 +91,7 @@ public override int GetHashCode()
var hashCode = 41;
// Suitable nullity checks etc, of course :)
if (Messages != null)
hashCode = hashCode * 59 + Messages.GetHashCode();
hashCode = (hashCode * 59) + Messages.GetHashCode();
return hashCode;
}
}
Expand Down
Loading

0 comments on commit 9ab6300

Please sign in to comment.