diff --git a/.github/changelog_configuration.json b/.github/changelog_configuration.json index f80a850b5..eb4c6d739 100644 --- a/.github/changelog_configuration.json +++ b/.github/changelog_configuration.json @@ -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": "(.*)", diff --git a/src/IO.Swagger.Lib.V3/Controllers/AASXFileServerAPIApi.cs b/src/IO.Swagger.Lib.V3/Controllers/AASXFileServerAPIApi.cs index 6fe7849af..7dd840de5 100644 --- a/src/IO.Swagger.Lib.V3/Controllers/AASXFileServerAPIApi.cs +++ b/src/IO.Swagger.Lib.V3/Controllers/AASXFileServerAPIApi.cs @@ -45,7 +45,7 @@ public AASXFileServerAPIApiController(IAppLogger _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)); } /// /// Deletes a specific AASX package from the server diff --git a/src/IO.Swagger.Lib.V3/Controllers/AssetAdministrationShellRepositoryAPIApi.cs b/src/IO.Swagger.Lib.V3/Controllers/AssetAdministrationShellRepositoryAPIApi.cs index 2eb966e59..29f5dc774 100644 --- a/src/IO.Swagger.Lib.V3/Controllers/AssetAdministrationShellRepositoryAPIApi.cs +++ b/src/IO.Swagger.Lib.V3/Controllers/AssetAdministrationShellRepositoryAPIApi.cs @@ -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 assetIds, [FromQuery] string idShort, [FromQuery] int? limit, [FromQuery] string cursor) public virtual IActionResult GetAllAssetAdministrationShells([FromQuery] List? assetIds, [FromQuery] string? idShort, [FromQuery] int? limit, [FromQuery] string? cursor) { diff --git a/src/IO.Swagger.Lib.V3/Controllers/ConceptDescriptionRepositoryAPIApi.cs b/src/IO.Swagger.Lib.V3/Controllers/ConceptDescriptionRepositoryAPIApi.cs index e5e72e732..9b4e0616f 100644 --- a/src/IO.Swagger.Lib.V3/Controllers/ConceptDescriptionRepositoryAPIApi.cs +++ b/src/IO.Swagger.Lib.V3/Controllers/ConceptDescriptionRepositoryAPIApi.cs @@ -48,7 +48,7 @@ public ConceptDescriptionRepositoryAPIApiController(IAppLogger diff --git a/src/IO.Swagger.Lib.V3/Controllers/SubmodelRepositoryAPIApi.cs b/src/IO.Swagger.Lib.V3/Controllers/SubmodelRepositoryAPIApi.cs index e31aa066d..2b649bcca 100644 --- a/src/IO.Swagger.Lib.V3/Controllers/SubmodelRepositoryAPIApi.cs +++ b/src/IO.Swagger.Lib.V3/Controllers/SubmodelRepositoryAPIApi.cs @@ -66,8 +66,8 @@ public SubmodelRepositoryAPIApiController(IAppLoggerFilterContext 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); } } } -} +} \ No newline at end of file diff --git a/src/IO.Swagger.Lib.V3/Filters/GeneratePathParamsValidationFilter.cs b/src/IO.Swagger.Lib.V3/Filters/GeneratePathParamsValidationFilter.cs index 60bf7bc38..a4be685f4 100644 --- a/src/IO.Swagger.Lib.V3/Filters/GeneratePathParamsValidationFilter.cs +++ b/src/IO.Swagger.Lib.V3/Filters/GeneratePathParamsValidationFilter.cs @@ -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] @@ -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; } } } diff --git a/src/IO.Swagger.Lib.V3/Formatters/AasRequestFormatter.cs b/src/IO.Swagger.Lib.V3/Formatters/AasRequestFormatter.cs index 3b1100a66..3cefac9a6 100644 --- a/src/IO.Swagger.Lib.V3/Formatters/AasRequestFormatter.cs +++ b/src/IO.Swagger.Lib.V3/Formatters/AasRequestFormatter.cs @@ -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) diff --git a/src/IO.Swagger.Lib.V3/Formatters/AasResponseFormatter.cs b/src/IO.Swagger.Lib.V3/Formatters/AasResponseFormatter.cs index 15f81943c..003710905 100644 --- a/src/IO.Swagger.Lib.V3/Formatters/AasResponseFormatter.cs +++ b/src/IO.Swagger.Lib.V3/Formatters/AasResponseFormatter.cs @@ -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) { diff --git a/src/IO.Swagger.Lib.V3/Models/BaseOperationResult.cs b/src/IO.Swagger.Lib.V3/Models/BaseOperationResult.cs index a2376da19..08c5dbc2d 100644 --- a/src/IO.Swagger.Lib.V3/Models/BaseOperationResult.cs +++ b/src/IO.Swagger.Lib.V3/Models/BaseOperationResult.cs @@ -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)) ); } @@ -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; } } diff --git a/src/IO.Swagger.Lib.V3/Models/Description.cs b/src/IO.Swagger.Lib.V3/Models/Description.cs index 288cc4368..e4ed0b06f 100644 --- a/src/IO.Swagger.Lib.V3/Models/Description.cs +++ b/src/IO.Swagger.Lib.V3/Models/Description.cs @@ -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)) ); } @@ -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; } } diff --git a/src/IO.Swagger.Lib.V3/Models/GetPathItemsResult.cs b/src/IO.Swagger.Lib.V3/Models/GetPathItemsResult.cs index a234d3f2e..11c8b898d 100644 --- a/src/IO.Swagger.Lib.V3/Models/GetPathItemsResult.cs +++ b/src/IO.Swagger.Lib.V3/Models/GetPathItemsResult.cs @@ -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)) ); } @@ -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; } } diff --git a/src/IO.Swagger.Lib.V3/Models/GetReferencesResult.cs b/src/IO.Swagger.Lib.V3/Models/GetReferencesResult.cs index ddefda053..7808650f2 100644 --- a/src/IO.Swagger.Lib.V3/Models/GetReferencesResult.cs +++ b/src/IO.Swagger.Lib.V3/Models/GetReferencesResult.cs @@ -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)) ); } @@ -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; } } diff --git a/src/IO.Swagger.Lib.V3/Models/GetSubmodelElementsResult.cs b/src/IO.Swagger.Lib.V3/Models/GetSubmodelElementsResult.cs index 7341c769c..947a3a6d9 100644 --- a/src/IO.Swagger.Lib.V3/Models/GetSubmodelElementsResult.cs +++ b/src/IO.Swagger.Lib.V3/Models/GetSubmodelElementsResult.cs @@ -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)) ); } @@ -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; } } diff --git a/src/IO.Swagger.Lib.V3/Models/OperationRequest.cs b/src/IO.Swagger.Lib.V3/Models/OperationRequest.cs index 5c4b7a0ce..0b41b731d 100644 --- a/src/IO.Swagger.Lib.V3/Models/OperationRequest.cs +++ b/src/IO.Swagger.Lib.V3/Models/OperationRequest.cs @@ -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 */ @@ -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)) ); } @@ -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) @@ -159,6 +160,7 @@ public override int GetHashCode() } #pragma warning restore 1591 + #endregion Operators } -} +} \ No newline at end of file diff --git a/src/IO.Swagger.Lib.V3/Models/OperationResult.cs b/src/IO.Swagger.Lib.V3/Models/OperationResult.cs index 97f070e45..6422f1023 100644 --- a/src/IO.Swagger.Lib.V3/Models/OperationResult.cs +++ b/src/IO.Swagger.Lib.V3/Models/OperationResult.cs @@ -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)) ); } @@ -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; } } diff --git a/src/IO.Swagger.Lib.V3/Models/Result.cs b/src/IO.Swagger.Lib.V3/Models/Result.cs index 903181d4e..b1af01fc9 100644 --- a/src/IO.Swagger.Lib.V3/Models/Result.cs +++ b/src/IO.Swagger.Lib.V3/Models/Result.cs @@ -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)); } /// @@ -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; } } diff --git a/src/IO.Swagger.Lib.V3/Models/ServiceDescription.cs b/src/IO.Swagger.Lib.V3/Models/ServiceDescription.cs index 9752810fd..d3ec92805 100644 --- a/src/IO.Swagger.Lib.V3/Models/ServiceDescription.cs +++ b/src/IO.Swagger.Lib.V3/Models/ServiceDescription.cs @@ -174,8 +174,8 @@ public bool Equals(ServiceDescription? other) return Profiles == other.Profiles || - Profiles != null && - Profiles.SequenceEqual(other.Profiles) + (Profiles != null && + Profiles.SequenceEqual(other.Profiles)) ; } @@ -188,9 +188,9 @@ public override int GetHashCode() unchecked // Overflow is fine, just wrap { var hashCode = 41; - // Suitable nullity checks etc, of course :) + // Suitable nullity checks etc., of course :) if (Profiles != null) - hashCode = hashCode * 59 + Profiles.GetHashCode(); + hashCode = (hashCode * 59) + Profiles.GetHashCode(); return hashCode; } } diff --git a/src/IO.Swagger.Lib.V3/SerializationModifiers/Mappers/MetadataMappers/RequestMetadataMapper.cs b/src/IO.Swagger.Lib.V3/SerializationModifiers/Mappers/MetadataMappers/RequestMetadataMapper.cs index 6570d2a93..033591d89 100644 --- a/src/IO.Swagger.Lib.V3/SerializationModifiers/Mappers/MetadataMappers/RequestMetadataMapper.cs +++ b/src/IO.Swagger.Lib.V3/SerializationModifiers/Mappers/MetadataMappers/RequestMetadataMapper.cs @@ -46,7 +46,7 @@ public static class RequestMetadataMapper } - private static IEntity? Transform(EntityMetadata metadata) + private static IEntity Transform(EntityMetadata metadata) { List statements = null; if (metadata.statements != null) @@ -64,7 +64,7 @@ public static class RequestMetadataMapper TransformEmbeddedDataSpecList(metadata.embeddedDataSpecifications), statements); } - private static IAnnotatedRelationshipElement? Transform(AnnotatedRelationshipElementMetadata metadata) + private static IAnnotatedRelationshipElement Transform(AnnotatedRelationshipElementMetadata metadata) { List annotations = null; if (metadata.annotations != null) @@ -82,7 +82,7 @@ public static class RequestMetadataMapper TransformQualifierList(metadata.qualifiers), TransformEmbeddedDataSpecList(metadata.embeddedDataSpecifications), annotations); } - private static ISubmodelElementList? Transform(SubmodelElementListMetadata metadata) + private static ISubmodelElementList Transform(SubmodelElementListMetadata metadata) { List value = null; if (metadata.value != null) @@ -101,7 +101,7 @@ public static class RequestMetadataMapper TransformReference(metadata.semanticIdListElement), metadata.valueTypeListElement, value); } - private static ISubmodelElementCollection? Transform(SubmodelElementCollectionMetadata metadata) + private static ISubmodelElementCollection Transform(SubmodelElementCollectionMetadata metadata) { List value = null; if (metadata.value != null) @@ -119,7 +119,7 @@ public static class RequestMetadataMapper TransformQualifierList(metadata.qualifiers), TransformEmbeddedDataSpecList(metadata.embeddedDataSpecifications), value); } - private static IRelationshipElement? Transform(RelationshipElementMetadata metadata) + private static IRelationshipElement Transform(RelationshipElementMetadata metadata) { return new RelationshipElement(null, null, TransformExtensions(metadata.extensions), metadata.category, metadata.idShort, TransformLangStringNameTypeList(metadata.displayName), TransformLangStringTextTypeList(metadata.description), @@ -127,7 +127,7 @@ public static class RequestMetadataMapper TransformQualifierList(metadata.qualifiers), TransformEmbeddedDataSpecList(metadata.embeddedDataSpecifications)); } - private static IReferenceElement? Transform(ReferenceElementMetadata metadata) + private static IReferenceElement Transform(ReferenceElementMetadata metadata) { return new ReferenceElement(TransformExtensions(metadata.extensions), metadata.category, metadata.idShort, TransformLangStringNameTypeList(metadata.displayName), TransformLangStringTextTypeList(metadata.description), TransformReference(metadata.semanticId), @@ -135,7 +135,7 @@ public static class RequestMetadataMapper TransformEmbeddedDataSpecList(metadata.embeddedDataSpecifications)); } - private static IRange? Transform(RangeMetadata metadata) + private static IRange Transform(RangeMetadata metadata) { return new AasCore.Aas3_0.Range(metadata.valueType, TransformExtensions(metadata.extensions), metadata.category, metadata.idShort, TransformLangStringNameTypeList(metadata.displayName), TransformLangStringTextTypeList(metadata.description), @@ -143,7 +143,7 @@ public static class RequestMetadataMapper TransformQualifierList(metadata.qualifiers), TransformEmbeddedDataSpecList(metadata.embeddedDataSpecifications)); } - private static IFile? Transform(FileMetadata metadata) + private static IFile Transform(FileMetadata metadata) { return new File(null, TransformExtensions(metadata.extensions), metadata.category, metadata.idShort, TransformLangStringNameTypeList(metadata.displayName), TransformLangStringTextTypeList(metadata.description), TransformReference(metadata.semanticId), @@ -151,7 +151,7 @@ public static class RequestMetadataMapper TransformEmbeddedDataSpecList(metadata.embeddedDataSpecifications)); } - private static IBlob? Transform(BlobMetadata metadata) + private static IBlob Transform(BlobMetadata metadata) { return new Blob(null, TransformExtensions(metadata.extensions), metadata.category, metadata.idShort, TransformLangStringNameTypeList(metadata.displayName), TransformLangStringTextTypeList(metadata.description), TransformReference(metadata.semanticId), @@ -159,7 +159,7 @@ public static class RequestMetadataMapper TransformEmbeddedDataSpecList(metadata.embeddedDataSpecifications)); } - private static IBasicEventElement? Transform(BasicEventElementMetadata metadata) + private static IBasicEventElement Transform(BasicEventElementMetadata metadata) { return new BasicEventElement(null, metadata.direction, metadata.state, TransformExtensions(metadata.extensions), metadata.category, metadata.idShort, TransformLangStringNameTypeList(metadata.displayName), TransformLangStringTextTypeList(metadata.description), @@ -168,7 +168,7 @@ public static class RequestMetadataMapper TransformReference(metadata.messageBroker), metadata.lastUpdate, metadata.minInterval, metadata.maxInterval); } - private static IMultiLanguageProperty? Transform(MultiLanguagePropertyMetadata multiLanguagePropertyMetadata) => + private static IMultiLanguageProperty Transform(MultiLanguagePropertyMetadata multiLanguagePropertyMetadata) => new MultiLanguageProperty(TransformExtensions(multiLanguagePropertyMetadata.extensions), multiLanguagePropertyMetadata.category, multiLanguagePropertyMetadata.idShort, TransformLangStringNameTypeList(multiLanguagePropertyMetadata.displayName), TransformLangStringTextTypeList(multiLanguagePropertyMetadata.description), @@ -177,7 +177,7 @@ public static class RequestMetadataMapper TransformQualifierList(multiLanguagePropertyMetadata.qualifiers), TransformEmbeddedDataSpecList(multiLanguagePropertyMetadata.embeddedDataSpecifications)); - private static IProperty? Transform(PropertyMetadata propertyMetadata) => + private static IProperty Transform(PropertyMetadata propertyMetadata) => new Property(propertyMetadata.valueType, TransformExtensions(propertyMetadata.extensions), propertyMetadata.category, propertyMetadata.idShort, TransformLangStringNameTypeList(propertyMetadata.displayName), TransformLangStringTextTypeList(propertyMetadata.description), TransformReference(propertyMetadata.semanticId), TransformReferenceList(propertyMetadata.supplementalSemanticIds), @@ -207,8 +207,15 @@ private static List TransformReferenceList(List refere return references.Select(reference => TransformReference(reference)).ToList(); } - private static IReference TransformReference(ReferenceDTO referenceDTO) => - new Reference(referenceDTO.type, TransformKeys(referenceDTO.keys), TransformReference(referenceDTO.referredSemanticId)); + private static IReference TransformReference(ReferenceDTO referenceDTO) + { + var transformedKeys = TransformKeys(referenceDTO.keys); + var transformedSemanticId = referenceDTO.referredSemanticId != null ? + TransformReference(referenceDTO.referredSemanticId) : + null; + + return new Reference(referenceDTO.type, transformedKeys, transformedSemanticId); + } private static List? TransformKeys(List? keys) => keys?.Select(key => new Key(key.type, key.value)).Cast().ToList(); diff --git a/src/IO.Swagger.Lib.V3/SerializationModifiers/Mappers/MetadataMappers/ResponseMetadataMapper.cs b/src/IO.Swagger.Lib.V3/SerializationModifiers/Mappers/MetadataMappers/ResponseMetadataMapper.cs index ecfc23279..1541bd81a 100644 --- a/src/IO.Swagger.Lib.V3/SerializationModifiers/Mappers/MetadataMappers/ResponseMetadataMapper.cs +++ b/src/IO.Swagger.Lib.V3/SerializationModifiers/Mappers/MetadataMappers/ResponseMetadataMapper.cs @@ -1,14 +1,9 @@ using DataTransferObjects; -namespace IO.Swagger.Lib.V3.SerializationModifiers.Mappers.MetadataMappers -{ - public class ResponseMetadataMapper - { - private static ResponseMetadataTransformer Transformer = new ResponseMetadataTransformer(); +namespace IO.Swagger.Lib.V3.SerializationModifiers.Mappers.MetadataMappers; - public static IDTO? Map(IClass source) - { - return Transformer.Transform(source); - } - } -} +public class ResponseMetadataMapper +{ + private static ResponseMetadataTransformer Transformer = new(); + public static IDTO Map(IClass source) => Transformer.Transform(source); +} \ No newline at end of file diff --git a/src/IO.Swagger.Lib.V3/SerializationModifiers/Mappers/MetadataMappers/ResponseMetadataTransformer.cs b/src/IO.Swagger.Lib.V3/SerializationModifiers/Mappers/MetadataMappers/ResponseMetadataTransformer.cs index 0e2cd4223..f850588e5 100644 --- a/src/IO.Swagger.Lib.V3/SerializationModifiers/Mappers/MetadataMappers/ResponseMetadataTransformer.cs +++ b/src/IO.Swagger.Lib.V3/SerializationModifiers/Mappers/MetadataMappers/ResponseMetadataTransformer.cs @@ -215,7 +215,7 @@ public IDTO TransformOperation(IOperation that) TransformEmbeddedDataSpecList(that.EmbeddedDataSpecifications), inputVarMetadataList, outputVarMetadataList, inOutVarMetadataList); } - public IDTO? TransformOperationVariable(IOperationVariable that) => Transform(that.Value); + public IDTO TransformOperationVariable(IOperationVariable that) => Transform(that.Value); public IDTO TransformProperty(IProperty that) => new PropertyMetadata(that.ValueType, TransformExtensionList(that.Extensions), that.Category, that.IdShort, TransformLangStringNameTypeList(that.DisplayName), diff --git a/src/IO.Swagger.Lib.V3/SerializationModifiers/Mappers/ValueMappers/RequestValueMapper.cs b/src/IO.Swagger.Lib.V3/SerializationModifiers/Mappers/ValueMappers/RequestValueMapper.cs index 75b908dd7..f2060d15a 100644 --- a/src/IO.Swagger.Lib.V3/SerializationModifiers/Mappers/ValueMappers/RequestValueMapper.cs +++ b/src/IO.Swagger.Lib.V3/SerializationModifiers/Mappers/ValueMappers/RequestValueMapper.cs @@ -92,12 +92,12 @@ private static IClass Transform(SubmodelValue valueDTO) return new Submodel(null, submodelElements: submodelElements); } - private static IClass? Transform(RangeValue valueDTO) + private static IClass Transform(RangeValue valueDTO) { return new AasCore.Aas3_0.Range(DataTypeDefXsd.String, idShort: valueDTO.idShort, min: valueDTO.min, max: valueDTO.max); } - private static IClass? Transform(SubmodelElementListValue valueDTO) + private static IClass Transform(SubmodelElementListValue valueDTO) { List value = null; if (valueDTO.value != null) @@ -112,7 +112,7 @@ private static IClass Transform(SubmodelValue valueDTO) return new SubmodelElementList(AasSubmodelElements.SubmodelElement, idShort: valueDTO.idShort, value: value); } - private static IClass? Transform(MultiLanguagePropertyValue valueDTO) + private static IClass Transform(MultiLanguagePropertyValue valueDTO) { var value = new List(); foreach (var langString in valueDTO.langStrings) @@ -122,7 +122,7 @@ private static IClass Transform(SubmodelValue valueDTO) return new MultiLanguageProperty(idShort: valueDTO.idShort, value: value); } - private static IClass? Transform(SubmodelElementCollectionValue valueDTO) + private static IClass Transform(SubmodelElementCollectionValue valueDTO) { List value = null; if (valueDTO.value != null) @@ -137,7 +137,7 @@ private static IClass Transform(SubmodelValue valueDTO) return new SubmodelElementCollection(idShort: valueDTO.idShort, value: value); } - private static IClass? Transform(EntityValue valueDTO) + private static IClass Transform(EntityValue valueDTO) { List statements = null; if (valueDTO.statements != null) @@ -151,12 +151,12 @@ private static IClass Transform(SubmodelValue valueDTO) return new Entity(valueDTO.entityType, idShort: valueDTO.idShort, statements: statements, globalAssetId: valueDTO.globalAssetId); } - private static IClass? Transform(ReferenceElementValue valueDTO) + private static IClass Transform(ReferenceElementValue valueDTO) { return new ReferenceElement(idShort: valueDTO.idShort, value: TransformReference(valueDTO.value)); } - private static IClass? Transform(RelationshipElementValue valueDTO) + private static IClass Transform(RelationshipElementValue valueDTO) { return new RelationshipElement(TransformReference(valueDTO.first), TransformReference(valueDTO.second), idShort: valueDTO.idShort); } @@ -175,17 +175,17 @@ private static IClass Transform(SubmodelValue valueDTO) return new AnnotatedRelationshipElement(TransformReference(valueDTO.first), TransformReference(valueDTO.second), idShort: valueDTO.idShort, annotations: annotations); } - private static IClass? Transform(FileValue valueDTO) + private static IClass Transform(FileValue valueDTO) { return new File(valueDTO.contentType, idShort: valueDTO.idShort, value: valueDTO.value); } - private static IClass? Transform(BlobValue valueDTO) + private static IClass Transform(BlobValue valueDTO) { return new Blob(valueDTO.contentType, idShort: valueDTO.idShort, value: valueDTO.value); } - private static IClass? Transform(PropertyValue valueDTO) + private static IClass Transform(PropertyValue valueDTO) { return new Property(DataTypeDefXsd.String, idShort: valueDTO.idShort, value: valueDTO.value); } diff --git a/src/IO.Swagger.Lib.V3/SerializationModifiers/Mappers/ValueMappers/ValueOnlyJsonDeserializer.cs b/src/IO.Swagger.Lib.V3/SerializationModifiers/Mappers/ValueMappers/ValueOnlyJsonDeserializer.cs index ef51bb8ee..88ca6dcd0 100644 --- a/src/IO.Swagger.Lib.V3/SerializationModifiers/Mappers/ValueMappers/ValueOnlyJsonDeserializer.cs +++ b/src/IO.Swagger.Lib.V3/SerializationModifiers/Mappers/ValueMappers/ValueOnlyJsonDeserializer.cs @@ -23,7 +23,7 @@ public class ValueOnlyJsonDeserializer : IValueOnlyJsonDeserializer public ValueOnlyJsonDeserializer(ISubmodelService submodelService, IBase64UrlDecoderService decoderService) { _submodelService = submodelService ?? throw new ArgumentNullException(nameof(submodelService)); - _decoderService = decoderService ?? throw new ArgumentNullException(nameof(submodelService)); + _decoderService = decoderService ?? throw new ArgumentNullException(nameof(decoderService)); } public IValueDTO? DeserializeSubmodelElementValue(JsonNode node, string? encodedSubmodelIdentifier = null, string idShortPath = null) { @@ -98,7 +98,7 @@ public ValueOnlyJsonDeserializer(ISubmodelService submodelService, IBase64UrlDec return null; } - private IValueDTO? CreateSubmodelElementList(string idShort, JsonArray valueArray, SubmodelElementList smeList, string? encodedSubmodelIdentifier, string idShortPath) + private IValueDTO CreateSubmodelElementList(string idShort, JsonArray valueArray, SubmodelElementList smeList, string? encodedSubmodelIdentifier, string idShortPath) { var value = new List(); foreach (var element in valueArray) @@ -110,7 +110,7 @@ public ValueOnlyJsonDeserializer(ISubmodelService submodelService, IBase64UrlDec return new SubmodelElementListValue(idShort, value); } - private IValueDTO? CreateMultilanguagePropertyValue(string idShort, JsonArray valueArray) + private IValueDTO CreateMultilanguagePropertyValue(string idShort, JsonArray valueArray) { var langStrings = new List>(); @@ -197,7 +197,7 @@ private void GetPropertyFromJsonObject(JsonObject jsonObject, out string? proper return null; } - private IValueDTO? CreateSubmodelElementCollectionValue(string idShort, JsonObject valueObject, string? encodedSubmodelIdentifier, string idShortPath) + private IValueDTO CreateSubmodelElementCollectionValue(string idShort, JsonObject valueObject, string? encodedSubmodelIdentifier, string idShortPath) { var submodelElements = new List(); @@ -214,18 +214,17 @@ private void GetPropertyFromJsonObject(JsonObject jsonObject, out string? proper return new SubmodelElementCollectionValue(idShort, submodelElements); } - private IValueDTO? CreateBasicEventElement(string idShort, JsonObject valueObject) + private IValueDTO CreateBasicEventElement(string idShort, JsonObject valueObject) { - ReferenceDTO observed = null; - var observedNode = valueObject["observed"] as JsonNode; - if (observedNode != null) + ReferenceDTO? observed = null; + if (valueObject["observed"] is not null) { observed = JsonConvert.DeserializeObject(valueObject.ToString()); } return new BasicEventElementValue(idShort, observed); } - private IValueDTO? CreateEntityValue(string idShort, JsonObject valueObject, string? encodedSubmodelIdentifier, string idShortPath) + private IValueDTO CreateEntityValue(string idShort, JsonObject valueObject, string? encodedSubmodelIdentifier, string idShortPath) { string? entityType = null; string globalAssetId = null; @@ -252,13 +251,13 @@ private void GetPropertyFromJsonObject(JsonObject jsonObject, out string? proper return new EntityValue(idShort, (EntityType)Stringification.EntityTypeFromString(entityType), statements, globalAssetId); } - private IValueDTO? CreateReferenceElementValue(string idShort, JsonObject valueObject) + private IValueDTO CreateReferenceElementValue(string idShort, JsonObject valueObject) { ReferenceDTO referenceDTO = JsonConvert.DeserializeObject(valueObject.ToString()); return new ReferenceElementValue(idShort, referenceDTO); } - private IValueDTO? CreateRelationshipElementValue(string idShort, JsonObject valueObject) + private IValueDTO CreateRelationshipElementValue(string idShort, JsonObject valueObject) { ReferenceDTO firstDTO = null, secondDTO = null; JsonNode firstNode = valueObject["first"]; @@ -275,7 +274,7 @@ private void GetPropertyFromJsonObject(JsonObject jsonObject, out string? proper return new RelationshipElementValue(idShort, firstDTO, secondDTO); } - private IValueDTO? CreateAnnotedRelationshipElementValue(string idShort, JsonObject valueObject, string? encodedSubmodelIdentifier, string idShortPath) + private IValueDTO CreateAnnotedRelationshipElementValue(string idShort, JsonObject valueObject, string? encodedSubmodelIdentifier, string idShortPath) { ReferenceDTO firstDTO = null, secondDTO = null; JsonNode firstNode = valueObject["first"]; @@ -304,7 +303,7 @@ private void GetPropertyFromJsonObject(JsonObject jsonObject, out string? proper return new AnnotatedRelationshipElementValue(idShort, firstDTO, secondDTO); } - private IValueDTO? CreateBlobValue(string idShort, JsonObject valueObject) + private IValueDTO CreateBlobValue(string idShort, JsonObject valueObject) { string? contentType = null; var contentTypeNode = valueObject["contentType"] as JsonValue; @@ -320,7 +319,7 @@ private void GetPropertyFromJsonObject(JsonObject jsonObject, out string? proper return new BlobValue(idShort, contentType); } - private IValueDTO? CreateFileValue(string idShort, JsonObject valueObject) + private IValueDTO CreateFileValue(string idShort, JsonObject valueObject) { string? contentType = null; string value = null; @@ -331,7 +330,7 @@ private void GetPropertyFromJsonObject(JsonObject jsonObject, out string? proper return new FileValue(idShort, contentType, value); } - private static IValueDTO? CreateRangeValue(string idShort, JsonObject valueObject) + private static IValueDTO CreateRangeValue(string idShort, JsonObject valueObject) { string min = null, max = null; var minNode = valueObject["min"] as JsonValue; @@ -342,7 +341,7 @@ private void GetPropertyFromJsonObject(JsonObject jsonObject, out string? proper return new RangeValue(idShort, min, max); } - public SubmodelValue? DeserializeSubmodelValue(JsonNode node, string? encodedSubmodelIdentifier) + public SubmodelValue DeserializeSubmodelValue(JsonNode node, string? encodedSubmodelIdentifier) { var submodelElements = new List(); var jsonObject = node as JsonObject; diff --git a/src/IO.Swagger.Lib.V3/SerializationModifiers/Mappers/ValueMappers/ValueOnlyJsonSerializer.cs b/src/IO.Swagger.Lib.V3/SerializationModifiers/Mappers/ValueMappers/ValueOnlyJsonSerializer.cs index 4a1fccbb0..824384c1a 100644 --- a/src/IO.Swagger.Lib.V3/SerializationModifiers/Mappers/ValueMappers/ValueOnlyJsonSerializer.cs +++ b/src/IO.Swagger.Lib.V3/SerializationModifiers/Mappers/ValueMappers/ValueOnlyJsonSerializer.cs @@ -69,7 +69,7 @@ public static class ValueOnlyJsonSerializer return null; } - private static JsonNode? Transform(EntityValue entityValue) + private static JsonNode Transform(EntityValue entityValue) { var result = new JsonObject(); @@ -98,7 +98,7 @@ public static class ValueOnlyJsonSerializer return result; } - private static JsonNode? Transform(AnnotatedRelationshipElementValue annotatedRelEleValue) + private static JsonNode Transform(AnnotatedRelationshipElementValue annotatedRelEleValue) { var result = new JsonObject(); @@ -122,7 +122,7 @@ public static class ValueOnlyJsonSerializer return result; } - private static JsonNode? Transform(SubmodelValue submodelValue) + private static JsonNode Transform(SubmodelValue submodelValue) { var result = new JsonObject(); if (submodelValue.submodelElements != null) @@ -142,7 +142,7 @@ public static class ValueOnlyJsonSerializer return result; } - private static JsonObject? Transform(SubmodelElementListValue submodelElementListValue) + private static JsonObject Transform(SubmodelElementListValue submodelElementListValue) { var result = new JsonObject(); @@ -166,7 +166,7 @@ public static class ValueOnlyJsonSerializer return result; } - private static JsonObject? Transform(SubmodelElementCollectionValue submodelElementCollectionValue) + private static JsonObject Transform(SubmodelElementCollectionValue submodelElementCollectionValue) { var result = new JsonObject(); @@ -190,7 +190,7 @@ public static class ValueOnlyJsonSerializer return result; } - private static JsonObject? Transform(RelationshipElementValue relationshipElementValue) + private static JsonObject Transform(RelationshipElementValue relationshipElementValue) { var result = new JsonObject(); @@ -203,7 +203,7 @@ public static class ValueOnlyJsonSerializer return result; } - private static JsonObject? Transform(ReferenceElementValue referenceElementValue) + private static JsonObject Transform(ReferenceElementValue referenceElementValue) { var result = new JsonObject(); @@ -212,7 +212,7 @@ public static class ValueOnlyJsonSerializer return result; } - private static JsonObject? Transform(RangeValue rangeValue) + private static JsonObject Transform(RangeValue rangeValue) { var result = new JsonObject(); @@ -225,7 +225,7 @@ public static class ValueOnlyJsonSerializer return result; } - private static JsonObject? Transform(FileValue fileValue) + private static JsonObject Transform(FileValue fileValue) { var result = new JsonObject(); @@ -238,7 +238,7 @@ public static class ValueOnlyJsonSerializer return result; } - private static JsonObject? Transform(BlobValue blobValue) + private static JsonObject Transform(BlobValue blobValue) { var result = new JsonObject(); @@ -254,7 +254,7 @@ public static class ValueOnlyJsonSerializer return result; } - private static JsonObject? Transform(BasicEventElementValue basicEventElementValue) + private static JsonObject Transform(BasicEventElementValue basicEventElementValue) { var result = new JsonObject(); @@ -302,7 +302,7 @@ private static JsonNode Transform(KeyDTO that) return result; } - private static JsonObject? Transform(MultiLanguagePropertyValue multiLanguagePropertyValue) + private static JsonObject Transform(MultiLanguagePropertyValue multiLanguagePropertyValue) { var result = new JsonObject(); @@ -318,7 +318,7 @@ private static JsonNode Transform(KeyDTO that) return result; } - private static JsonObject? Transform(PropertyValue propertyValue) + private static JsonObject Transform(PropertyValue propertyValue) { var result = new JsonObject(); result[propertyValue.idShort] = propertyValue.value; diff --git a/src/IO.Swagger.Lib.V3/SerializationModifiers/PathModifier/PathTransformer.cs b/src/IO.Swagger.Lib.V3/SerializationModifiers/PathModifier/PathTransformer.cs index 79aa6cc7a..0c1851f64 100644 --- a/src/IO.Swagger.Lib.V3/SerializationModifiers/PathModifier/PathTransformer.cs +++ b/src/IO.Swagger.Lib.V3/SerializationModifiers/PathModifier/PathTransformer.cs @@ -96,7 +96,7 @@ public List TransformEntity(IEntity that, PathModifierContext context) { if (context.IdShortPaths.Count == 0) { - context.IdShortPaths.Add(that.IdShort); + context.IdShortPaths.Add(that.IdShort ?? string.Empty); } else { @@ -106,7 +106,7 @@ public List TransformEntity(IEntity that, PathModifierContext context) if (that.Statements != null) { var currentParentPath = string.IsNullOrEmpty(context.ParentPath) ? that.IdShort : $"{context.ParentPath}.{that.IdShort}"; - foreach (ISubmodelElement item in that.Statements) + foreach (var item in that.Statements) { context.ParentPath = currentParentPath; Transform(item, context); @@ -311,7 +311,7 @@ public List TransformSubmodelElementCollection(ISubmodelElementCollectio if (that.Value != null) { var currentParentPath = string.IsNullOrEmpty(context.ParentPath) ? that.IdShort : $"{context.ParentPath}.{that.IdShort}"; - foreach (ISubmodelElement item in that.Value) + foreach (var item in that.Value) { context.ParentPath = currentParentPath; Transform(item, context); @@ -325,7 +325,7 @@ public List TransformSubmodelElementList(ISubmodelElementList that, Path { if (that.Value != null) { - for (int i = 0; i < that.Value.Count; i++) + for (var i = 0; i < that.Value.Count; i++) { if (string.IsNullOrEmpty(context.ParentPath)) { diff --git a/src/IO.Swagger.Lib.V3/SerializationModifiers/SerializationModifiersValidator.cs b/src/IO.Swagger.Lib.V3/SerializationModifiers/SerializationModifiersValidator.cs index dc6e1c461..a670c229d 100644 --- a/src/IO.Swagger.Lib.V3/SerializationModifiers/SerializationModifiersValidator.cs +++ b/src/IO.Swagger.Lib.V3/SerializationModifiers/SerializationModifiersValidator.cs @@ -73,7 +73,7 @@ public static void Validate(object? resource, LevelEnum level, ExtentEnum extent public static void Validate(List resources, LevelEnum level, ExtentEnum extent) { - foreach (IClass? resource in resources) + foreach (var resource in resources) Validate(resource, level, extent); } } diff --git a/src/IO.Swagger.Lib.V3/Services/JsonQueryDeserializer.cs b/src/IO.Swagger.Lib.V3/Services/JsonQueryDeserializer.cs index d38762a5e..db76defbd 100644 --- a/src/IO.Swagger.Lib.V3/Services/JsonQueryDeserializer.cs +++ b/src/IO.Swagger.Lib.V3/Services/JsonQueryDeserializer.cs @@ -29,8 +29,8 @@ public JsonQueryDeserializer(IAppLogger logger, IBase64Ur if (!string.IsNullOrEmpty(referenceString)) { var decodedString = _decoderService.Decode(fieldName, referenceString); - MemoryStream mStrm = new MemoryStream(Encoding.UTF8.GetBytes(decodedString)); - JsonNode node = JsonSerializer.DeserializeAsync(mStrm).Result; + var mStrm = new MemoryStream(Encoding.UTF8.GetBytes(decodedString ?? string.Empty)); + var node = JsonSerializer.DeserializeAsync(mStrm).Result; output = Jsonization.Deserialize.ReferenceFrom(node); } } diff --git a/src/IO.Swagger.Lib.V3/Services/PaginationService.cs b/src/IO.Swagger.Lib.V3/Services/PaginationService.cs index b5a39f69f..a54f0548a 100644 --- a/src/IO.Swagger.Lib.V3/Services/PaginationService.cs +++ b/src/IO.Swagger.Lib.V3/Services/PaginationService.cs @@ -34,7 +34,7 @@ public PagedResult GetPaginatedList(List sourceList, PaginationParameters _logger.LogError($"There are less elements in the retrived list than requested pagination - (from: {startIndex}, size:{endIndex})"); } - for (int i = startIndex; i <= endIndex; i++) + for (var i = startIndex; i <= endIndex; i++) { outputList.Add(sourceList[i]); } @@ -48,7 +48,7 @@ public PagedResult GetPaginatedList(List sourceList, PaginationParameters var paginationResult = new PagedResult() { - result = outputList.ConvertAll(r => (IClass)r), + result = outputList.ConvertAll(r => r as IClass), paging_metadata = pagingMetadata }; @@ -95,7 +95,7 @@ private List GetPaginationList(List sourceList, int startIndex, int end _logger.LogError($"There are less elements in the retrived list than requested pagination - (from: {startIndex}, size:{endIndex})"); } - for (int i = startIndex; i <= endIndex; i++) + for (var i = startIndex; i <= endIndex; i++) { outputList.Add(sourceList[i]); } diff --git a/src/IO.Swagger.Lib.V3/Services/ReferenceModifierService.cs b/src/IO.Swagger.Lib.V3/Services/ReferenceModifierService.cs index bb28ef598..aebd4e4e7 100644 --- a/src/IO.Swagger.Lib.V3/Services/ReferenceModifierService.cs +++ b/src/IO.Swagger.Lib.V3/Services/ReferenceModifierService.cs @@ -6,6 +6,8 @@ namespace IO.Swagger.Lib.V3.Services { + using System.Linq; + public class ReferenceModifierService : IReferenceModifierService { private readonly IAppLogger _logger; @@ -21,11 +23,7 @@ public List GetReferenceResult(List referables) if (!referables.IsNullOrEmpty()) { - foreach (var referable in referables) - { - Reference reference = referable.GetReference(); - output.Add(reference); - } + output.AddRange(referables.Select(referable => referable.GetReference()).Cast()); } return output;