From 6ba6431f5d53321be5083ae925d4b795d42e06b3 Mon Sep 17 00:00:00 2001 From: David Kallesen Date: Thu, 27 Jun 2024 22:49:07 +0200 Subject: [PATCH 1/6] feat: Prefix DataContract dataType with full namespace if needed. Introduce GetQualifiedDataType extension on ApiOperationResponseModel --- .../ContentGeneratorClientEndpointResult.cs | 14 ++++---- ...tGeneratorClientEndpointResultInterface.cs | 8 +++-- .../ApiOperationResponseModelExtensions.cs | 32 ++++++++++++++++--- .../Models/ApiOperationResponseModel.cs | 3 +- .../ContentGeneratorServerEndpoints.cs | 8 +++-- .../ContentGeneratorServerController.cs | 8 +++-- ...tGeneratorServerResultParametersFactory.cs | 2 +- ...ndpointResultInterfaceParametersFactory.cs | 3 +- ...orClientEndpointResultParametersFactory.cs | 3 +- ...eneratorServerEndpointParametersFactory.cs | 3 +- .../Extensions/OpenApiOperationExtensions.cs | 9 ++++-- 11 files changed, 66 insertions(+), 27 deletions(-) diff --git a/src/Atc.Rest.ApiGenerator.Client.CSharp/ContentGenerators/ContentGeneratorClientEndpointResult.cs b/src/Atc.Rest.ApiGenerator.Client.CSharp/ContentGenerators/ContentGeneratorClientEndpointResult.cs index 7b0674c7..f5082712 100644 --- a/src/Atc.Rest.ApiGenerator.Client.CSharp/ContentGenerators/ContentGeneratorClientEndpointResult.cs +++ b/src/Atc.Rest.ApiGenerator.Client.CSharp/ContentGenerators/ContentGeneratorClientEndpointResult.cs @@ -171,10 +171,12 @@ private void AppendMethodContentStatusCodeOk( return; } + var dataType = responseModel.GetQualifiedDataType(); + if (responseModel.CollectionDataType is null) { - sb.AppendLine(4, $"public {responseModel.DataType} OkContent"); - sb.AppendLine(8, $"=> IsOk && ContentObject is {responseModel.DataType} result"); + sb.AppendLine(4, $"public {dataType} OkContent"); + sb.AppendLine(8, $"=> IsOk && ContentObject is {dataType} result"); sb.AppendLine(12, "? result"); sb.AppendLine(12, ": throw new InvalidOperationException(\"Content is not the expected type - please use the IsOk property first.\");"); return; @@ -182,15 +184,15 @@ private void AppendMethodContentStatusCodeOk( if (responseModel.CollectionDataType == NameConstants.List) { - sb.AppendLine(4, $"public IEnumerable<{responseModel.DataType}> OkContent"); - sb.AppendLine(8, $"=> IsOk && ContentObject is IEnumerable<{responseModel.DataType}> result"); + sb.AppendLine(4, $"public IEnumerable<{dataType}> OkContent"); + sb.AppendLine(8, $"=> IsOk && ContentObject is IEnumerable<{dataType}> result"); sb.AppendLine(12, "? result"); sb.AppendLine(12, ": throw new InvalidOperationException(\"Content is not the expected type - please use the IsOk property first.\");"); } else { - sb.AppendLine(4, $"public {responseModel.CollectionDataType}<{responseModel.DataType}> OkContent"); - sb.AppendLine(8, $"=> IsOk && ContentObject is {responseModel.CollectionDataType}<{responseModel.DataType}> result"); + sb.AppendLine(4, $"public {responseModel.CollectionDataType}<{dataType}> OkContent"); + sb.AppendLine(8, $"=> IsOk && ContentObject is {responseModel.CollectionDataType}<{dataType}> result"); sb.AppendLine(12, "? result"); sb.AppendLine(12, ": throw new InvalidOperationException(\"Content is not the expected type - please use the IsOk property first.\");"); } diff --git a/src/Atc.Rest.ApiGenerator.Client.CSharp/ContentGenerators/ContentGeneratorClientEndpointResultInterface.cs b/src/Atc.Rest.ApiGenerator.Client.CSharp/ContentGenerators/ContentGeneratorClientEndpointResultInterface.cs index bd2f12c8..74be0ad2 100644 --- a/src/Atc.Rest.ApiGenerator.Client.CSharp/ContentGenerators/ContentGeneratorClientEndpointResultInterface.cs +++ b/src/Atc.Rest.ApiGenerator.Client.CSharp/ContentGenerators/ContentGeneratorClientEndpointResultInterface.cs @@ -161,19 +161,21 @@ private void AppendMethodContentStatusCodeOk( return; } + var dataType = responseModel.GetQualifiedDataType(); + if (responseModel.CollectionDataType is null) { - sb.AppendLine(4, $"{responseModel.DataType} OkContent {{ get; }}"); + sb.AppendLine(4, $"{dataType} OkContent {{ get; }}"); return; } if (responseModel.CollectionDataType == NameConstants.List) { - sb.AppendLine(4, $"IEnumerable<{responseModel.DataType}> OkContent {{ get; }}"); + sb.AppendLine(4, $"IEnumerable<{dataType}> OkContent {{ get; }}"); } else { - sb.AppendLine(4, $"{responseModel.CollectionDataType}<{responseModel.DataType}> OkContent {{ get; }}"); + sb.AppendLine(4, $"{responseModel.CollectionDataType}<{dataType}> OkContent {{ get; }}"); } } diff --git a/src/Atc.Rest.ApiGenerator.Contracts/Extensions/ApiOperationResponseModelExtensions.cs b/src/Atc.Rest.ApiGenerator.Contracts/Extensions/ApiOperationResponseModelExtensions.cs index 1e2d0fe4..b8dff789 100644 --- a/src/Atc.Rest.ApiGenerator.Contracts/Extensions/ApiOperationResponseModelExtensions.cs +++ b/src/Atc.Rest.ApiGenerator.Contracts/Extensions/ApiOperationResponseModelExtensions.cs @@ -2,6 +2,26 @@ namespace Atc.Rest.ApiGenerator.Contracts.Extensions; public static class ApiOperationResponseModelExtensions { + public static string? GetQualifiedDataType( + this ApiOperationResponseModel responseModel) + { + ArgumentNullException.ThrowIfNull(responseModel); + + if (string.IsNullOrEmpty(responseModel.DataType)) + { + return null; + } + + var dataType = responseModel.DataType; + if (responseModel.Namespace is not null && + responseModel.Namespace.EndsWith(responseModel.DataType, StringComparison.Ordinal)) + { + dataType = $"{responseModel.Namespace}.{dataType}"; + } + + return dataType; + } + public static IEnumerable AppendUnauthorizedIfNeeded( this IEnumerable responseModels, ApiAuthorizeModel? authorization) @@ -24,7 +44,8 @@ public static IEnumerable AppendUnauthorizedIfNeeded( MediaType: null, CollectionDataType: null, DataType: null, - Description: null)); + Description: null, + Namespace: null)); } return models; @@ -56,7 +77,8 @@ authorization is MediaType: null, CollectionDataType: null, DataType: null, - Description: null)); + Description: null, + Namespace: null)); } return models; @@ -79,7 +101,8 @@ public static IEnumerable AppendBadRequestIfNeeded( MediaType: null, CollectionDataType: null, DataType: null, - Description: null)); + Description: null, + Namespace: null)); } return models; @@ -102,7 +125,8 @@ public static IEnumerable AppendBadRequestIfNeeded( MediaType: null, CollectionDataType: null, DataType: null, - Description: null)); + Description: null, + Namespace: null)); } return models; diff --git a/src/Atc.Rest.ApiGenerator.Contracts/Models/ApiOperationResponseModel.cs b/src/Atc.Rest.ApiGenerator.Contracts/Models/ApiOperationResponseModel.cs index d3828317..3b4cfde2 100644 --- a/src/Atc.Rest.ApiGenerator.Contracts/Models/ApiOperationResponseModel.cs +++ b/src/Atc.Rest.ApiGenerator.Contracts/Models/ApiOperationResponseModel.cs @@ -7,4 +7,5 @@ public record ApiOperationResponseModel( string? MediaType, string? CollectionDataType, string? DataType, - string? Description); \ No newline at end of file + string? Description, + string? Namespace); \ No newline at end of file diff --git a/src/Atc.Rest.ApiGenerator.Framework.Minimal/ContentGenerators/ContentGeneratorServerEndpoints.cs b/src/Atc.Rest.ApiGenerator.Framework.Minimal/ContentGenerators/ContentGeneratorServerEndpoints.cs index fb772496..746e31a9 100644 --- a/src/Atc.Rest.ApiGenerator.Framework.Minimal/ContentGenerators/ContentGeneratorServerEndpoints.cs +++ b/src/Atc.Rest.ApiGenerator.Framework.Minimal/ContentGenerators/ContentGeneratorServerEndpoints.cs @@ -395,17 +395,19 @@ private static void AppendProducesForOk( } else { + var dataType = responseModel.GetQualifiedDataType(); + if (string.IsNullOrEmpty(responseModel.CollectionDataType)) { - sb.Append(12, $".Produces<{responseModel.DataType}>()"); + sb.Append(12, $".Produces<{dataType}>()"); } else { sb.AppendLine( 4, responseModel.CollectionDataType == "List" - ? $".Produces>()" - : $".Produces<{responseModel.CollectionDataType}<{responseModel.DataType}>>()"); + ? $".Produces>()" + : $".Produces<{responseModel.CollectionDataType}<{dataType}>>()"); } } } diff --git a/src/Atc.Rest.ApiGenerator.Framework.Mvc/ContentGenerators/ContentGeneratorServerController.cs b/src/Atc.Rest.ApiGenerator.Framework.Mvc/ContentGenerators/ContentGeneratorServerController.cs index 8eaa5245..576d3b33 100644 --- a/src/Atc.Rest.ApiGenerator.Framework.Mvc/ContentGenerators/ContentGeneratorServerController.cs +++ b/src/Atc.Rest.ApiGenerator.Framework.Mvc/ContentGenerators/ContentGeneratorServerController.cs @@ -367,17 +367,19 @@ private static void AppendProducesForOk( } else { + var dataType = responseModel.GetQualifiedDataType(); + if (string.IsNullOrEmpty(responseModel.CollectionDataType)) { - sb.AppendLine(4, $"[ProducesResponseType(typeof({responseModel.DataType}), StatusCodes.{responseModel.StatusCode.ToStatusCodesConstant()})]"); + sb.AppendLine(4, $"[ProducesResponseType(typeof({dataType}), StatusCodes.{responseModel.StatusCode.ToStatusCodesConstant()})]"); } else { sb.AppendLine( 4, responseModel.CollectionDataType == "List" - ? $"[ProducesResponseType(typeof(IEnumerable<{responseModel.DataType}>), StatusCodes.{responseModel.StatusCode.ToStatusCodesConstant()})]" - : $"[ProducesResponseType(typeof({responseModel.CollectionDataType}<{responseModel.DataType}>), StatusCodes.{responseModel.StatusCode.ToStatusCodesConstant()})]"); + ? $"[ProducesResponseType(typeof(IEnumerable<{dataType}>), StatusCodes.{responseModel.StatusCode.ToStatusCodesConstant()})]" + : $"[ProducesResponseType(typeof({responseModel.CollectionDataType}<{dataType}>), StatusCodes.{responseModel.StatusCode.ToStatusCodesConstant()})]"); } } } diff --git a/src/Atc.Rest.ApiGenerator.Framework.Mvc/Factories/ContentGeneratorServerResultParametersFactory.cs b/src/Atc.Rest.ApiGenerator.Framework.Mvc/Factories/ContentGeneratorServerResultParametersFactory.cs index 454d79ee..0a671582 100644 --- a/src/Atc.Rest.ApiGenerator.Framework.Mvc/Factories/ContentGeneratorServerResultParametersFactory.cs +++ b/src/Atc.Rest.ApiGenerator.Framework.Mvc/Factories/ContentGeneratorServerResultParametersFactory.cs @@ -19,7 +19,7 @@ public static ContentGeneratorServerResultParameters Create( // Methods var methodParameters = new List(); - var responseModels = openApiOperation.ExtractApiOperationResponseModels().ToList(); + var responseModels = openApiOperation.ExtractApiOperationResponseModels(@namespace).ToList(); foreach (var responseModel in responseModels.OrderBy(x => x.StatusCode)) { diff --git a/src/Atc.Rest.ApiGenerator.Framework/Factories/Parameters/Client/ContentGeneratorClientEndpointResultInterfaceParametersFactory.cs b/src/Atc.Rest.ApiGenerator.Framework/Factories/Parameters/Client/ContentGeneratorClientEndpointResultInterfaceParametersFactory.cs index d0b578c4..73b48bc1 100644 --- a/src/Atc.Rest.ApiGenerator.Framework/Factories/Parameters/Client/ContentGeneratorClientEndpointResultInterfaceParametersFactory.cs +++ b/src/Atc.Rest.ApiGenerator.Framework/Factories/Parameters/Client/ContentGeneratorClientEndpointResultInterfaceParametersFactory.cs @@ -18,9 +18,10 @@ public static ContentGeneratorClientEndpointResultInterfaceParameters Create( AppendParameters(parameters, openApiOperation.Parameters); AppendParametersFromBody(parameters, openApiOperation.RequestBody); + var modelNamespace = $"{projectName}.{ContentGeneratorConstants.Contracts}.{apiGroupName}"; var operationName = openApiOperation.GetOperationName(); var endpointAuthorization = openApiOperation.ExtractApiOperationAuthorization(openApiPath); - var responseModels = openApiOperation.ExtractApiOperationResponseModels().ToList(); + var responseModels = openApiOperation.ExtractApiOperationResponseModels(modelNamespace).ToList(); var hasParameterType = openApiPath.HasParameters() || openApiOperation.HasParametersOrRequestBody(); return new ContentGeneratorClientEndpointResultInterfaceParameters( diff --git a/src/Atc.Rest.ApiGenerator.Framework/Factories/Parameters/Client/ContentGeneratorClientEndpointResultParametersFactory.cs b/src/Atc.Rest.ApiGenerator.Framework/Factories/Parameters/Client/ContentGeneratorClientEndpointResultParametersFactory.cs index b5b1c391..6c18f087 100644 --- a/src/Atc.Rest.ApiGenerator.Framework/Factories/Parameters/Client/ContentGeneratorClientEndpointResultParametersFactory.cs +++ b/src/Atc.Rest.ApiGenerator.Framework/Factories/Parameters/Client/ContentGeneratorClientEndpointResultParametersFactory.cs @@ -18,9 +18,10 @@ public static ContentGeneratorClientEndpointResultParameters Create( AppendParameters(parameters, openApiOperation.Parameters); AppendParametersFromBody(parameters, openApiOperation.RequestBody); + var modelNamespace = $"{projectName}.{ContentGeneratorConstants.Contracts}.{apiGroupName}"; var operationName = openApiOperation.GetOperationName(); var endpointAuthorization = openApiOperation.ExtractApiOperationAuthorization(openApiPath); - var responseModels = openApiOperation.ExtractApiOperationResponseModels().ToList(); + var responseModels = openApiOperation.ExtractApiOperationResponseModels(modelNamespace).ToList(); var hasParameterType = openApiPath.HasParameters() || openApiOperation.HasParametersOrRequestBody(); if (hasParameterType) diff --git a/src/Atc.Rest.ApiGenerator.Framework/Factories/Server/ContentGeneratorServerEndpointParametersFactory.cs b/src/Atc.Rest.ApiGenerator.Framework/Factories/Server/ContentGeneratorServerEndpointParametersFactory.cs index e0788200..cf0aab3b 100644 --- a/src/Atc.Rest.ApiGenerator.Framework/Factories/Server/ContentGeneratorServerEndpointParametersFactory.cs +++ b/src/Atc.Rest.ApiGenerator.Framework/Factories/Server/ContentGeneratorServerEndpointParametersFactory.cs @@ -11,6 +11,7 @@ public static ContentGeneratorServerEndpointParameters Create( string endpointSuffixName, OpenApiDocument openApiDocument) { + var modelNamespace = $"{projectName}.{ContentGeneratorConstants.Contracts}.{apiGroupName}"; var methodParameters = new List(); ApiAuthorizeModel? controllerAuthorization = null; @@ -23,7 +24,7 @@ public static ContentGeneratorServerEndpointParameters Create( var operationName = apiOperation.Value.GetOperationName(); var endpointAuthorization = apiOperation.Value.ExtractApiOperationAuthorization(apiPathData); var responseModels = apiOperation.Value - .ExtractApiOperationResponseModels() + .ExtractApiOperationResponseModels(modelNamespace) .AdjustNamespacesIfNeeded(operationSchemaMappings); methodParameters.Add(new ContentGeneratorServerEndpointMethodParameters( diff --git a/src/Atc.Rest.ApiGenerator.OpenApi/Extensions/OpenApiOperationExtensions.cs b/src/Atc.Rest.ApiGenerator.OpenApi/Extensions/OpenApiOperationExtensions.cs index 2df6d042..51514002 100644 --- a/src/Atc.Rest.ApiGenerator.OpenApi/Extensions/OpenApiOperationExtensions.cs +++ b/src/Atc.Rest.ApiGenerator.OpenApi/Extensions/OpenApiOperationExtensions.cs @@ -133,7 +133,8 @@ authorizationRolesForOperation is null && } public static IEnumerable ExtractApiOperationResponseModels( - this OpenApiOperation apiOperation) + this OpenApiOperation apiOperation, + string? @namespace = null) { var result = new List(); @@ -154,7 +155,8 @@ public static IEnumerable ExtractApiOperationResponse MediaType: null, CollectionDataType: null, DataType: null, - Description: apiResponse.Value.Description)); + Description: apiResponse.Value.Description, + Namespace: null)); } else { @@ -209,7 +211,8 @@ public static IEnumerable ExtractApiOperationResponse MediaType: apiMediaType.Key, CollectionDataType: collectionDataType, DataType: dataType, - Description: apiResponse.Value.Description)); + Description: apiResponse.Value.Description, + Namespace: @namespace)); } } } From 15e84f9a867b4f0df62a56bae3dad0d130b78355 Mon Sep 17 00:00:00 2001 From: David Kallesen Date: Thu, 27 Jun 2024 22:49:43 +0200 Subject: [PATCH 2/6] fix: Remove Atc.Rest.MinimalApi package from Mvc project --- .../Providers/NugetPackageReferenceProvider.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Atc.Rest.ApiGenerator.Framework/Providers/NugetPackageReferenceProvider.cs b/src/Atc.Rest.ApiGenerator.Framework/Providers/NugetPackageReferenceProvider.cs index 8fa36ded..48139144 100644 --- a/src/Atc.Rest.ApiGenerator.Framework/Providers/NugetPackageReferenceProvider.cs +++ b/src/Atc.Rest.ApiGenerator.Framework/Providers/NugetPackageReferenceProvider.cs @@ -58,7 +58,6 @@ public async Task GetAtcApiGeneratorVersion() ("Asp.Versioning.Http", PackageDefaultVersions["Asp.Versioning.Http"]), ("Atc", atcVersion), ("Atc.Rest.Extended", atcVersion), - ("Atc.Rest.MinimalApi", "1.0.81"), ("Microsoft.NETCore.Platforms", PackageDefaultVersions["Microsoft.NETCore.Platforms"]), ("Swashbuckle.AspNetCore", PackageDefaultVersions["Swashbuckle.AspNetCore"]), }; From 70ad04422d6f1c12bea7318ab11dd861a437095f Mon Sep 17 00:00:00 2001 From: David Kallesen Date: Thu, 27 Jun 2024 22:50:28 +0200 Subject: [PATCH 3/6] fix: Remove ArgumentNullException.ThrowIfNull(testPath) - testPath null is allowed --- .../ProjectGenerator/ServerGenerator.cs | 1 - .../ProjectGenerator/ServerGenerator.cs | 1 - 2 files changed, 2 deletions(-) diff --git a/src/Atc.Rest.ApiGenerator.Framework.Minimal/ProjectGenerator/ServerGenerator.cs b/src/Atc.Rest.ApiGenerator.Framework.Minimal/ProjectGenerator/ServerGenerator.cs index 04b002db..6ce64160 100644 --- a/src/Atc.Rest.ApiGenerator.Framework.Minimal/ProjectGenerator/ServerGenerator.cs +++ b/src/Atc.Rest.ApiGenerator.Framework.Minimal/ProjectGenerator/ServerGenerator.cs @@ -19,7 +19,6 @@ public ServerGenerator( ArgumentNullException.ThrowIfNull(projectName); ArgumentNullException.ThrowIfNull(rootPath); ArgumentNullException.ThrowIfNull(srcPath); - ArgumentNullException.ThrowIfNull(testPath); logger = loggerFactory.CreateLogger(); this.projectName = projectName; diff --git a/src/Atc.Rest.ApiGenerator.Framework.Mvc/ProjectGenerator/ServerGenerator.cs b/src/Atc.Rest.ApiGenerator.Framework.Mvc/ProjectGenerator/ServerGenerator.cs index dcee4337..5ce98584 100644 --- a/src/Atc.Rest.ApiGenerator.Framework.Mvc/ProjectGenerator/ServerGenerator.cs +++ b/src/Atc.Rest.ApiGenerator.Framework.Mvc/ProjectGenerator/ServerGenerator.cs @@ -19,7 +19,6 @@ public ServerGenerator( ArgumentNullException.ThrowIfNull(projectName); ArgumentNullException.ThrowIfNull(rootPath); ArgumentNullException.ThrowIfNull(srcPath); - ArgumentNullException.ThrowIfNull(testPath); logger = loggerFactory.CreateLogger(); this.projectName = projectName; From 0b133746e38d14a41e739b828ed591cdcf91a44f Mon Sep 17 00:00:00 2001 From: David Kallesen Date: Thu, 27 Jun 2024 22:59:32 +0200 Subject: [PATCH 4/6] fix: Improve use of $"{projectName}.{ContentGeneratorConstants.Contracts}" in GlobalUsings --- .../ProjectGenerator/ClientCSharpApiGenerator.cs | 3 +-- .../ProjectGenerator/ServerApiGenerator.cs | 9 +++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Atc.Rest.ApiGenerator.Client.CSharp/ProjectGenerator/ClientCSharpApiGenerator.cs b/src/Atc.Rest.ApiGenerator.Client.CSharp/ProjectGenerator/ClientCSharpApiGenerator.cs index 390005b0..7b83820e 100644 --- a/src/Atc.Rest.ApiGenerator.Client.CSharp/ProjectGenerator/ClientCSharpApiGenerator.cs +++ b/src/Atc.Rest.ApiGenerator.Client.CSharp/ProjectGenerator/ClientCSharpApiGenerator.cs @@ -395,8 +395,7 @@ public void MaintainGlobalUsings( requiredUsings.Add("Atc.Rest.Results"); } - if (operationSchemaMappings.Any(apiOperation => apiOperation.Model.IsEnum || - apiOperation.Model.IsShared)) + if (operationSchemaMappings.Any(apiOperation => apiOperation.Model.IsShared)) { requiredUsings.Add($"{projectName}.{ContentGeneratorConstants.Contracts}"); } diff --git a/src/Atc.Rest.ApiGenerator.Framework.Minimal/ProjectGenerator/ServerApiGenerator.cs b/src/Atc.Rest.ApiGenerator.Framework.Minimal/ProjectGenerator/ServerApiGenerator.cs index 50563a8a..c87b3e55 100644 --- a/src/Atc.Rest.ApiGenerator.Framework.Minimal/ProjectGenerator/ServerApiGenerator.cs +++ b/src/Atc.Rest.ApiGenerator.Framework.Minimal/ProjectGenerator/ServerApiGenerator.cs @@ -354,11 +354,12 @@ public void MaintainGlobalUsings( // TODO: Check for any use ?? requiredUsings.Add("Microsoft.AspNetCore.Authorization"); - var apiGroupNames = openApiDocument.GetApiGroupNames(); - - // TODO: Check for any use ?? - requiredUsings.Add($"{projectName}.{ContentGeneratorConstants.Contracts}"); + if (operationSchemaMappings.Any(apiOperation => apiOperation.Model.IsShared)) + { + requiredUsings.Add($"{projectName}.{ContentGeneratorConstants.Contracts}"); + } + var apiGroupNames = openApiDocument.GetApiGroupNames(); requiredUsings.AddRange(apiGroupNames.Select(x => $"{projectName}.{ContentGeneratorConstants.Contracts}.{x}")); GlobalUsingsHelper.CreateOrUpdate( From 76ed9bc421ac024559f30d58de271219936536c2 Mon Sep 17 00:00:00 2001 From: David Kallesen Date: Thu, 27 Jun 2024 23:01:51 +0200 Subject: [PATCH 5/6] fix: Improve IsUsingRequiredFor-methods --- .../Extensions/OpenApiDocumentExtensions.cs | 106 ++++++++++++------ .../OpenApiKeyValuePairExtensions.cs | 4 + 2 files changed, 77 insertions(+), 33 deletions(-) diff --git a/src/Atc.Rest.ApiGenerator.OpenApi/Extensions/OpenApiDocumentExtensions.cs b/src/Atc.Rest.ApiGenerator.OpenApi/Extensions/OpenApiDocumentExtensions.cs index cc7d3405..9fc27d33 100644 --- a/src/Atc.Rest.ApiGenerator.OpenApi/Extensions/OpenApiDocumentExtensions.cs +++ b/src/Atc.Rest.ApiGenerator.OpenApi/Extensions/OpenApiDocumentExtensions.cs @@ -119,27 +119,27 @@ public static bool IsUsingRequiredForSystem( this OpenApiDocument openApiDocument, bool includeDeprecated) { - foreach (var openApiPath in openApiDocument.Paths) + foreach (var apiPathPair in openApiDocument.Paths) { - foreach (var openApiOperation in openApiPath.Value.Operations) + foreach (var apiOperationPair in apiPathPair.Value.Operations) { - if (openApiOperation.Value.Deprecated && !includeDeprecated) + if (apiOperationPair.Value.Deprecated && !includeDeprecated) { continue; } - foreach (var response in openApiOperation.Value.Responses.Values) + foreach (var response in apiOperationPair.Value.Responses.Values) { foreach (var mediaType in response.Content.Values) { - foreach (var schemaProperty in mediaType.Schema.Properties) + foreach (var propertyApiSchemaPair in mediaType.Schema.Properties) { - if (schemaProperty.Value.Deprecated && !includeDeprecated) + if (propertyApiSchemaPair.Value.Deprecated && !includeDeprecated) { continue; } - if (schemaProperty.Value.IsFormatTypeUuid()) + if (propertyApiSchemaPair.Value.IsFormatTypeUuid()) { return true; } @@ -156,23 +156,63 @@ public static bool IsUsingRequiredForSystemCollectionGeneric( this OpenApiDocument openApiDocument, bool includeDeprecated) { - foreach (var openApiPath in openApiDocument.Paths) + foreach (var apiPathPair in openApiDocument.Paths) { - foreach (var openApiOperation in openApiPath.Value.Operations) + foreach (var apiOperationPair in apiPathPair.Value.Operations) { - if (openApiOperation.Value.Deprecated && !includeDeprecated) + if (apiOperationPair.Value.Deprecated && !includeDeprecated) { continue; } - foreach (var response in openApiOperation.Value.Responses.Values) + foreach (var apiParameter in apiPathPair.Value.Parameters) { - foreach (var mediaType in response.Content.Values) + if (apiParameter.Schema.IsTypeArray()) + { + return true; + } + } + + foreach (var apiParameter in apiOperationPair.Value.Parameters) + { + if (apiParameter.Schema.IsTypeArray()) { - if (mediaType.Schema.IsTypeArray()) + return true; + } + } + + foreach (var apiResponse in apiOperationPair.Value.Responses.Values) + { + foreach (var apiMediaType in apiResponse.Content.Values) + { + if (apiMediaType.Schema.IsTypeArray()) { return true; } + + foreach (var propertyApiSchemaPair in apiMediaType.Schema.Properties) + { + if (propertyApiSchemaPair.IsTypeArray()) + { + return true; + } + + foreach (var oneOfApiSchema in propertyApiSchemaPair.Value.OneOf) + { + if (oneOfApiSchema.IsTypeArray()) + { + return true; + } + + foreach (var oneOfPropertyApiSchemaPair in oneOfApiSchema.Properties) + { + if (oneOfPropertyApiSchemaPair.IsTypeArray()) + { + return true; + } + } + } + } } } } @@ -185,18 +225,18 @@ public static bool IsUsingRequiredForSystemLinq( this OpenApiDocument openApiDocument, bool includeDeprecated) { - foreach (var openApiPath in openApiDocument.Paths) + foreach (var apiPathPair in openApiDocument.Paths) { - foreach (var openApiOperation in openApiPath.Value.Operations) + foreach (var apiOperationPair in apiPathPair.Value.Operations) { - if (openApiOperation.Value.Deprecated && !includeDeprecated) + if (apiOperationPair.Value.Deprecated && !includeDeprecated) { continue; } - foreach (var parameter in openApiOperation.Value.Parameters) + foreach (var apiParameter in apiOperationPair.Value.Parameters) { - if (parameter.Schema.IsTypeArray()) + if (apiParameter.Schema.IsTypeArray()) { return true; } @@ -211,27 +251,27 @@ public static bool IsUsingRequiredForSystemTextJsonSerializationAndSystemRuntime this OpenApiDocument openApiDocument, bool includeDeprecated) { - foreach (var openApiPath in openApiDocument.Paths) + foreach (var apiPathPair in openApiDocument.Paths) { - foreach (var openApiOperation in openApiPath.Value.Operations) + foreach (var apiOperationPair in apiPathPair.Value.Operations) { - if (openApiOperation.Value.Deprecated && !includeDeprecated) + if (apiOperationPair.Value.Deprecated && !includeDeprecated) { continue; } - foreach (var parameter in openApiOperation.Value.Parameters) + foreach (var apiParameter in apiOperationPair.Value.Parameters) { - if (parameter.Schema.IsSchemaEnum()) + if (apiParameter.Schema.IsSchemaEnum()) { - foreach (var openApiAny in parameter.Schema.Enum) + foreach (var apiAny in apiParameter.Schema.Enum) { - if (openApiAny is not OpenApiString openApiString) + if (apiAny is not OpenApiString openApiString) { continue; } - if ((!parameter.Schema.Type.Equals("string", StringComparison.Ordinal) && openApiString.Value.IsFirstCharacterLowerCase()) || + if ((!apiParameter.Schema.Type.Equals("string", StringComparison.Ordinal) && openApiString.Value.IsFirstCharacterLowerCase()) || openApiString.Value.Contains('-', StringComparison.Ordinal)) { return true; @@ -248,13 +288,13 @@ public static bool IsUsingRequiredForSystemTextJsonSerializationAndSystemRuntime public static bool IsUsingRequiredForAtcRestResults( this OpenApiDocument openApiDocument) { - foreach (var path in openApiDocument.Paths) + foreach (var apiPathPair in openApiDocument.Paths) { - foreach (var openApiOperation in path.Value.Operations.Values) + foreach (var openApiOperation in apiPathPair.Value.Operations.Values) { - foreach (var response in openApiOperation.Responses.OrderBy(x => x.GetFormattedKey(), StringComparer.Ordinal)) + foreach (var responsePair in openApiOperation.Responses.OrderBy(x => x.GetFormattedKey(), StringComparer.Ordinal)) { - if (!Enum.TryParse(typeof(HttpStatusCode), response.Key, out var parsedType)) + if (!Enum.TryParse(typeof(HttpStatusCode), responsePair.Key, out var parsedType)) { continue; } @@ -298,14 +338,14 @@ public static bool IsUsingRequiredForMicrosoftAspNetCoreAuthorization( return true; } - foreach (var openApiOperation in openApiPath.Value.Operations) + foreach (var apiOperationPair in openApiPath.Value.Operations) { - if (openApiOperation.Value.Deprecated && !includeDeprecated) + if (apiOperationPair.Value.Deprecated && !includeDeprecated) { continue; } - var isOperationAuthenticationRequired = openApiOperation.Value.Extensions.ExtractAuthenticationRequired(); + var isOperationAuthenticationRequired = apiOperationPair.Value.Extensions.ExtractAuthenticationRequired(); if (isOperationAuthenticationRequired is not null && isOperationAuthenticationRequired.Value) { return true; diff --git a/src/Atc.Rest.ApiGenerator.OpenApi/Extensions/OpenApiKeyValuePairExtensions.cs b/src/Atc.Rest.ApiGenerator.OpenApi/Extensions/OpenApiKeyValuePairExtensions.cs index 9d88207b..8fcdcce3 100644 --- a/src/Atc.Rest.ApiGenerator.OpenApi/Extensions/OpenApiKeyValuePairExtensions.cs +++ b/src/Atc.Rest.ApiGenerator.OpenApi/Extensions/OpenApiKeyValuePairExtensions.cs @@ -3,6 +3,10 @@ namespace Atc.Rest.ApiGenerator.OpenApi.Extensions; public static class OpenApiKeyValuePairExtensions { + public static bool IsTypeArray( + this KeyValuePair value) + => value.Value.IsTypeArray(); + public static string GetFormattedKey( this KeyValuePair value) => value.Key.PascalCase(ApiOperationExtractor.ModelNameSeparators, removeSeparators: true); From 4b9b04a2007f7ef29954ae5276f6e0c5af44a20f Mon Sep 17 00:00:00 2001 From: David Kallesen Date: Thu, 27 Jun 2024 23:33:29 +0200 Subject: [PATCH 6/6] fix: Fix and update integration-tests --- .../Extensions/OpenApiOperationExtensions.cs | 2 +- .../Extractors/ApiOperationExtractor.cs | 2 +- .../EventArgs/GetEventArgByIdEndpointResult.verified.cs | 8 ++++---- .../EventArgs/GetEventArgsEndpointResult.verified.cs | 8 ++++---- .../Interfaces/IGetEventArgByIdEndpointResult.verified.cs | 6 +++--- .../Interfaces/IGetEventArgsEndpointResult.verified.cs | 6 +++--- .../EventArgs/GetEventArgByIdEndpointResult.verified.cs | 8 ++++---- .../EventArgs/GetEventArgsEndpointResult.verified.cs | 8 ++++---- .../Interfaces/IGetEventArgByIdEndpointResult.verified.cs | 6 +++--- .../Interfaces/IGetEventArgsEndpointResult.verified.cs | 6 +++--- .../EventArgs/GetEventArgByIdEndpointResult.verified.cs | 8 ++++---- .../EventArgs/GetEventArgsEndpointResult.verified.cs | 8 ++++---- .../Interfaces/IGetEventArgByIdEndpointResult.verified.cs | 6 +++--- .../Interfaces/IGetEventArgsEndpointResult.verified.cs | 6 +++--- .../EventArgs/GetEventArgByIdEndpointResult.verified.cs | 8 ++++---- .../EventArgs/GetEventArgsEndpointResult.verified.cs | 8 ++++---- .../Interfaces/IGetEventArgByIdEndpointResult.verified.cs | 6 +++--- .../Interfaces/IGetEventArgsEndpointResult.verified.cs | 6 +++--- .../ExUsers.ApiClient.Generated/GlobalUsings.verified.cs | 1 - .../ExUsers.ApiClient.Generated/GlobalUsings.verified.cs | 1 - 20 files changed, 58 insertions(+), 60 deletions(-) diff --git a/src/Atc.Rest.ApiGenerator.OpenApi/Extensions/OpenApiOperationExtensions.cs b/src/Atc.Rest.ApiGenerator.OpenApi/Extensions/OpenApiOperationExtensions.cs index 51514002..a850fbe8 100644 --- a/src/Atc.Rest.ApiGenerator.OpenApi/Extensions/OpenApiOperationExtensions.cs +++ b/src/Atc.Rest.ApiGenerator.OpenApi/Extensions/OpenApiOperationExtensions.cs @@ -160,7 +160,7 @@ public static IEnumerable ExtractApiOperationResponse } else { - foreach (var apiMediaType in apiResponse.Value.Content.Where(x => x.Key.Equals(MediaTypeNames.Application.Json, StringComparison.OrdinalIgnoreCase))) + foreach (var apiMediaType in apiResponse.Value.Content.Where(x => !x.Key.Equals(MediaTypeNames.Application.Xml, StringComparison.OrdinalIgnoreCase))) { if (!apiResponse.Key.TryParseToHttpStatusCode(out var httpStatusCode)) { diff --git a/src/Atc.Rest.ApiGenerator.OpenApi/Extractors/ApiOperationExtractor.cs b/src/Atc.Rest.ApiGenerator.OpenApi/Extractors/ApiOperationExtractor.cs index 46a08396..e78e7735 100644 --- a/src/Atc.Rest.ApiGenerator.OpenApi/Extractors/ApiOperationExtractor.cs +++ b/src/Atc.Rest.ApiGenerator.OpenApi/Extractors/ApiOperationExtractor.cs @@ -113,7 +113,7 @@ private static void ExtractMappingsFromResponses( if (apiResponse.Value.Content.Keys.Count > 0) { - foreach (var apiMediaType in apiResponse.Value.Content.Where(x => x.Key.Equals(MediaTypeNames.Application.Json, StringComparison.OrdinalIgnoreCase))) + foreach (var apiMediaType in apiResponse.Value.Content.Where(x => !x.Key.Equals(MediaTypeNames.Application.Xml, StringComparison.OrdinalIgnoreCase))) { CollectSchema( componentsSchemas, diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyClient/WOPD/src/DemoSample.ApiClient.Generated/Endpoints/EventArgs/GetEventArgByIdEndpointResult.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyClient/WOPD/src/DemoSample.ApiClient.Generated/Endpoints/EventArgs/GetEventArgByIdEndpointResult.verified.cs index eb55aeab..14813875 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyClient/WOPD/src/DemoSample.ApiClient.Generated/Endpoints/EventArgs/GetEventArgByIdEndpointResult.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyClient/WOPD/src/DemoSample.ApiClient.Generated/Endpoints/EventArgs/GetEventArgByIdEndpointResult.verified.cs @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // This code was auto-generated by ApiGenerator x.x.x.x. // // Changes to this file may cause incorrect behavior and will be lost if @@ -31,8 +31,8 @@ public bool IsUnauthorized public bool IsNotFound => StatusCode == HttpStatusCode.NotFound; - public EventArgs OkContent - => IsOk && ContentObject is EventArgs result + public DemoSample.ApiClient.Generated.Contracts.EventArgs.EventArgs OkContent + => IsOk && ContentObject is DemoSample.ApiClient.Generated.Contracts.EventArgs.EventArgs result ? result : throw new InvalidOperationException("Content is not the expected type - please use the IsOk property first."); @@ -50,4 +50,4 @@ public string? NotFoundContent => IsNotFound && ContentObject is string result ? result : throw new InvalidOperationException("Content is not the expected type - please use the IsNotFound property first."); -} +} \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyClient/WOPD/src/DemoSample.ApiClient.Generated/Endpoints/EventArgs/GetEventArgsEndpointResult.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyClient/WOPD/src/DemoSample.ApiClient.Generated/Endpoints/EventArgs/GetEventArgsEndpointResult.verified.cs index 46333393..1c15d9c7 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyClient/WOPD/src/DemoSample.ApiClient.Generated/Endpoints/EventArgs/GetEventArgsEndpointResult.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyClient/WOPD/src/DemoSample.ApiClient.Generated/Endpoints/EventArgs/GetEventArgsEndpointResult.verified.cs @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // This code was auto-generated by ApiGenerator x.x.x.x. // // Changes to this file may cause incorrect behavior and will be lost if @@ -25,8 +25,8 @@ public bool IsOk public bool IsUnauthorized => StatusCode == HttpStatusCode.Unauthorized; - public IEnumerable OkContent - => IsOk && ContentObject is IEnumerable result + public IEnumerable OkContent + => IsOk && ContentObject is IEnumerable result ? result : throw new InvalidOperationException("Content is not the expected type - please use the IsOk property first."); @@ -34,4 +34,4 @@ public string? UnauthorizedContent => IsUnauthorized && ContentObject is string result ? result : throw new InvalidOperationException("Content is not the expected type - please use the IsUnauthorized property first."); -} +} \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyClient/WOPD/src/DemoSample.ApiClient.Generated/Endpoints/EventArgs/Interfaces/IGetEventArgByIdEndpointResult.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyClient/WOPD/src/DemoSample.ApiClient.Generated/Endpoints/EventArgs/Interfaces/IGetEventArgByIdEndpointResult.verified.cs index 9d22c2a3..944b6e04 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyClient/WOPD/src/DemoSample.ApiClient.Generated/Endpoints/EventArgs/Interfaces/IGetEventArgByIdEndpointResult.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyClient/WOPD/src/DemoSample.ApiClient.Generated/Endpoints/EventArgs/Interfaces/IGetEventArgByIdEndpointResult.verified.cs @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // This code was auto-generated by ApiGenerator x.x.x.x. // // Changes to this file may cause incorrect behavior and will be lost if @@ -23,11 +23,11 @@ public interface IGetEventArgByIdEndpointResult : IEndpointResponse bool IsNotFound { get; } - EventArgs OkContent { get; } + DemoSample.ApiClient.Generated.Contracts.EventArgs.EventArgs OkContent { get; } string? BadRequestContent { get; } string? UnauthorizedContent { get; } string? NotFoundContent { get; } -} +} \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyClient/WOPD/src/DemoSample.ApiClient.Generated/Endpoints/EventArgs/Interfaces/IGetEventArgsEndpointResult.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyClient/WOPD/src/DemoSample.ApiClient.Generated/Endpoints/EventArgs/Interfaces/IGetEventArgsEndpointResult.verified.cs index 65b954e6..f9f4dd56 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyClient/WOPD/src/DemoSample.ApiClient.Generated/Endpoints/EventArgs/Interfaces/IGetEventArgsEndpointResult.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyClient/WOPD/src/DemoSample.ApiClient.Generated/Endpoints/EventArgs/Interfaces/IGetEventArgsEndpointResult.verified.cs @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // This code was auto-generated by ApiGenerator x.x.x.x. // // Changes to this file may cause incorrect behavior and will be lost if @@ -19,7 +19,7 @@ public interface IGetEventArgsEndpointResult : IEndpointResponse bool IsUnauthorized { get; } - IEnumerable OkContent { get; } + IEnumerable OkContent { get; } string? UnauthorizedContent { get; } -} +} \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyClient/WPD/src/DemoSample.ApiClient.Generated/Endpoints/EventArgs/GetEventArgByIdEndpointResult.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyClient/WPD/src/DemoSample.ApiClient.Generated/Endpoints/EventArgs/GetEventArgByIdEndpointResult.verified.cs index abdd50bf..77b6f9d6 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyClient/WPD/src/DemoSample.ApiClient.Generated/Endpoints/EventArgs/GetEventArgByIdEndpointResult.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyClient/WPD/src/DemoSample.ApiClient.Generated/Endpoints/EventArgs/GetEventArgByIdEndpointResult.verified.cs @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // This code was auto-generated by ApiGenerator x.x.x.x. // // Changes to this file may cause incorrect behavior and will be lost if @@ -31,8 +31,8 @@ public bool IsUnauthorized public bool IsNotFound => StatusCode == HttpStatusCode.NotFound; - public EventArgs OkContent - => IsOk && ContentObject is EventArgs result + public DemoSample.ApiClient.Generated.Contracts.EventArgs.EventArgs OkContent + => IsOk && ContentObject is DemoSample.ApiClient.Generated.Contracts.EventArgs.EventArgs result ? result : throw new InvalidOperationException("Content is not the expected type - please use the IsOk property first."); @@ -50,4 +50,4 @@ public ProblemDetails NotFoundContent => IsNotFound && ContentObject is ProblemDetails result ? result : throw new InvalidOperationException("Content is not the expected type - please use the IsNotFound property first."); -} +} \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyClient/WPD/src/DemoSample.ApiClient.Generated/Endpoints/EventArgs/GetEventArgsEndpointResult.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyClient/WPD/src/DemoSample.ApiClient.Generated/Endpoints/EventArgs/GetEventArgsEndpointResult.verified.cs index 2b2bb4c4..fe0d8755 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyClient/WPD/src/DemoSample.ApiClient.Generated/Endpoints/EventArgs/GetEventArgsEndpointResult.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyClient/WPD/src/DemoSample.ApiClient.Generated/Endpoints/EventArgs/GetEventArgsEndpointResult.verified.cs @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // This code was auto-generated by ApiGenerator x.x.x.x. // // Changes to this file may cause incorrect behavior and will be lost if @@ -25,8 +25,8 @@ public bool IsOk public bool IsUnauthorized => StatusCode == HttpStatusCode.Unauthorized; - public IEnumerable OkContent - => IsOk && ContentObject is IEnumerable result + public IEnumerable OkContent + => IsOk && ContentObject is IEnumerable result ? result : throw new InvalidOperationException("Content is not the expected type - please use the IsOk property first."); @@ -34,4 +34,4 @@ public ProblemDetails UnauthorizedContent => IsUnauthorized && ContentObject is ProblemDetails result ? result : throw new InvalidOperationException("Content is not the expected type - please use the IsUnauthorized property first."); -} +} \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyClient/WPD/src/DemoSample.ApiClient.Generated/Endpoints/EventArgs/Interfaces/IGetEventArgByIdEndpointResult.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyClient/WPD/src/DemoSample.ApiClient.Generated/Endpoints/EventArgs/Interfaces/IGetEventArgByIdEndpointResult.verified.cs index af73bd3e..9ec09081 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyClient/WPD/src/DemoSample.ApiClient.Generated/Endpoints/EventArgs/Interfaces/IGetEventArgByIdEndpointResult.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyClient/WPD/src/DemoSample.ApiClient.Generated/Endpoints/EventArgs/Interfaces/IGetEventArgByIdEndpointResult.verified.cs @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // This code was auto-generated by ApiGenerator x.x.x.x. // // Changes to this file may cause incorrect behavior and will be lost if @@ -23,11 +23,11 @@ public interface IGetEventArgByIdEndpointResult : IEndpointResponse bool IsNotFound { get; } - EventArgs OkContent { get; } + DemoSample.ApiClient.Generated.Contracts.EventArgs.EventArgs OkContent { get; } ValidationProblemDetails BadRequestContent { get; } ProblemDetails UnauthorizedContent { get; } ProblemDetails NotFoundContent { get; } -} +} \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyClient/WPD/src/DemoSample.ApiClient.Generated/Endpoints/EventArgs/Interfaces/IGetEventArgsEndpointResult.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyClient/WPD/src/DemoSample.ApiClient.Generated/Endpoints/EventArgs/Interfaces/IGetEventArgsEndpointResult.verified.cs index de3de14a..46d28cdc 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyClient/WPD/src/DemoSample.ApiClient.Generated/Endpoints/EventArgs/Interfaces/IGetEventArgsEndpointResult.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyClient/WPD/src/DemoSample.ApiClient.Generated/Endpoints/EventArgs/Interfaces/IGetEventArgsEndpointResult.verified.cs @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // This code was auto-generated by ApiGenerator x.x.x.x. // // Changes to this file may cause incorrect behavior and will be lost if @@ -19,7 +19,7 @@ public interface IGetEventArgsEndpointResult : IEndpointResponse bool IsUnauthorized { get; } - IEnumerable OkContent { get; } + IEnumerable OkContent { get; } ProblemDetails UnauthorizedContent { get; } -} +} \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyClient/WOPD/src/ExNsWithTask.ApiClient.Generated/Endpoints/EventArgs/GetEventArgByIdEndpointResult.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyClient/WOPD/src/ExNsWithTask.ApiClient.Generated/Endpoints/EventArgs/GetEventArgByIdEndpointResult.verified.cs index 6b43a7eb..8a7ace6b 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyClient/WOPD/src/ExNsWithTask.ApiClient.Generated/Endpoints/EventArgs/GetEventArgByIdEndpointResult.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyClient/WOPD/src/ExNsWithTask.ApiClient.Generated/Endpoints/EventArgs/GetEventArgByIdEndpointResult.verified.cs @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // This code was auto-generated by ApiGenerator x.x.x.x. // // Changes to this file may cause incorrect behavior and will be lost if @@ -31,8 +31,8 @@ public bool IsUnauthorized public bool IsNotFound => StatusCode == HttpStatusCode.NotFound; - public EventArgs OkContent - => IsOk && ContentObject is EventArgs result + public ExNsWithTask.ApiClient.Generated.Contracts.EventArgs.EventArgs OkContent + => IsOk && ContentObject is ExNsWithTask.ApiClient.Generated.Contracts.EventArgs.EventArgs result ? result : throw new InvalidOperationException("Content is not the expected type - please use the IsOk property first."); @@ -50,4 +50,4 @@ public string? NotFoundContent => IsNotFound && ContentObject is string result ? result : throw new InvalidOperationException("Content is not the expected type - please use the IsNotFound property first."); -} +} \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyClient/WOPD/src/ExNsWithTask.ApiClient.Generated/Endpoints/EventArgs/GetEventArgsEndpointResult.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyClient/WOPD/src/ExNsWithTask.ApiClient.Generated/Endpoints/EventArgs/GetEventArgsEndpointResult.verified.cs index 20324fb5..a2980c70 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyClient/WOPD/src/ExNsWithTask.ApiClient.Generated/Endpoints/EventArgs/GetEventArgsEndpointResult.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyClient/WOPD/src/ExNsWithTask.ApiClient.Generated/Endpoints/EventArgs/GetEventArgsEndpointResult.verified.cs @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // This code was auto-generated by ApiGenerator x.x.x.x. // // Changes to this file may cause incorrect behavior and will be lost if @@ -25,8 +25,8 @@ public bool IsOk public bool IsUnauthorized => StatusCode == HttpStatusCode.Unauthorized; - public IEnumerable OkContent - => IsOk && ContentObject is IEnumerable result + public IEnumerable OkContent + => IsOk && ContentObject is IEnumerable result ? result : throw new InvalidOperationException("Content is not the expected type - please use the IsOk property first."); @@ -34,4 +34,4 @@ public string? UnauthorizedContent => IsUnauthorized && ContentObject is string result ? result : throw new InvalidOperationException("Content is not the expected type - please use the IsUnauthorized property first."); -} +} \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyClient/WOPD/src/ExNsWithTask.ApiClient.Generated/Endpoints/EventArgs/Interfaces/IGetEventArgByIdEndpointResult.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyClient/WOPD/src/ExNsWithTask.ApiClient.Generated/Endpoints/EventArgs/Interfaces/IGetEventArgByIdEndpointResult.verified.cs index 5e2e6cc9..8ab18cff 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyClient/WOPD/src/ExNsWithTask.ApiClient.Generated/Endpoints/EventArgs/Interfaces/IGetEventArgByIdEndpointResult.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyClient/WOPD/src/ExNsWithTask.ApiClient.Generated/Endpoints/EventArgs/Interfaces/IGetEventArgByIdEndpointResult.verified.cs @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // This code was auto-generated by ApiGenerator x.x.x.x. // // Changes to this file may cause incorrect behavior and will be lost if @@ -23,11 +23,11 @@ public interface IGetEventArgByIdEndpointResult : IEndpointResponse bool IsNotFound { get; } - EventArgs OkContent { get; } + ExNsWithTask.ApiClient.Generated.Contracts.EventArgs.EventArgs OkContent { get; } string? BadRequestContent { get; } string? UnauthorizedContent { get; } string? NotFoundContent { get; } -} +} \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyClient/WOPD/src/ExNsWithTask.ApiClient.Generated/Endpoints/EventArgs/Interfaces/IGetEventArgsEndpointResult.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyClient/WOPD/src/ExNsWithTask.ApiClient.Generated/Endpoints/EventArgs/Interfaces/IGetEventArgsEndpointResult.verified.cs index 31c2424b..e06162cd 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyClient/WOPD/src/ExNsWithTask.ApiClient.Generated/Endpoints/EventArgs/Interfaces/IGetEventArgsEndpointResult.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyClient/WOPD/src/ExNsWithTask.ApiClient.Generated/Endpoints/EventArgs/Interfaces/IGetEventArgsEndpointResult.verified.cs @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // This code was auto-generated by ApiGenerator x.x.x.x. // // Changes to this file may cause incorrect behavior and will be lost if @@ -19,7 +19,7 @@ public interface IGetEventArgsEndpointResult : IEndpointResponse bool IsUnauthorized { get; } - IEnumerable OkContent { get; } + IEnumerable OkContent { get; } string? UnauthorizedContent { get; } -} +} \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyClient/WPD/src/ExNsWithTask.ApiClient.Generated/Endpoints/EventArgs/GetEventArgByIdEndpointResult.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyClient/WPD/src/ExNsWithTask.ApiClient.Generated/Endpoints/EventArgs/GetEventArgByIdEndpointResult.verified.cs index b6e0ec80..db27926b 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyClient/WPD/src/ExNsWithTask.ApiClient.Generated/Endpoints/EventArgs/GetEventArgByIdEndpointResult.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyClient/WPD/src/ExNsWithTask.ApiClient.Generated/Endpoints/EventArgs/GetEventArgByIdEndpointResult.verified.cs @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // This code was auto-generated by ApiGenerator x.x.x.x. // // Changes to this file may cause incorrect behavior and will be lost if @@ -31,8 +31,8 @@ public bool IsUnauthorized public bool IsNotFound => StatusCode == HttpStatusCode.NotFound; - public EventArgs OkContent - => IsOk && ContentObject is EventArgs result + public ExNsWithTask.ApiClient.Generated.Contracts.EventArgs.EventArgs OkContent + => IsOk && ContentObject is ExNsWithTask.ApiClient.Generated.Contracts.EventArgs.EventArgs result ? result : throw new InvalidOperationException("Content is not the expected type - please use the IsOk property first."); @@ -50,4 +50,4 @@ public ProblemDetails NotFoundContent => IsNotFound && ContentObject is ProblemDetails result ? result : throw new InvalidOperationException("Content is not the expected type - please use the IsNotFound property first."); -} +} \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyClient/WPD/src/ExNsWithTask.ApiClient.Generated/Endpoints/EventArgs/GetEventArgsEndpointResult.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyClient/WPD/src/ExNsWithTask.ApiClient.Generated/Endpoints/EventArgs/GetEventArgsEndpointResult.verified.cs index d1644512..a3982b5b 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyClient/WPD/src/ExNsWithTask.ApiClient.Generated/Endpoints/EventArgs/GetEventArgsEndpointResult.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyClient/WPD/src/ExNsWithTask.ApiClient.Generated/Endpoints/EventArgs/GetEventArgsEndpointResult.verified.cs @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // This code was auto-generated by ApiGenerator x.x.x.x. // // Changes to this file may cause incorrect behavior and will be lost if @@ -25,8 +25,8 @@ public bool IsOk public bool IsUnauthorized => StatusCode == HttpStatusCode.Unauthorized; - public IEnumerable OkContent - => IsOk && ContentObject is IEnumerable result + public IEnumerable OkContent + => IsOk && ContentObject is IEnumerable result ? result : throw new InvalidOperationException("Content is not the expected type - please use the IsOk property first."); @@ -34,4 +34,4 @@ public ProblemDetails UnauthorizedContent => IsUnauthorized && ContentObject is ProblemDetails result ? result : throw new InvalidOperationException("Content is not the expected type - please use the IsUnauthorized property first."); -} +} \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyClient/WPD/src/ExNsWithTask.ApiClient.Generated/Endpoints/EventArgs/Interfaces/IGetEventArgByIdEndpointResult.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyClient/WPD/src/ExNsWithTask.ApiClient.Generated/Endpoints/EventArgs/Interfaces/IGetEventArgByIdEndpointResult.verified.cs index 81baed8f..da3943f8 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyClient/WPD/src/ExNsWithTask.ApiClient.Generated/Endpoints/EventArgs/Interfaces/IGetEventArgByIdEndpointResult.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyClient/WPD/src/ExNsWithTask.ApiClient.Generated/Endpoints/EventArgs/Interfaces/IGetEventArgByIdEndpointResult.verified.cs @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // This code was auto-generated by ApiGenerator x.x.x.x. // // Changes to this file may cause incorrect behavior and will be lost if @@ -23,11 +23,11 @@ public interface IGetEventArgByIdEndpointResult : IEndpointResponse bool IsNotFound { get; } - EventArgs OkContent { get; } + ExNsWithTask.ApiClient.Generated.Contracts.EventArgs.EventArgs OkContent { get; } ValidationProblemDetails BadRequestContent { get; } ProblemDetails UnauthorizedContent { get; } ProblemDetails NotFoundContent { get; } -} +} \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyClient/WPD/src/ExNsWithTask.ApiClient.Generated/Endpoints/EventArgs/Interfaces/IGetEventArgsEndpointResult.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyClient/WPD/src/ExNsWithTask.ApiClient.Generated/Endpoints/EventArgs/Interfaces/IGetEventArgsEndpointResult.verified.cs index ec5a59b2..37602756 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyClient/WPD/src/ExNsWithTask.ApiClient.Generated/Endpoints/EventArgs/Interfaces/IGetEventArgsEndpointResult.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyClient/WPD/src/ExNsWithTask.ApiClient.Generated/Endpoints/EventArgs/Interfaces/IGetEventArgsEndpointResult.verified.cs @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // This code was auto-generated by ApiGenerator x.x.x.x. // // Changes to this file may cause incorrect behavior and will be lost if @@ -19,7 +19,7 @@ public interface IGetEventArgsEndpointResult : IEndpointResponse bool IsUnauthorized { get; } - IEnumerable OkContent { get; } + IEnumerable OkContent { get; } ProblemDetails UnauthorizedContent { get; } -} +} \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExUsers/VerifyClient/WOPD/src/ExUsers.ApiClient.Generated/GlobalUsings.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExUsers/VerifyClient/WOPD/src/ExUsers.ApiClient.Generated/GlobalUsings.verified.cs index 3637c8d3..3917b2bd 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExUsers/VerifyClient/WOPD/src/ExUsers.ApiClient.Generated/GlobalUsings.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExUsers/VerifyClient/WOPD/src/ExUsers.ApiClient.Generated/GlobalUsings.verified.cs @@ -10,7 +10,6 @@ global using Atc.Rest.Client; global using Atc.Rest.Client.Builder; -global using ExUsers.ApiClient.Generated.Contracts; global using ExUsers.ApiClient.Generated.Contracts.Users; global using ExUsers.ApiClient.Generated.Endpoints.Users.Interfaces; diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExUsers/VerifyClient/WPD/src/ExUsers.ApiClient.Generated/GlobalUsings.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExUsers/VerifyClient/WPD/src/ExUsers.ApiClient.Generated/GlobalUsings.verified.cs index 3637c8d3..3917b2bd 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExUsers/VerifyClient/WPD/src/ExUsers.ApiClient.Generated/GlobalUsings.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExUsers/VerifyClient/WPD/src/ExUsers.ApiClient.Generated/GlobalUsings.verified.cs @@ -10,7 +10,6 @@ global using Atc.Rest.Client; global using Atc.Rest.Client.Builder; -global using ExUsers.ApiClient.Generated.Contracts; global using ExUsers.ApiClient.Generated.Contracts.Users; global using ExUsers.ApiClient.Generated.Endpoints.Users.Interfaces;