diff --git a/.editorconfig b/.editorconfig index f4587b1eb..d12a6d5b7 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,8 +1,8 @@ # ATC coding rules - https://github.com/atc-net/atc-coding-rules -# Version: 1.0.1 -# Updated: 03-06-2024 +# Version: 1.0.0 +# Updated: 01-03-2025 # Location: Root -# Distribution: DotNet8 +# Distribution: DotNet9 # Inspired by: https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/code-style-rule-options ########################################## @@ -492,6 +492,8 @@ dotnet_diagnostic.CA1867.severity = suggestion # Use char overload dotnet_diagnostic.CA1868.severity = suggestion # Unnecessary call to 'Contains(item)' dotnet_diagnostic.CA1869.severity = suggestion # Cache and reuse 'JsonSerializerOptions' instances dotnet_diagnostic.CA1870.severity = suggestion # Use a cached 'SearchValues' instance +dotnet_diagnostic.CA1871.severity = suggestion # Do not pass a nullable struct to 'ArgumentNullException.ThrowIfNull' +dotnet_diagnostic.CA1872.severity = suggestion # Prefer 'Convert.ToHexString' and 'Convert.ToHexStringLower' over call chains based on 'BitConverter.ToString' dotnet_diagnostic.CA2007.severity = suggestion # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/MicrosoftCodeAnalysis/CA2007.md dotnet_diagnostic.CA2017.severity = error # Parameter count mismatch dotnet_diagnostic.CA2018.severity = error # The count argument to Buffer.BlockCopy should specify the number of bytes to copy @@ -505,6 +507,9 @@ dotnet_diagnostic.CA2255.severity = suggestion # The ModuleInitializer attr dotnet_diagnostic.CA2259.severity = error # Ensure ThreadStatic is only used with static fields dotnet_diagnostic.CA2260.severity = error # Implement generic math interfaces correctly dotnet_diagnostic.CA2261.severity = error # Do not use ConfigureAwaitOptions.SuppressThrowing with Task +dotnet_diagnostic.CA2262.severity = suggestion # Set 'MaxResponseHeadersLength' properly +dotnet_diagnostic.CA2263.severity = suggestion # Prefer generic overload when type is known +dotnet_diagnostic.CA2264.severity = error # Do not pass a non-nullable value to 'ArgumentNullException.ThrowIfNull' dotnet_diagnostic.IDE0005.severity = warning # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/MicrosoftCodeAnalysis/IDE0005.md dotnet_diagnostic.IDE0010.severity = suggestion # Populate switch dotnet_diagnostic.IDE0028.severity = suggestion # Collection initialization can be simplified @@ -556,6 +561,7 @@ dotnet_diagnostic.S3358.severity = none # Extract this nested ternary dotnet_diagnostic.S6602.severity = none # "Find" method should be used instead of the "FirstOrDefault" dotnet_diagnostic.S6603.severity = none # The collection-specific "TrueForAll" method should be used instead of the "All" dotnet_diagnostic.S6605.severity = none # Collection-specific "Exists" method should be used instead of the "Any" +dotnet_diagnostic.S6964.severity = none # Value type property used as input in a controller action should be nullable, required or annotated with the JsonRequiredAttribute to avoid under-posting. ########################################## diff --git a/.github/workflows/post-integration.yml b/.github/workflows/post-integration.yml index 3da1ce8d8..e4acefa7f 100644 --- a/.github/workflows/post-integration.yml +++ b/.github/workflows/post-integration.yml @@ -4,13 +4,13 @@ on: push: branches: - main - - '!stable' - - '!release' + - "!stable" + - "!release" env: - ATC_EMAIL: 'atcnet.org@gmail.com' - ATC_NAME: 'Atc-Net' - NUGET_REPO_URL: 'https://nuget.pkg.github.com/atc-net/index.json' + ATC_EMAIL: "atcnet.org@gmail.com" + ATC_NAME: "Atc-Net" + NUGET_REPO_URL: "https://nuget.pkg.github.com/atc-net/index.json" jobs: merge-to-stable: @@ -30,16 +30,16 @@ jobs: with: setAllVars: true - - name: ⚙️ Setup dotnet 8.0.x + - name: ⚙️ Setup dotnet 9.0.x uses: actions/setup-dotnet@v4 with: - dotnet-version: '8.0.x' + dotnet-version: "9.0.x" - name: ⚙️ Set up JDK 17 uses: actions/setup-java@v3 with: java-version: 17 - distribution: 'zulu' + distribution: "zulu" - name: 🧹 Clean run: dotnet clean -c Release && dotnet nuget locals all --clear diff --git a/.github/workflows/pre-integration.yml b/.github/workflows/pre-integration.yml index ec0d911b0..5b2ba46d4 100644 --- a/.github/workflows/pre-integration.yml +++ b/.github/workflows/pre-integration.yml @@ -20,10 +20,10 @@ jobs: with: fetch-depth: 0 - - name: ⚙️ Setup dotnet 8.0.x + - name: ⚙️ Setup dotnet 9.0.x uses: actions/setup-dotnet@v4 with: - dotnet-version: '8.0.x' + dotnet-version: "9.0.x" - name: 📐 Ensure nuget.org added as package source on Windows if: matrix.os == 'windows-latest' @@ -46,10 +46,10 @@ jobs: with: fetch-depth: 0 - - name: ⚙️ Setup dotnet 8.0.x + - name: ⚙️ Setup dotnet 9.0.x uses: actions/setup-dotnet@v4 with: - dotnet-version: '8.0.x' + dotnet-version: "9.0.x" - name: 🔁 Restore packages run: dotnet restore @@ -74,10 +74,10 @@ jobs: with: fetch-depth: 0 - - name: ⚙️ Setup dotnet 8.0.x + - name: ⚙️ Setup dotnet 9.0.x uses: actions/setup-dotnet@v4 with: - dotnet-version: '8.0.x' + dotnet-version: "9.0.x" - name: 📐 Ensure nuget.org added as package source on Windows if: matrix.os == 'windows-latest' @@ -99,4 +99,4 @@ jobs: - name: 🛠️ Build Generated Code run: dotnet build - working-directory: petstore3 \ No newline at end of file + working-directory: petstore3 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5043ea7e6..d0b31cc50 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,9 +4,9 @@ on: workflow_dispatch: env: - ATC_EMAIL: 'atcnet.org@gmail.com' - ATC_NAME: 'Atc-Net' - NUGET_REPO_URL: 'https://api.nuget.org/v3/index.json' + ATC_EMAIL: "atcnet.org@gmail.com" + ATC_NAME: "Atc-Net" + NUGET_REPO_URL: "https://api.nuget.org/v3/index.json" jobs: release: @@ -27,10 +27,10 @@ jobs: with: setAllVars: true - - name: ⚙️ Setup dotnet 8.0.x + - name: ⚙️ Setup dotnet 9.0.x uses: actions/setup-dotnet@v4 with: - dotnet-version: '8.0.x' + dotnet-version: "9.0.x" - name: 🧹 Clean run: dotnet clean -c Release && dotnet nuget locals all --clear @@ -61,4 +61,4 @@ jobs: uses: satak/webrequest-action@master with: url: https://atc-api.azurewebsites.net/nuget-search/package?packageId=atc-rest-api-generator&invalidateCache=true - method: GET \ No newline at end of file + method: GET diff --git a/Directory.Build.props b/Directory.Build.props index c483a1a4c..bc2b6719a 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -18,7 +18,7 @@ enable 12.0 enable - net8.0 + net9.0 true 1573,1591,1712 @@ -43,10 +43,10 @@ - + - + \ No newline at end of file diff --git a/README.md b/README.md index edf389019..076c9e134 100644 --- a/README.md +++ b/README.md @@ -42,17 +42,17 @@ |Project|Target Framework|Description|Nuget Download Link| |---|---|---|---| -|[Atc.Rest.ApiGenerator](src/Atc.Rest.ApiGenerator) | net8.0 | Atc.Rest.ApiGenerator is a WebApi C# code generator using a OpenApi 3.0.x specification YAML file. | [![Nuget](https://img.shields.io/nuget/dt/Atc.Rest.ApiGenerator?logo=nuget&style=flat-square)](https://www.nuget.org/packages/Atc.Rest.ApiGenerator) | -|[Atc.Rest.ApiGenerator.CLI](src/Atc.Rest.ApiGenerator.CLI) |net8.0 | A CLI tool that use Atc.Rest.ApiGenerator to create/update a project specified by a OpenApi 3.0.x specification YAML file. | [![Nuget](https://img.shields.io/nuget/dt/atc-rest-api-generator?logo=nuget&style=flat-square)](https://www.nuget.org/packages/atc-rest-api-generator) | -|[Atc.Rest.ApiGenerator.CodingRules](src/Atc.Rest.ApiGenerator.CodingRules) | net8.0| Create/update atc coding rules for the generated code | | -|[Atc.Rest.ApiGenerator.Contracts](src/Atc.Rest.ApiGenerator.Contracts) | net8.0| Shared contracts and interfaces for the generated code. | | -|[Atc.Rest.ApiGenerator.Framework.Mvc](src/Atc.Rest.ApiGenerator.Framework.Mvc) | net8.0| Provides support for generating ASP.NET MVC / Controller based REST API server implementations. | | -|[Atc.Rest.ApiGenerator.Framework.Minimal](src/Atc.Rest.ApiGenerator.Framework.Minimal) | net8.0| Provides support for generating MinimalAPI based REST server implementations. | | -|[Atc.Rest.ApiGenerator.Client.CSharp](src/Atc.Rest.ApiGenerator.Client.CSharp) | net8.0| Generates C# client code for interacting with the generated REST APIs. | | -|[Atc.Rest.ApiGenerator.Framework](src/Atc.Rest.ApiGenerator.Framework) | net8.0| Shared framework components and utilities for the API generator projects. | | -|[Atc.Rest.ApiGenerator.OpenApi](src/Atc.Rest.ApiGenerator.OpenApi) | net8.0| Handles OpenAPI specification parsing and manipulation for the API generator. | | -|[Atc.Rest.ApiGenerator.Nuget](src/Atc.Rest.ApiGenerator.Nuget) | net8.0| Manages NuGet packages required by the generated code and frameworks. | | -|[Atc.CodeGeneration.CSharp](src/Atc.CodeGeneration.CSharp) | net8.0| Provides utilities and functionalities for generating C# code. | | +|[Atc.Rest.ApiGenerator](src/Atc.Rest.ApiGenerator) | net9.0 | Atc.Rest.ApiGenerator is a WebApi C# code generator using a OpenApi 3.0.x specification YAML file. | [![Nuget](https://img.shields.io/nuget/dt/Atc.Rest.ApiGenerator?logo=nuget&style=flat-square)](https://www.nuget.org/packages/Atc.Rest.ApiGenerator) | +|[Atc.Rest.ApiGenerator.CLI](src/Atc.Rest.ApiGenerator.CLI) |net9.0 | A CLI tool that use Atc.Rest.ApiGenerator to create/update a project specified by a OpenApi 3.0.x specification YAML file. | [![Nuget](https://img.shields.io/nuget/dt/atc-rest-api-generator?logo=nuget&style=flat-square)](https://www.nuget.org/packages/atc-rest-api-generator) | +|[Atc.Rest.ApiGenerator.CodingRules](src/Atc.Rest.ApiGenerator.CodingRules) | net9.0| Create/update atc coding rules for the generated code | | +|[Atc.Rest.ApiGenerator.Contracts](src/Atc.Rest.ApiGenerator.Contracts) | net9.0| Shared contracts and interfaces for the generated code. | | +|[Atc.Rest.ApiGenerator.Framework.Mvc](src/Atc.Rest.ApiGenerator.Framework.Mvc) | net9.0| Provides support for generating ASP.NET MVC / Controller based REST API server implementations. | | +|[Atc.Rest.ApiGenerator.Framework.Minimal](src/Atc.Rest.ApiGenerator.Framework.Minimal) | net9.0| Provides support for generating MinimalAPI based REST server implementations. | | +|[Atc.Rest.ApiGenerator.Client.CSharp](src/Atc.Rest.ApiGenerator.Client.CSharp) | net9.0| Generates C# client code for interacting with the generated REST APIs. | | +|[Atc.Rest.ApiGenerator.Framework](src/Atc.Rest.ApiGenerator.Framework) | net9.0| Shared framework components and utilities for the API generator projects. | | +|[Atc.Rest.ApiGenerator.OpenApi](src/Atc.Rest.ApiGenerator.OpenApi) | net9.0| Handles OpenAPI specification parsing and manipulation for the API generator. | | +|[Atc.Rest.ApiGenerator.Nuget](src/Atc.Rest.ApiGenerator.Nuget) | net9.0| Manages NuGet packages required by the generated code and frameworks. | | +|[Atc.CodeGeneration.CSharp](src/Atc.CodeGeneration.CSharp) | net9.0| Provides utilities and functionalities for generating C# code. | | ## Project dependency graph @@ -512,23 +512,23 @@ Running the above command produces the following output: 🟢 root: atc-coding-rules-updater.json created 🟢 root: atc-coding-rules-updater.ps1 created 🐭 Working on EditorConfig files - Download from: [GitHub] /atc-net/atc-coding-rules/main/distribution/dotnet8/.editorconfig + Download from: [GitHub] /atc-net/atc-coding-rules/main/distribution/dotnet9/.editorconfig Download time: 27.947 ms 🟢 root: .editorconfig created - Download from: [GitHub] /atc-net/atc-coding-rules/main/distribution/dotnet8/src/.editorconfig + Download from: [GitHub] /atc-net/atc-coding-rules/main/distribution/dotnet9/src/.editorconfig Download time: 22.987 ms 🟢 src: .editorconfig created - Download from: [GitHub] /atc-net/atc-coding-rules/main/distribution/dotnet8/test/.editorconfig + Download from: [GitHub] /atc-net/atc-coding-rules/main/distribution/dotnet9/test/.editorconfig Download time: 24.465 ms 🟢 test: .editorconfig created 🔨 Working on Directory.Build.props files - Download from: [GitHub] /atc-net/atc-coding-rules/main/distribution/dotnet8/Directory.Build.props + Download from: [GitHub] /atc-net/atc-coding-rules/main/distribution/dotnet9/Directory.Build.props Download time: 20.880 ms 🟢 root: Directory.Build.props created - Download from: [GitHub] /atc-net/atc-coding-rules/main/distribution/dotnet8/src/Directory.Build.props + Download from: [GitHub] /atc-net/atc-coding-rules/main/distribution/dotnet9/src/Directory.Build.props Download time: 48.340 ms 🟢 src: Directory.Build.props created - Download from: [GitHub] /atc-net/atc-coding-rules/main/distribution/dotnet8/test/Directory.Build.props + Download from: [GitHub] /atc-net/atc-coding-rules/main/distribution/dotnet9/test/Directory.Build.props Download time: 29.480 ms 🟢 test: Directory.Build.props created ✅ Done diff --git a/atc-coding-rules-updater.json b/atc-coding-rules-updater.json index 65e3cb360..4fd353e04 100644 --- a/atc-coding-rules-updater.json +++ b/atc-coding-rules-updater.json @@ -1,5 +1,5 @@ { - "projectTarget": "DotNet8", + "projectTarget": "Dotnet9", "useLatestMinorNugetVersion": true, "useTemporarySuppressions": false, "temporarySuppressionAsExcel": false, diff --git a/src/.editorconfig b/src/.editorconfig index e0c0f9a98..2a30b594a 100644 --- a/src/.editorconfig +++ b/src/.editorconfig @@ -1,8 +1,8 @@ # ATC coding rules - https://github.com/atc-net/atc-coding-rules # Version: 1.0.0 -# Updated: 25-09-2023 +# Updated: 03-06-2024 # Location: src -# Distribution: DotNet8 +# Distribution: DotNet9 # Inspired by: https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/code-style-rule-options ########################################## diff --git a/src/Atc.CodeGeneration.CSharp/Atc.CodeGeneration.CSharp.csproj b/src/Atc.CodeGeneration.CSharp/Atc.CodeGeneration.CSharp.csproj index 7a5a2cda6..f6aa95c89 100644 --- a/src/Atc.CodeGeneration.CSharp/Atc.CodeGeneration.CSharp.csproj +++ b/src/Atc.CodeGeneration.CSharp/Atc.CodeGeneration.CSharp.csproj @@ -1,14 +1,18 @@ - net8.0 + net9.0 false - - - + + + + + + + \ No newline at end of file diff --git a/src/Atc.CodeGeneration.CSharp/Content/DeclarationModifiers.cs b/src/Atc.CodeGeneration.CSharp/Content/DeclarationModifiers.cs index bb34dfd2f..f4af5c9d0 100644 --- a/src/Atc.CodeGeneration.CSharp/Content/DeclarationModifiers.cs +++ b/src/Atc.CodeGeneration.CSharp/Content/DeclarationModifiers.cs @@ -55,6 +55,9 @@ public enum DeclarationModifiers [Description("private async")] PrivateAsync, + [Description("private static async")] + PrivateStaticAsync, + [Description("protected")] Protected, diff --git a/src/Atc.Rest.ApiGenerator.CLI/Atc.Rest.ApiGenerator.CLI.csproj b/src/Atc.Rest.ApiGenerator.CLI/Atc.Rest.ApiGenerator.CLI.csproj index 052874b12..b7721d64a 100644 --- a/src/Atc.Rest.ApiGenerator.CLI/Atc.Rest.ApiGenerator.CLI.csproj +++ b/src/Atc.Rest.ApiGenerator.CLI/Atc.Rest.ApiGenerator.CLI.csproj @@ -1,7 +1,7 @@ - net8.0 + net9.0 atc-rest-api-generator rest;api;netstandard;generator A .NET Core Web API C# code generator using a OpenApi 3.0.x specification YAML file. @@ -13,9 +13,9 @@ - - - + + + diff --git a/src/Atc.Rest.ApiGenerator.CLI/Program.cs b/src/Atc.Rest.ApiGenerator.CLI/Program.cs index 780176c60..418bf7378 100644 --- a/src/Atc.Rest.ApiGenerator.CLI/Program.cs +++ b/src/Atc.Rest.ApiGenerator.CLI/Program.cs @@ -113,7 +113,7 @@ private static string[] SetHelpArgumentIfNeeded( { if (args.Length == 0) { - return new[] { CommandConstants.ArgumentShortHelp }; + return [CommandConstants.ArgumentShortHelp]; } // TODO: Add multiple validations diff --git a/src/Atc.Rest.ApiGenerator.Client.CSharp/Atc.Rest.ApiGenerator.Client.CSharp.csproj b/src/Atc.Rest.ApiGenerator.Client.CSharp/Atc.Rest.ApiGenerator.Client.CSharp.csproj index 5f57560b3..d9e992bc6 100644 --- a/src/Atc.Rest.ApiGenerator.Client.CSharp/Atc.Rest.ApiGenerator.Client.CSharp.csproj +++ b/src/Atc.Rest.ApiGenerator.Client.CSharp/Atc.Rest.ApiGenerator.Client.CSharp.csproj @@ -1,13 +1,13 @@ - net8.0 + net9.0 false - - + + diff --git a/src/Atc.Rest.ApiGenerator.Client.CSharp/ContentGenerators/ContentGeneratorClientEndpoint.cs b/src/Atc.Rest.ApiGenerator.Client.CSharp/ContentGenerators/ContentGeneratorClientEndpoint.cs index e21058dae..d0da3238e 100644 --- a/src/Atc.Rest.ApiGenerator.Client.CSharp/ContentGenerators/ContentGeneratorClientEndpoint.cs +++ b/src/Atc.Rest.ApiGenerator.Client.CSharp/ContentGenerators/ContentGeneratorClientEndpoint.cs @@ -141,9 +141,9 @@ public string Generate() case HttpStatusCode.Continue: case HttpStatusCode.SwitchingProtocols: case HttpStatusCode.Processing: - case HttpStatusCode.EarlyHints: case HttpStatusCode.Created: case HttpStatusCode.Accepted: + case HttpStatusCode.EarlyHints: case HttpStatusCode.NonAuthoritativeInformation: case HttpStatusCode.NoContent: case HttpStatusCode.ResetContent: diff --git a/src/Atc.Rest.ApiGenerator.Client.CSharp/ContentGenerators/ContentGeneratorClientEndpointResult.cs b/src/Atc.Rest.ApiGenerator.Client.CSharp/ContentGenerators/ContentGeneratorClientEndpointResult.cs index adde55417..1434cb321 100644 --- a/src/Atc.Rest.ApiGenerator.Client.CSharp/ContentGenerators/ContentGeneratorClientEndpointResult.cs +++ b/src/Atc.Rest.ApiGenerator.Client.CSharp/ContentGenerators/ContentGeneratorClientEndpointResult.cs @@ -250,14 +250,12 @@ private void AppendContentWithProblemDetails( sb.AppendLine(12, "? result"); sb.AppendLine(12, $": throw new InvalidOperationException(\"Content is not the expected type - please use the Is{responseModel.StatusCode.ToNormalizedString()} property first.\");"); break; - case HttpStatusCode.EarlyHints: - // Skip. - break; case HttpStatusCode.Continue: case HttpStatusCode.SwitchingProtocols: case HttpStatusCode.Processing: case HttpStatusCode.Created: case HttpStatusCode.Accepted: + case HttpStatusCode.EarlyHints: case HttpStatusCode.NonAuthoritativeInformation: case HttpStatusCode.NoContent: case HttpStatusCode.ResetContent: @@ -341,14 +339,12 @@ private void AppendContentWithoutProblemDetails( sb.AppendLine(); AppendMethodContentStatusCodeOk(sb, responseModel); break; - case HttpStatusCode.EarlyHints: - // Skip. - break; case HttpStatusCode.Continue: case HttpStatusCode.SwitchingProtocols: case HttpStatusCode.Processing: case HttpStatusCode.Created: case HttpStatusCode.Accepted: + case HttpStatusCode.EarlyHints: case HttpStatusCode.NonAuthoritativeInformation: case HttpStatusCode.NoContent: case HttpStatusCode.ResetContent: diff --git a/src/Atc.Rest.ApiGenerator.Client.CSharp/ContentGenerators/ContentGeneratorClientEndpointResultInterface.cs b/src/Atc.Rest.ApiGenerator.Client.CSharp/ContentGenerators/ContentGeneratorClientEndpointResultInterface.cs index 8fda829d5..41374b661 100644 --- a/src/Atc.Rest.ApiGenerator.Client.CSharp/ContentGenerators/ContentGeneratorClientEndpointResultInterface.cs +++ b/src/Atc.Rest.ApiGenerator.Client.CSharp/ContentGenerators/ContentGeneratorClientEndpointResultInterface.cs @@ -219,14 +219,12 @@ private void AppendContentWithProblemDetails( sb.AppendLine(); sb.AppendLine(4, $"ValidationProblemDetails {responseModel.StatusCode.ToNormalizedString()}Content {{ get; }}"); break; - case HttpStatusCode.EarlyHints: - // Skip. - break; case HttpStatusCode.Continue: case HttpStatusCode.SwitchingProtocols: case HttpStatusCode.Processing: case HttpStatusCode.Created: case HttpStatusCode.Accepted: + case HttpStatusCode.EarlyHints: case HttpStatusCode.NonAuthoritativeInformation: case HttpStatusCode.NoContent: case HttpStatusCode.ResetContent: @@ -307,14 +305,12 @@ private void AppendContentWithoutProblemDetails( sb.AppendLine(); AppendMethodContentStatusCodeOk(sb, responseModel); break; - case HttpStatusCode.EarlyHints: - // Skip. - break; case HttpStatusCode.Continue: case HttpStatusCode.SwitchingProtocols: case HttpStatusCode.Processing: case HttpStatusCode.Created: case HttpStatusCode.Accepted: + case HttpStatusCode.EarlyHints: case HttpStatusCode.NonAuthoritativeInformation: case HttpStatusCode.NoContent: case HttpStatusCode.ResetContent: diff --git a/src/Atc.Rest.ApiGenerator.Client.CSharp/ProjectGenerator/ClientCSharpApiGenerator.cs b/src/Atc.Rest.ApiGenerator.Client.CSharp/ProjectGenerator/ClientCSharpApiGenerator.cs index 54c7d9173..859b15239 100644 --- a/src/Atc.Rest.ApiGenerator.Client.CSharp/ProjectGenerator/ClientCSharpApiGenerator.cs +++ b/src/Atc.Rest.ApiGenerator.Client.CSharp/ProjectGenerator/ClientCSharpApiGenerator.cs @@ -62,7 +62,7 @@ public async Task ScaffoldProjectFile() "Microsoft.NET.Sdk", [ [ - new("TargetFramework", Attributes: null, "net8.0"), + new("TargetFramework", Attributes: null, "net9.0"), new("Nullable", Attributes: null, "enable"), new("IsPackable", Attributes: null, "false"), ], @@ -70,7 +70,7 @@ public async Task ScaffoldProjectFile() new("GenerateDocumentationFile", Attributes: null, "true"), ], [ - new("DocumentationFile", Attributes: null, @$"bin\Debug\net8.0\{settings.ProjectName}.xml"), + new("DocumentationFile", Attributes: null, @$"bin\Debug\net9.0\{settings.ProjectName}.xml"), new("NoWarn", Attributes: null, "$(NoWarn);1573;1591;1701;1702;1712;8618;"), ], ], diff --git a/src/Atc.Rest.ApiGenerator.CodingRules/Atc.Rest.ApiGenerator.CodingRules.csproj b/src/Atc.Rest.ApiGenerator.CodingRules/Atc.Rest.ApiGenerator.CodingRules.csproj index 89537e251..876d3617f 100644 --- a/src/Atc.Rest.ApiGenerator.CodingRules/Atc.Rest.ApiGenerator.CodingRules.csproj +++ b/src/Atc.Rest.ApiGenerator.CodingRules/Atc.Rest.ApiGenerator.CodingRules.csproj @@ -1,13 +1,13 @@ - net8.0 + net9.0 false - - + + diff --git a/src/Atc.Rest.ApiGenerator.CodingRules/AtcCodingRulesUpdater.cs b/src/Atc.Rest.ApiGenerator.CodingRules/AtcCodingRulesUpdater.cs index 12dec118e..4cd205b27 100644 --- a/src/Atc.Rest.ApiGenerator.CodingRules/AtcCodingRulesUpdater.cs +++ b/src/Atc.Rest.ApiGenerator.CodingRules/AtcCodingRulesUpdater.cs @@ -9,7 +9,7 @@ public sealed partial class AtcCodingRulesUpdater : IAtcCodingRulesUpdater public const string GitRawContentUrl = "https://raw.githubusercontent.com"; public const string GitHubPrefix = "[silver][[GitHub]][/] "; - private const string RawCodingRulesDistributionUrl = "https://raw.githubusercontent.com/atc-net/atc-coding-rules/main/distribution/dotnet8"; + private const string RawCodingRulesDistributionUrl = "https://raw.githubusercontent.com/atc-net/atc-coding-rules/main/distribution/dotnet9"; public const string FileNameEditorConfig = ".editorconfig"; public const string FileNameDirectoryBuildProps = "Directory.Build.props"; @@ -111,7 +111,7 @@ private void HandleAtcCodingRulesJson( { var sb = new StringBuilder(); sb.AppendLine("{"); - sb.AppendLine(" \"projectTarget\": \"DotNet8\","); + sb.AppendLine(" \"projectTarget\": \"Dotnet9\","); sb.AppendLine(" \"mappings\": {"); sb.Append(" \"src\": { \"paths\": [ \""); diff --git a/src/Atc.Rest.ApiGenerator.Contracts/Atc.Rest.ApiGenerator.Contracts.csproj b/src/Atc.Rest.ApiGenerator.Contracts/Atc.Rest.ApiGenerator.Contracts.csproj index 1d1e14174..087c299a7 100644 --- a/src/Atc.Rest.ApiGenerator.Contracts/Atc.Rest.ApiGenerator.Contracts.csproj +++ b/src/Atc.Rest.ApiGenerator.Contracts/Atc.Rest.ApiGenerator.Contracts.csproj @@ -1,17 +1,21 @@ - net8.0 + net9.0 false - - + + + + + + diff --git a/src/Atc.Rest.ApiGenerator.Contracts/Extensions/ApiOperationResponseModelExtensions.cs b/src/Atc.Rest.ApiGenerator.Contracts/Extensions/ApiOperationResponseModelExtensions.cs index d63dab547..5b152547e 100644 --- a/src/Atc.Rest.ApiGenerator.Contracts/Extensions/ApiOperationResponseModelExtensions.cs +++ b/src/Atc.Rest.ApiGenerator.Contracts/Extensions/ApiOperationResponseModelExtensions.cs @@ -156,9 +156,11 @@ public static IEnumerable AppendBadRequestIfNeeded( public static IEnumerable AdjustNamespacesIfNeeded( this IEnumerable responseModels, - IList operationSchemaMappings) + IList operationSchemaMappings, + string contractNamespace) { - if (responseModels is null) + if (responseModels is null || + contractNamespace is null) { return Array.Empty(); } @@ -170,22 +172,16 @@ public static IEnumerable AdjustNamespacesIfNeeded( model.DataType.IsWellKnownSystemTypeName()) { var operationSchemaMapping = operationSchemaMappings.First(x => x.Model.Name == model.DataType); - if (operationSchemaMapping.Model.IsShared) - { - models.Add( - model with - { - DataType = $"{ContentGeneratorConstants.Contracts}.{model.DataType}", - }); - } - else - { - models.Add( - model with - { - DataType = $"{ContentGeneratorConstants.Contracts}.{operationSchemaMapping.ApiGroupName}.{model.DataType}", - }); - } + + contractNamespace = operationSchemaMapping.Model.IsShared + ? contractNamespace.Replace("[[apiGroupName]]", string.Empty, StringComparison.Ordinal).Trim('.') + : contractNamespace.Replace("[[apiGroupName]]", operationSchemaMapping.ApiGroupName, StringComparison.Ordinal); + + models.Add( + model with + { + DataType = $"{contractNamespace}.{model.DataType}", + }); } else { diff --git a/src/Atc.Rest.ApiGenerator.Framework.Minimal/Atc.Rest.ApiGenerator.Framework.Minimal.csproj b/src/Atc.Rest.ApiGenerator.Framework.Minimal/Atc.Rest.ApiGenerator.Framework.Minimal.csproj index 0c72b448d..9a4d605fe 100644 --- a/src/Atc.Rest.ApiGenerator.Framework.Minimal/Atc.Rest.ApiGenerator.Framework.Minimal.csproj +++ b/src/Atc.Rest.ApiGenerator.Framework.Minimal/Atc.Rest.ApiGenerator.Framework.Minimal.csproj @@ -1,12 +1,12 @@ - net8.0 + net9.0 false - + diff --git a/src/Atc.Rest.ApiGenerator.Framework.Minimal/ContentGenerators/ContentGeneratorServerProgram.cs b/src/Atc.Rest.ApiGenerator.Framework.Minimal/ContentGenerators/ContentGeneratorServerProgram.cs index ef6580522..2ce327af2 100644 --- a/src/Atc.Rest.ApiGenerator.Framework.Minimal/ContentGenerators/ContentGeneratorServerProgram.cs +++ b/src/Atc.Rest.ApiGenerator.Framework.Minimal/ContentGenerators/ContentGeneratorServerProgram.cs @@ -84,9 +84,9 @@ public string Generate() if (SwaggerThemeMode != SwaggerThemeMode.None) { sb.AppendLine(8, "app.ConfigureSwagger(builder.Environment.ApplicationName);"); + sb.AppendLine(); } - sb.AppendLine(); sb.AppendLine(8, "app.UseHttpsRedirection();"); sb.AppendLine(8, "app.UseHsts();"); sb.AppendLine(); diff --git a/src/Atc.Rest.ApiGenerator.Framework.Minimal/ContentGenerators/ContentGeneratorServerResult.cs b/src/Atc.Rest.ApiGenerator.Framework.Minimal/ContentGenerators/ContentGeneratorServerResult.cs index 99421df34..4e604d632 100644 --- a/src/Atc.Rest.ApiGenerator.Framework.Minimal/ContentGenerators/ContentGeneratorServerResult.cs +++ b/src/Atc.Rest.ApiGenerator.Framework.Minimal/ContentGenerators/ContentGeneratorServerResult.cs @@ -99,7 +99,13 @@ private void AppendMethodContentStatusCodeOk( ContentGeneratorServerResultMethodParameters item, string resultName) { - // TODO: byte[] bytes, string fileName + if (item.ResponseModel.MediaType is not null && + item.ResponseModel.MediaType != MediaTypeNames.Application.Json) + { + sb.AppendLine(4, $"public static {resultName} Ok(byte[] bytes, string contentType, string fileName)"); + sb.AppendLine(8, "=> new(TypedResults.Bytes(bytes, contentType, fileName));"); + return; + } if (string.IsNullOrEmpty(item.ResponseModel.DataType)) { @@ -108,21 +114,28 @@ private void AppendMethodContentStatusCodeOk( return; } - if (item.ResponseModel.UseAsyncEnumerable) + if (string.IsNullOrEmpty(item.ResponseModel.CollectionDataType)) { - sb.AppendLine( - 4, - string.IsNullOrEmpty(item.ResponseModel.CollectionDataType) - ? $"public static {resultName} Ok(IAsyncEnumerable<{item.ResponseModel.DataType}> result)" - : $"public static {resultName} Ok(IAsyncEnumerable<{item.ResponseModel.CollectionDataType}<{item.ResponseModel.DataType}>> result)"); + sb.AppendLine(4, $"public static {resultName} Ok({item.ResponseModel.DataType} result)"); } else { - sb.AppendLine( - 4, - string.IsNullOrEmpty(item.ResponseModel.CollectionDataType) - ? $"public static {resultName} Ok({item.ResponseModel.DataType} result)" - : $"public static {resultName} Ok({item.ResponseModel.CollectionDataType}<{item.ResponseModel.DataType}> result)"); + if (item.ResponseModel.UseAsyncEnumerable) + { + sb.AppendLine( + 4, + item.ResponseModel.CollectionDataType == NameConstants.List + ? $"public static {resultName} Ok(IAsyncEnumerable<{item.ResponseModel.DataType}> result)" + : $"public static {resultName} Ok(IAsyncEnumerable<{item.ResponseModel.CollectionDataType}<{item.ResponseModel.DataType}>> result)"); + } + else + { + sb.AppendLine( + 4, + item.ResponseModel.CollectionDataType == NameConstants.List + ? $"public static {resultName} Ok(IEnumerable<{item.ResponseModel.DataType}> result)" + : $"public static {resultName} Ok({item.ResponseModel.CollectionDataType}<{item.ResponseModel.DataType}> result)"); + } } sb.AppendLine(8, "=> new(TypedResults.Ok(result));"); diff --git a/src/Atc.Rest.ApiGenerator.Framework.Minimal/ContentGenerators/ContentGeneratorServerWebApplicationExtensions.cs b/src/Atc.Rest.ApiGenerator.Framework.Minimal/ContentGenerators/ContentGeneratorServerWebApplicationExtensions.cs index 537333790..9d0cc1e72 100644 --- a/src/Atc.Rest.ApiGenerator.Framework.Minimal/ContentGenerators/ContentGeneratorServerWebApplicationExtensions.cs +++ b/src/Atc.Rest.ApiGenerator.Framework.Minimal/ContentGenerators/ContentGeneratorServerWebApplicationExtensions.cs @@ -21,6 +21,7 @@ public string Generate() sb.AppendLine(); sb.AppendLine("public static class WebApplicationExtensions"); sb.AppendLine("{"); + sb.AppendLine(4, "[SuppressMessage(\"Spacing Rules\", \"SA1010:Opening Square Brackets Must Be Spaced Correctly\", Justification = \"OK.\")]"); sb.AppendLine(4, "private static readonly string[] PatchHttpMethods = [\"patch\"];"); sb.AppendLine(); sb.AppendLine(4, "public static RouteHandlerBuilder MapPatch("); diff --git a/src/Atc.Rest.ApiGenerator.Framework.Minimal/Factories/ContentGeneratorServerResultParametersFactory.cs b/src/Atc.Rest.ApiGenerator.Framework.Minimal/Factories/ContentGeneratorServerResultParametersFactory.cs index f295b2cb2..362508ed9 100644 --- a/src/Atc.Rest.ApiGenerator.Framework.Minimal/Factories/ContentGeneratorServerResultParametersFactory.cs +++ b/src/Atc.Rest.ApiGenerator.Framework.Minimal/Factories/ContentGeneratorServerResultParametersFactory.cs @@ -35,10 +35,7 @@ public static ContentGeneratorServerResultParameters Create( var okResponseModel = responseModels.Find(x => x.StatusCode == HttpStatusCode.OK) ?? responseModels.Find(x => x.StatusCode == HttpStatusCode.Created); - if (ShouldAppendImplicitOperatorContent( - httpStatusCodes, - okResponseModel?.DataType, - openApiOperation.Responses.IsSchemaUsingBinaryFormatForOkResponse())) + if (ShouldAppendImplicitOperatorContent(httpStatusCodes)) { var collectionDataType = okResponseModel?.CollectionDataType; var dataType = okResponseModel?.DataType; @@ -60,9 +57,7 @@ public static ContentGeneratorServerResultParameters Create( } private static bool ShouldAppendImplicitOperatorContent( - ICollection httpStatusCodes, - string? modelName, - bool isSchemaUsingBinaryFormatForOkResponse) + ICollection httpStatusCodes) { if (!httpStatusCodes.Contains(HttpStatusCode.OK) && !httpStatusCodes.Contains(HttpStatusCode.Created)) @@ -70,27 +65,6 @@ private static bool ShouldAppendImplicitOperatorContent( return false; } - var httpStatusCode = HttpStatusCode.Continue; // Dummy - if (httpStatusCodes.Contains(HttpStatusCode.OK)) - { - httpStatusCode = HttpStatusCode.OK; - } - else if (httpStatusCodes.Contains(HttpStatusCode.Created)) - { - httpStatusCode = HttpStatusCode.Created; - } - - if (httpStatusCode == HttpStatusCode.Created && - string.IsNullOrEmpty(modelName)) - { - return false; - } - - if (isSchemaUsingBinaryFormatForOkResponse) - { - return false; - } - return true; } } \ No newline at end of file diff --git a/src/Atc.Rest.ApiGenerator.Framework.Minimal/GlobalUsings.cs b/src/Atc.Rest.ApiGenerator.Framework.Minimal/GlobalUsings.cs index 3fa87e833..cb30167fd 100644 --- a/src/Atc.Rest.ApiGenerator.Framework.Minimal/GlobalUsings.cs +++ b/src/Atc.Rest.ApiGenerator.Framework.Minimal/GlobalUsings.cs @@ -1,4 +1,5 @@ global using System.Net; +global using System.Net.Mime; global using System.Text; global using Atc.CodeDocumentation.CodeComment; diff --git a/src/Atc.Rest.ApiGenerator.Framework.Minimal/ProjectGenerator/ServerApiGenerator.cs b/src/Atc.Rest.ApiGenerator.Framework.Minimal/ProjectGenerator/ServerApiGenerator.cs index cf4e89847..ff532b085 100644 --- a/src/Atc.Rest.ApiGenerator.Framework.Minimal/ProjectGenerator/ServerApiGenerator.cs +++ b/src/Atc.Rest.ApiGenerator.Framework.Minimal/ProjectGenerator/ServerApiGenerator.cs @@ -41,7 +41,8 @@ public ServerApiGenerator( $"\"{ContentWriterConstants.ApiGeneratorName}\", \"{settings.Version}\""); } - public async Task ScaffoldProjectFile() + public async Task ScaffoldProjectFile( + bool usingCodingRules) { var packageReferences = await nugetPackageReferenceProvider.GetPackageReferencesForApiProjectForMinimalApi(); @@ -59,15 +60,20 @@ public async Task ScaffoldProjectFile() "Microsoft.NET.Sdk", [ [ - new("TargetFramework", Attributes: null, "net8.0"), + new("TargetFramework", Attributes: null, "net9.0"), new("IsPackable", Attributes: null, "false"), ], [ new("GenerateDocumentationFile", Attributes: null, "true"), ], [ - new("DocumentationFile", Attributes: null, @$"bin\Debug\net8.0\{settings.ProjectName}.xml"), - new("NoWarn", Attributes: null, "$(NoWarn);1573;1591;1701;1702;1712;8618;"), + new("DocumentationFile", Attributes: null, @$"bin\Debug\net9.0\{settings.ProjectName}.xml"), + new( + "NoWarn", + Attributes: null, + usingCodingRules + ? "$(NoWarn);1573;1591;1701;1702;1712;8618;" + : "$(NoWarn);1573;1591;1701;1702;1712;8618;8632;"), ], ], [ @@ -297,6 +303,7 @@ public void GenerateEndpoints() GetRouteByApiGroupName(apiGroupName), ContentGeneratorConstants.EndpointDefinition, openApiDocument, + settings.ContractsNamespace, settings.UsePartialClassForEndpoints); var contentGenerator = new ContentGenerators.ContentGeneratorServerEndpoints( @@ -325,7 +332,8 @@ public void MaintainApiSpecification( settings.ProjectPath); public void MaintainGlobalUsings( - bool removeNamespaceGroupSeparatorInGlobalUsings) + bool removeNamespaceGroupSeparatorInGlobalUsings, + bool usingCodingRules) { var requiredUsings = new List { @@ -338,6 +346,15 @@ public void MaintainGlobalUsings( "Microsoft.AspNetCore.Mvc", }; + if (!usingCodingRules) + { + requiredUsings.Add("System"); + requiredUsings.Add("System.Collections.Generic"); + requiredUsings.Add("System.Linq"); + requiredUsings.Add("System.Threading"); + requiredUsings.Add("System.Threading.Tasks"); + } + if (openApiDocument.IsUsingRequiredForSystemTextJsonSerializationAndSystemRuntimeSerialization(settings.IncludeDeprecatedOperations)) { requiredUsings.Add("System.Runtime.Serialization"); diff --git a/src/Atc.Rest.ApiGenerator.Framework.Minimal/ProjectGenerator/ServerDomainGenerator.cs b/src/Atc.Rest.ApiGenerator.Framework.Minimal/ProjectGenerator/ServerDomainGenerator.cs index 2c5c626d1..3d9417dcf 100644 --- a/src/Atc.Rest.ApiGenerator.Framework.Minimal/ProjectGenerator/ServerDomainGenerator.cs +++ b/src/Atc.Rest.ApiGenerator.Framework.Minimal/ProjectGenerator/ServerDomainGenerator.cs @@ -56,14 +56,14 @@ public async Task ScaffoldProjectFile() "Microsoft.NET.Sdk", [ [ - new("TargetFramework", Attributes: null, "net8.0"), + new("TargetFramework", Attributes: null, "net9.0"), new("IsPackable", Attributes: null, "false"), ], [ new("GenerateDocumentationFile", Attributes: null, "true"), ], [ - new("DocumentationFile", Attributes: null, @$"bin\Debug\net8.0\{settings.ProjectName}.xml"), + new("DocumentationFile", Attributes: null, @$"bin\Debug\net9.0\{settings.ProjectName}.xml"), new("NoWarn", Attributes: null, "$(NoWarn);1573;1591;1701;1702;1712;8618;"), ], ], @@ -248,7 +248,8 @@ public void GenerateServiceCollectionEndpointHandlerExtensions() } public void MaintainGlobalUsings( - bool removeNamespaceGroupSeparatorInGlobalUsings) + bool removeNamespaceGroupSeparatorInGlobalUsings, + bool usingCodingRules) { var requiredUsings = new List { @@ -258,9 +259,17 @@ public void MaintainGlobalUsings( "Microsoft.Extensions.DependencyInjection", }; + if (!usingCodingRules) + { + requiredUsings.Add("System"); + requiredUsings.Add("System.Threading"); + requiredUsings.Add("System.Threading.Tasks"); + } + var apiGroupNames = openApiDocument.GetApiGroupNames(); requiredUsings.AddRange(apiGroupNames.Select(x => NamespaceFactory.Create(apiProjectName, NamespaceFactory.CreateWithApiGroupName(x, settings.ContractsNamespace)))); + requiredUsings.AddRange(apiGroupNames.Select(x => NamespaceFactory.Create(settings.ProjectName, NamespaceFactory.CreateWithApiGroupName(x, settings.HandlersNamespace)))); GlobalUsingsHelper.CreateOrUpdate( logger, diff --git a/src/Atc.Rest.ApiGenerator.Framework.Minimal/ProjectGenerator/ServerHostGenerator.cs b/src/Atc.Rest.ApiGenerator.Framework.Minimal/ProjectGenerator/ServerHostGenerator.cs index 638e1e208..9beda0b06 100644 --- a/src/Atc.Rest.ApiGenerator.Framework.Minimal/ProjectGenerator/ServerHostGenerator.cs +++ b/src/Atc.Rest.ApiGenerator.Framework.Minimal/ProjectGenerator/ServerHostGenerator.cs @@ -56,14 +56,14 @@ public async Task ScaffoldProjectFile() "Microsoft.NET.Sdk.Web", [ [ - new("TargetFramework", Attributes: null, "net8.0"), + new("TargetFramework", Attributes: null, "net9.0"), new("IsPackable", Attributes: null, "false"), ], [ new("GenerateDocumentationFile", Attributes: null, "true"), ], [ - new("DocumentationFile", Attributes: null, @$"bin\Debug\net8.0\{settings.ProjectName}.xml"), + new("DocumentationFile", Attributes: null, @$"bin\Debug\net9.0\{settings.ProjectName}.xml"), new("NoWarn", Attributes: null, "$(NoWarn);1573;1591;1701;1702;1712;8618;"), ], ], @@ -236,7 +236,8 @@ public void GenerateConfigureSwaggerDocOptions() } public void MaintainGlobalUsings( - bool removeNamespaceGroupSeparatorInGlobalUsings) + bool removeNamespaceGroupSeparatorInGlobalUsings, + bool usingCodingRules) { var requiredUsings = new List { @@ -263,6 +264,17 @@ public void MaintainGlobalUsings( $"{domainProjectName}.Extensions", }; + if (!usingCodingRules) + { + requiredUsings.Add("System"); + requiredUsings.Add("System.IO"); + requiredUsings.Add("Microsoft.AspNetCore.Builder"); + requiredUsings.Add("Microsoft.AspNetCore.Hosting"); + requiredUsings.Add("Microsoft.Extensions.Hosting"); + requiredUsings.Add("Microsoft.Extensions.Configuration"); + requiredUsings.Add("Microsoft.Extensions.DependencyInjection"); + } + GlobalUsingsHelper.CreateOrUpdate( logger, ContentWriterArea.Src, diff --git a/src/Atc.Rest.ApiGenerator.Framework.Minimal/ProjectGenerator/ServerHostTestGenerator.cs b/src/Atc.Rest.ApiGenerator.Framework.Minimal/ProjectGenerator/ServerHostTestGenerator.cs index 4ab5cdce5..38f84d970 100644 --- a/src/Atc.Rest.ApiGenerator.Framework.Minimal/ProjectGenerator/ServerHostTestGenerator.cs +++ b/src/Atc.Rest.ApiGenerator.Framework.Minimal/ProjectGenerator/ServerHostTestGenerator.cs @@ -48,9 +48,11 @@ public ServerHostTestGenerator( .CreateGeneratedCode(settings.Version); } - public async Task ScaffoldProjectFile() + public async Task ScaffoldProjectFile( + bool usingCodingRules) { - var packageReferences = await nugetPackageReferenceProvider.GetPackageReferencesForTestHostProjectForMinimalApi(); + var packageReferences = await nugetPackageReferenceProvider.GetPackageReferencesForTestHostProjectForMinimalApi( + usingCodingRules); var itemGroupPackageReferences = packageReferences .Select(packageReference => new ItemGroupParameter( @@ -66,11 +68,16 @@ public async Task ScaffoldProjectFile() "Microsoft.NET.Sdk", [ [ - new("TargetFramework", Attributes: null, "net8.0"), + new("TargetFramework", Attributes: null, "net9.0"), ], [ - new("DocumentationFile", Attributes: null, @$"bin\Debug\net8.0\{settings.ProjectName}.xml"), - new("NoWarn", Attributes: null, "$(NoWarn);1573;1591;1701;1702;1712;8618;"), + new("DocumentationFile", Attributes: null, @$"bin\Debug\net9.0\{settings.ProjectName}.xml"), + new( + "NoWarn", + Attributes: null, + usingCodingRules + ? "$(NoWarn);1573;1591;1701;1702;1712;8618;NU1603;NU1608;" + : "$(NoWarn);1573;1591;1701;1702;1712;8618;8632;NU1603;NU1608;"), ], ], [ @@ -177,8 +184,11 @@ public void GenerateEndpointHandlerStubs() var apiGroupName = openApiPath.GetApiGroupName(); var endpointsLocation = LocationFactory.CreateWithApiGroupName(apiGroupName, settings.EndpointsLocation); + var endpointsNamespace = LocationFactory.CreateWithApiGroupName(apiGroupName, settings.EndpointsNamespace); + var contractsNamespace = LocationFactory.CreateWithApiGroupName(apiGroupName, settings.ContractsNamespace); - var fullNamespace = NamespaceFactory.Create(settings.ProjectName, endpointsLocation); + var fullNamespace = NamespaceFactory.Create(settings.ProjectName, endpointsNamespace); + var fullContractNamespace = NamespaceFactory.Create(settings.ProjectName.Replace("Tests", "Generated", StringComparison.Ordinal), contractsNamespace); foreach (var openApiOperation in openApiPath.Value.Operations) { @@ -192,7 +202,9 @@ public void GenerateEndpointHandlerStubs() fullNamespace, codeGeneratorAttribute, openApiPath.Value, - openApiOperation.Value); + openApiOperation.Value, + fullContractNamespace, + AspNetOutputType.MinimalApi); var contentGenerator = new GenerateContentForClass( new CodeDocumentationTagsGenerator(), @@ -247,26 +259,45 @@ public void GenerateEndpointTests() } public void MaintainGlobalUsings( - bool usingCodingRules, - bool removeNamespaceGroupSeparatorInGlobalUsings) + bool removeNamespaceGroupSeparatorInGlobalUsings, + bool usingCodingRules) { var requiredUsings = new List - { - "System.CodeDom.Compiler", - "System.Text", - "System.Text.Json", - "System.Text.Json.Serialization", - "System.Reflection", - "Atc.XUnit", - "Atc.Rest.Options", - "AutoFixture", - "Microsoft.AspNetCore.Hosting", - "Microsoft.AspNetCore.Http", - "Microsoft.Extensions.Configuration", - "Microsoft.Extensions.DependencyInjection", - "Xunit", - apiProjectName, - }; + { + "System.CodeDom.Compiler", + "AutoFixture", + }; + + if (!usingCodingRules) + { + requiredUsings.Add("System"); + requiredUsings.Add("System.Threading"); + requiredUsings.Add("System.Threading.Tasks"); + requiredUsings.Add("System.Collections.Generic"); + requiredUsings.Add("System.IO"); + requiredUsings.Add("System.Net.Http"); + } + + //// TODO: Maybe some is needed? + ////if (false) + ////{ + //// requiredUsings.Add("System.Reflection"); + //// requiredUsings.Add("System.Text"); + //// requiredUsings.Add("System.Text.Json"); + //// requiredUsings.Add("System.Text.Json.Serialization"); + //// requiredUsings.Add("Atc.Rest.Options"); + //// requiredUsings.Add("Atc.XUnit"); + //// requiredUsings.Add("Microsoft.AspNetCore.Hosting"); + //// requiredUsings.Add("Microsoft.AspNetCore.Http"); + //// requiredUsings.Add("Microsoft.Extensions.Configuration"); + //// requiredUsings.Add("Microsoft.Extensions.DependencyInjection"); + //// requiredUsings.Add("Xunit"); + ////} + + if (openApiDocument.IsUsingRequiredForSystemText(settings.IncludeDeprecatedOperations)) + { + requiredUsings.Add("System.Text"); + } if (openApiDocument.IsUsingRequiredForAtcRestResults()) { diff --git a/src/Atc.Rest.ApiGenerator.Framework.Mvc/Atc.Rest.ApiGenerator.Framework.Mvc.csproj b/src/Atc.Rest.ApiGenerator.Framework.Mvc/Atc.Rest.ApiGenerator.Framework.Mvc.csproj index 350284fc4..250fd9ffc 100644 --- a/src/Atc.Rest.ApiGenerator.Framework.Mvc/Atc.Rest.ApiGenerator.Framework.Mvc.csproj +++ b/src/Atc.Rest.ApiGenerator.Framework.Mvc/Atc.Rest.ApiGenerator.Framework.Mvc.csproj @@ -1,13 +1,13 @@ - net8.0 + net9.0 false - - + + diff --git a/src/Atc.Rest.ApiGenerator.Framework.Mvc/ContentGenerators/ContentGeneratorServerResult.cs b/src/Atc.Rest.ApiGenerator.Framework.Mvc/ContentGenerators/ContentGeneratorServerResult.cs index 3b386adae..7f752db89 100644 --- a/src/Atc.Rest.ApiGenerator.Framework.Mvc/ContentGenerators/ContentGeneratorServerResult.cs +++ b/src/Atc.Rest.ApiGenerator.Framework.Mvc/ContentGenerators/ContentGeneratorServerResult.cs @@ -97,10 +97,11 @@ private void AppendMethodContentStatusCodeOk( ContentGeneratorServerResultMethodParameters item, string resultName) { - if (item.ResponseModel.MediaType == MediaTypeNames.Application.Octet) + if (item.ResponseModel.MediaType is not null && + item.ResponseModel.MediaType != MediaTypeNames.Application.Json) { - sb.AppendLine(4, $"public static {resultName} Ok(byte[] bytes, string fileName)"); - sb.AppendLine(8, $"=> new {resultName}(ResultFactory.CreateFileContentResult(bytes, fileName));"); + sb.AppendLine(4, $"public static {resultName} Ok(byte[] bytes, string contentType, string fileName)"); + sb.AppendLine(8, $"=> new {resultName}(ResultFactory.CreateFileContentResult(bytes, fileName, contentType));"); return; } @@ -170,7 +171,7 @@ private void AppendMethodContentForOtherStatusCodesThanOkWithProblemDetails( break; case HttpStatusCode.EarlyHints: sb.AppendLine(4, $"public static {resultName} {item.ResponseModel.StatusCode.ToNormalizedString()}()"); - sb.AppendLine(8, $"=> new {resultName}({nameof(Results.ResultFactory)}.{nameof(Results.ResultFactory.CreateContentResultWithProblemDetails)}({nameof(HttpStatusCode)}.{item.ResponseModel.StatusCode}));"); + sb.AppendLine(8, $"=> new {resultName}({nameof(Results.ResultFactory)}.{nameof(Results.ResultFactory.CreateContentResultWithProblemDetails)}({nameof(HttpStatusCode)}.{item.ResponseModel.StatusCode}, string.Empty));"); break; case HttpStatusCode.Continue: case HttpStatusCode.SwitchingProtocols: @@ -258,7 +259,7 @@ private void AppendMethodContentForOtherStatusCodesThanOkWithoutProblemDetails( break; case HttpStatusCode.EarlyHints: sb.AppendLine(4, $"public static {resultName} {item.ResponseModel.StatusCode.ToNormalizedString()}()"); - sb.AppendLine(8, $"=> new {resultName}({nameof(Results.ResultFactory)}.{nameof(Results.ResultFactory.CreateContentResult)}({nameof(HttpStatusCode)}.{item.ResponseModel.StatusCode}, string? message = null));"); + sb.AppendLine(8, $"=> new {resultName}({nameof(Results.ResultFactory)}.{nameof(Results.ResultFactory.CreateContentResult)}({nameof(HttpStatusCode)}.{item.ResponseModel.StatusCode}, string.Empty));"); break; case HttpStatusCode.Continue: case HttpStatusCode.SwitchingProtocols: diff --git a/src/Atc.Rest.ApiGenerator.Framework.Mvc/ProjectGenerator/ServerApiGenerator.cs b/src/Atc.Rest.ApiGenerator.Framework.Mvc/ProjectGenerator/ServerApiGenerator.cs index 35f09a7e3..232ea59ae 100644 --- a/src/Atc.Rest.ApiGenerator.Framework.Mvc/ProjectGenerator/ServerApiGenerator.cs +++ b/src/Atc.Rest.ApiGenerator.Framework.Mvc/ProjectGenerator/ServerApiGenerator.cs @@ -41,7 +41,8 @@ public ServerApiGenerator( .CreateGeneratedCode(settings.Version); } - public async Task ScaffoldProjectFile() + public async Task ScaffoldProjectFile( + bool usingCodingRules) { var packageReferences = await nugetPackageReferenceProvider.GetPackageReferencesForApiProjectForMvc(); @@ -59,15 +60,20 @@ public async Task ScaffoldProjectFile() "Microsoft.NET.Sdk", [ [ - new("TargetFramework", Attributes: null, "net8.0"), + new("TargetFramework", Attributes: null, "net9.0"), new("IsPackable", Attributes: null, "false"), ], [ new("GenerateDocumentationFile", Attributes: null, "true"), ], [ - new("DocumentationFile", Attributes: null, @$"bin\Debug\net8.0\{settings.ProjectName}.xml"), - new("NoWarn", Attributes: null, "$(NoWarn);1573;1591;1701;1702;1712;8618;"), + new("DocumentationFile", Attributes: null, @$"bin\Debug\net9.0\{settings.ProjectName}.xml"), + new( + "NoWarn", + Attributes: null, + usingCodingRules + ? "$(NoWarn);1573;1591;1701;1702;1712;8618;" + : "$(NoWarn);1573;1591;1701;1702;1712;8618;8632;"), ], ], [ @@ -313,6 +319,7 @@ public void GenerateEndpoints() GetRouteByApiGroupName(apiGroupName), ContentGeneratorConstants.Controller, openApiDocument, + settings.ContractsNamespace, settings.UsePartialClassForEndpoints); var contentGenerator = new ContentGenerators.ContentGeneratorServerController( @@ -341,7 +348,8 @@ public void MaintainApiSpecification( settings.ProjectPath); public void MaintainGlobalUsings( - bool removeNamespaceGroupSeparatorInGlobalUsings) + bool removeNamespaceGroupSeparatorInGlobalUsings, + bool usingCodingRules) { var requiredUsings = new List { @@ -352,8 +360,19 @@ public void MaintainGlobalUsings( "Atc.Rest.Results", }; - // TODO: Check for any use ?? - requiredUsings.Add("System.Net"); + if (!usingCodingRules) + { + requiredUsings.Add("System"); + requiredUsings.Add("System.Collections.Generic"); + requiredUsings.Add("System.Linq"); + requiredUsings.Add("System.Threading"); + requiredUsings.Add("System.Threading.Tasks"); + } + + if (openApiDocument.IsUsingRequiredForSystemNet(settings.IncludeDeprecatedOperations)) + { + requiredUsings.Add("System.Net"); + } if (openApiDocument.IsUsingRequiredForSystemTextJsonSerializationAndSystemRuntimeSerialization(settings.IncludeDeprecatedOperations)) { diff --git a/src/Atc.Rest.ApiGenerator.Framework.Mvc/ProjectGenerator/ServerDomainGenerator.cs b/src/Atc.Rest.ApiGenerator.Framework.Mvc/ProjectGenerator/ServerDomainGenerator.cs index f64ca605a..e49f8f68b 100644 --- a/src/Atc.Rest.ApiGenerator.Framework.Mvc/ProjectGenerator/ServerDomainGenerator.cs +++ b/src/Atc.Rest.ApiGenerator.Framework.Mvc/ProjectGenerator/ServerDomainGenerator.cs @@ -41,14 +41,14 @@ public async Task ScaffoldProjectFile() "Microsoft.NET.Sdk", [ [ - new("TargetFramework", Attributes: null, "net8.0"), + new("TargetFramework", Attributes: null, "net9.0"), new("IsPackable", Attributes: null, "false"), ], [ new("GenerateDocumentationFile", Attributes: null, "true"), ], [ - new("DocumentationFile", Attributes: null, @$"bin\Debug\net8.0\{settings.ProjectName}.xml"), + new("DocumentationFile", Attributes: null, @$"bin\Debug\net9.0\{settings.ProjectName}.xml"), new("NoWarn", Attributes: null, "$(NoWarn);1573;1591;1701;1702;1712;8618;"), ], ], @@ -150,13 +150,21 @@ public void GenerateServiceCollectionEndpointHandlerExtensions() => throw new NotSupportedException($"{nameof(GenerateServiceCollectionEndpointHandlerExtensions)} is not supported for MVC"); public void MaintainGlobalUsings( - bool removeNamespaceGroupSeparatorInGlobalUsings) + bool removeNamespaceGroupSeparatorInGlobalUsings, + bool usingCodingRules) { var requiredUsings = new List { "System.CodeDom.Compiler", }; + if (!usingCodingRules) + { + requiredUsings.Add("System"); + requiredUsings.Add("System.Threading"); + requiredUsings.Add("System.Threading.Tasks"); + } + var apiGroupNames = openApiDocument.GetApiGroupNames(); requiredUsings.AddRange(apiGroupNames.Select(x => NamespaceFactory.Create(apiProjectName, NamespaceFactory.CreateWithApiGroupName(x, settings.ContractsNamespace)))); diff --git a/src/Atc.Rest.ApiGenerator.Framework.Mvc/ProjectGenerator/ServerHostGenerator.cs b/src/Atc.Rest.ApiGenerator.Framework.Mvc/ProjectGenerator/ServerHostGenerator.cs index d7a0312ee..70e5c0450 100644 --- a/src/Atc.Rest.ApiGenerator.Framework.Mvc/ProjectGenerator/ServerHostGenerator.cs +++ b/src/Atc.Rest.ApiGenerator.Framework.Mvc/ProjectGenerator/ServerHostGenerator.cs @@ -53,14 +53,14 @@ public async Task ScaffoldProjectFile() "Microsoft.NET.Sdk.Web", [ [ - new("TargetFramework", Attributes: null, "net8.0"), + new("TargetFramework", Attributes: null, "net9.0"), new("IsPackable", Attributes: null, "false"), ], [ new("GenerateDocumentationFile", Attributes: null, "true"), ], [ - new("DocumentationFile", Attributes: null, @$"bin\Debug\net8.0\{settings.ProjectName}.xml"), + new("DocumentationFile", Attributes: null, @$"bin\Debug\net9.0\{settings.ProjectName}.xml"), new("NoWarn", Attributes: null, "$(NoWarn);1573;1591;1701;1702;1712;8618;"), ], ], @@ -189,7 +189,8 @@ public void GenerateConfigureSwaggerDocOptions() } public void MaintainGlobalUsings( - bool removeNamespaceGroupSeparatorInGlobalUsings) + bool removeNamespaceGroupSeparatorInGlobalUsings, + bool usingCodingRules) { var requiredUsings = new List { @@ -201,6 +202,17 @@ public void MaintainGlobalUsings( $"{settings.ProjectName}.Options", }; + if (!usingCodingRules) + { + requiredUsings.Add("System"); + requiredUsings.Add("System.IO"); + requiredUsings.Add("Microsoft.AspNetCore.Builder"); + requiredUsings.Add("Microsoft.AspNetCore.Hosting"); + requiredUsings.Add("Microsoft.Extensions.Hosting"); + requiredUsings.Add("Microsoft.Extensions.Configuration"); + requiredUsings.Add("Microsoft.Extensions.DependencyInjection"); + } + if (UseRestExtended) { requiredUsings.Add("Asp.Versioning.ApiExplorer"); diff --git a/src/Atc.Rest.ApiGenerator.Framework.Mvc/ProjectGenerator/ServerHostTestGenerator.cs b/src/Atc.Rest.ApiGenerator.Framework.Mvc/ProjectGenerator/ServerHostTestGenerator.cs index 5a3525c4f..6693c70eb 100644 --- a/src/Atc.Rest.ApiGenerator.Framework.Mvc/ProjectGenerator/ServerHostTestGenerator.cs +++ b/src/Atc.Rest.ApiGenerator.Framework.Mvc/ProjectGenerator/ServerHostTestGenerator.cs @@ -50,9 +50,11 @@ public ServerHostTestGenerator( .CreateGeneratedCode(settings.Version); } - public async Task ScaffoldProjectFile() + public async Task ScaffoldProjectFile( + bool usingCodingRules) { - var packageReferences = await nugetPackageReferenceProvider.GetPackageReferencesForTestHostProjectForMvc(); + var packageReferences = await nugetPackageReferenceProvider.GetPackageReferencesForTestHostProjectForMvc( + usingCodingRules); var itemGroupPackageReferences = packageReferences .Select(packageReference => new ItemGroupParameter( @@ -68,11 +70,16 @@ public async Task ScaffoldProjectFile() "Microsoft.NET.Sdk", [ [ - new("TargetFramework", Attributes: null, "net8.0"), + new("TargetFramework", Attributes: null, "net9.0"), ], [ - new("DocumentationFile", Attributes: null, @$"bin\Debug\net8.0\{settings.ProjectName}.xml"), - new("NoWarn", Attributes: null, "$(NoWarn);1573;1591;1701;1702;1712;8618;"), + new("DocumentationFile", Attributes: null, @$"bin\Debug\net9.0\{settings.ProjectName}.xml"), + new( + "NoWarn", + Attributes: null, + usingCodingRules + ? "$(NoWarn);1573;1591;1701;1702;1712;8618;NU1603;NU1608;" + : "$(NoWarn);1573;1591;1701;1702;1712;8618;8632;NU1603;NU1608;"), ], ], [ @@ -176,8 +183,11 @@ public void GenerateEndpointHandlerStubs() var apiGroupName = openApiPath.GetApiGroupName(); var endpointsLocation = LocationFactory.CreateWithApiGroupName(apiGroupName, settings.EndpointsLocation); + var endpointsNamespace = LocationFactory.CreateWithApiGroupName(apiGroupName, settings.EndpointsNamespace); + var contractsNamespace = LocationFactory.CreateWithApiGroupName(apiGroupName, settings.ContractsNamespace); - var fullNamespace = NamespaceFactory.Create(settings.ProjectName, endpointsLocation); + var fullNamespace = NamespaceFactory.Create(settings.ProjectName, endpointsNamespace); + var fullContractNamespace = NamespaceFactory.Create(settings.ProjectName.Replace("Tests", "Generated", StringComparison.Ordinal), contractsNamespace); foreach (var openApiOperation in openApiPath.Value.Operations) { @@ -191,7 +201,9 @@ public void GenerateEndpointHandlerStubs() fullNamespace, codeGeneratorAttribute, openApiPath.Value, - openApiOperation.Value); + openApiOperation.Value, + fullContractNamespace, + AspNetOutputType.Mvc); var contentGenerator = new GenerateContentForClass( new CodeDocumentationTagsGenerator(), @@ -247,28 +259,38 @@ public void GenerateEndpointTests() } public void MaintainGlobalUsings( - bool usingCodingRules, - bool removeNamespaceGroupSeparatorInGlobalUsings) + bool removeNamespaceGroupSeparatorInGlobalUsings, + bool usingCodingRules) { var requiredUsings = new List - { - "System.CodeDom.Compiler", - "System.Text", - "System.Text.Json", - "System.Text.Json.Serialization", - "System.Reflection", - "Atc.XUnit", - "Atc.Rest.Options", - "AutoFixture", - "Microsoft.AspNetCore.Hosting", - "Microsoft.AspNetCore.Http", - "Microsoft.AspNetCore.TestHost", - "Microsoft.AspNetCore.Mvc.Testing", - "Microsoft.Extensions.Configuration", - "Microsoft.Extensions.DependencyInjection", - "Xunit", - apiProjectName, - }; + { + "System.CodeDom.Compiler", + "System.Text", + "System.Text.Json", + "System.Text.Json.Serialization", + "System.Reflection", + "Atc.XUnit", + "Atc.Rest.Options", + "AutoFixture", + "Microsoft.AspNetCore.Hosting", + "Microsoft.AspNetCore.Http", + "Microsoft.AspNetCore.TestHost", + "Microsoft.AspNetCore.Mvc.Testing", + "Microsoft.Extensions.Configuration", + "Microsoft.Extensions.DependencyInjection", + "Xunit", + apiProjectName, + }; + + if (!usingCodingRules) + { + requiredUsings.Add("System"); + requiredUsings.Add("System.Threading"); + requiredUsings.Add("System.Threading.Tasks"); + requiredUsings.Add("System.Collections.Generic"); + requiredUsings.Add("System.IO"); + requiredUsings.Add("System.Net.Http"); + } if (openApiDocument.IsUsingRequiredForAtcRestResults()) { diff --git a/src/Atc.Rest.ApiGenerator.Framework/Atc.Rest.ApiGenerator.Framework.csproj b/src/Atc.Rest.ApiGenerator.Framework/Atc.Rest.ApiGenerator.Framework.csproj index 41a3cb326..4330b8f8e 100644 --- a/src/Atc.Rest.ApiGenerator.Framework/Atc.Rest.ApiGenerator.Framework.csproj +++ b/src/Atc.Rest.ApiGenerator.Framework/Atc.Rest.ApiGenerator.Framework.csproj @@ -1,7 +1,7 @@ - net8.0 + net9.0 false @@ -26,10 +26,10 @@ - - - - + + + + diff --git a/src/Atc.Rest.ApiGenerator.Framework/ContentGenerators/Server/ContentGeneratorServerConfigureSwaggerDocOptions.cs b/src/Atc.Rest.ApiGenerator.Framework/ContentGenerators/Server/ContentGeneratorServerConfigureSwaggerDocOptions.cs index bb2b41de0..141d8d523 100644 --- a/src/Atc.Rest.ApiGenerator.Framework/ContentGenerators/Server/ContentGeneratorServerConfigureSwaggerDocOptions.cs +++ b/src/Atc.Rest.ApiGenerator.Framework/ContentGenerators/Server/ContentGeneratorServerConfigureSwaggerDocOptions.cs @@ -67,7 +67,7 @@ public string Generate() .Trim(); } - sb.AppendLine(8, $"var text = new StringBuilder(\"{description}\");"); + sb.AppendLine(8, $"var text = new StringBuilder(@\"{description}\");"); sb.AppendLine(8, "var info = new OpenApiInfo"); sb.AppendLine(8, "{"); sb.AppendLine(12, "Title = $\"{environment.ApplicationName} {description.GroupName.ToUpperInvariant()}\","); diff --git a/src/Atc.Rest.ApiGenerator.Framework/Factories/Parameters/Server/ContentGeneratorServerTestEndpointHandlerStubParametersFactory.cs b/src/Atc.Rest.ApiGenerator.Framework/Factories/Parameters/Server/ContentGeneratorServerTestEndpointHandlerStubParametersFactory.cs index 320f4032d..03c29acac 100644 --- a/src/Atc.Rest.ApiGenerator.Framework/Factories/Parameters/Server/ContentGeneratorServerTestEndpointHandlerStubParametersFactory.cs +++ b/src/Atc.Rest.ApiGenerator.Framework/Factories/Parameters/Server/ContentGeneratorServerTestEndpointHandlerStubParametersFactory.cs @@ -7,18 +7,21 @@ public static ClassParameters Create( string @namespace, AttributeParameters codeGeneratorAttribute, OpenApiPathItem openApiPath, - OpenApiOperation openApiOperation) + OpenApiOperation openApiOperation, + string contractNamespace, + AspNetOutputType aspNetOutputType) { ArgumentNullException.ThrowIfNull(@namespace); ArgumentNullException.ThrowIfNull(openApiOperation); + ArgumentNullException.ThrowIfNull(contractNamespace); var operationName = openApiOperation.GetOperationName(); var hasParameters = openApiPath.HasParameters() || openApiOperation.HasParametersOrRequestBody(); - var inheritedClassTypeName = EnsureFullNamespaceIfNeeded($"I{operationName}{ContentGeneratorConstants.Handler}", @namespace); - var returnTypeName = EnsureFullNamespaceIfNeeded($"{operationName}{ContentGeneratorConstants.Result}", @namespace); + var inheritedClassTypeName = EnsureFullNamespaceIfNeeded($"I{operationName}{ContentGeneratorConstants.Handler}", contractNamespace); + var returnTypeName = EnsureFullNamespaceIfNeeded($"{operationName}{ContentGeneratorConstants.Result}", contractNamespace); var methodParametersParameters = new List(); if (hasParameters) @@ -46,24 +49,85 @@ public static ClassParameters Create( Name: "cancellationToken", DefaultValue: "default")); - var methodParameters = new List + var methodParameters = new List(); + + var responseModel = openApiOperation + .ExtractApiOperationResponseModels() + .FirstOrDefault(x => x.StatusCode == HttpStatusCode.OK); + + if (responseModel is not null && responseModel.UseAsyncEnumerable) { - new( - DocumentationTags: null, - Attributes: null, - DeclarationModifier: DeclarationModifiers.Public, - ReturnTypeName: returnTypeName, - ReturnGenericTypeName: "Task", - Name: "ExecuteAsync", - Parameters: methodParametersParameters, - AlwaysBreakDownParameters: true, - UseExpressionBody: false, - Content: GenerateContentExecuteMethod( - @namespace, - returnTypeName, - openApiOperation, - hasParameters)), - }; + methodParameters.Add( + new( + DocumentationTags: null, + Attributes: null, + DeclarationModifier: DeclarationModifiers.Public, + ReturnTypeName: returnTypeName, + ReturnGenericTypeName: "Task", + Name: "ExecuteAsync", + Parameters: methodParametersParameters, + AlwaysBreakDownParameters: true, + UseExpressionBody: false, + Content: GenerateContentExecuteMethod( + contractNamespace, + returnTypeName, + openApiOperation, + hasParameters, + asAsyncEnumerable: true, + aspNetOutputType))); + + var parameterDataType = $"{responseModel.CollectionDataType}<{responseModel.GetQualifiedDataType()}>"; + var returnDataType = responseModel.CollectionDataType == NameConstants.List + ? responseModel.GetQualifiedDataType() + : $"{responseModel.CollectionDataType}<{responseModel.GetQualifiedDataType()}>"; + + var methodParametersParametersForDataAsync = new List + { + new( + Attributes: null, + GenericTypeName: null, + IsGenericListType: false, + TypeName: parameterDataType, + IsNullableType: false, + IsReferenceType: true, + Name: "data", + DefaultValue: null), + }; + + methodParameters.Add( + new( + DocumentationTags: null, + Attributes: null, + DeclarationModifier: DeclarationModifiers.PrivateStaticAsync, + ReturnTypeName: returnDataType, + ReturnGenericTypeName: "IAsyncEnumerable", + Name: "GetDataAsync", + Parameters: methodParametersParametersForDataAsync, + AlwaysBreakDownParameters: true, + UseExpressionBody: false, + Content: GenerateContentAsyncEnumerableMethod(responseModel.CollectionDataType == NameConstants.List))); + } + else + { + methodParameters.Add( + new( + DocumentationTags: null, + Attributes: null, + DeclarationModifier: DeclarationModifiers.Public, + ReturnTypeName: returnTypeName, + ReturnGenericTypeName: "Task", + Name: "ExecuteAsync", + Parameters: methodParametersParameters, + AlwaysBreakDownParameters: true, + UseExpressionBody: false, + Content: GenerateContentExecuteMethod( + contractNamespace, + returnTypeName, + openApiOperation, + hasParameters, + asAsyncEnumerable: false, + aspNetOutputType))); + } return new ClassParameters( headerContent, @@ -87,7 +151,9 @@ private static string GenerateContentExecuteMethod( string @namespace, string contractResultTypeName, OpenApiOperation openApiOperation, - bool hasParameters) + bool hasParameters, + bool asAsyncEnumerable, + AspNetOutputType aspNetOutputType) { var responseStatusCodes = openApiOperation.Responses.GetHttpStatusCodes(); if (!responseStatusCodes.Any()) @@ -158,7 +224,7 @@ private static string GenerateContentExecuteMethod( break; case "byte[]": sb.AppendLine("var bytes = Encoding.UTF8.GetBytes(\"Hello World\");"); - sb.Append($"return {GetTaskName(@namespace)}.FromResult({contractResultTypeName}.Ok(bytes, \"dummy.txt\"));"); + sb.Append($"return {GetTaskName(@namespace)}.FromResult({contractResultTypeName}.Ok(bytes, \"{MediaTypeNames.Text.Plain}\", \"dummy.txt\"));"); break; default: if (returnSchema is not null) @@ -168,7 +234,9 @@ private static string GenerateContentExecuteMethod( @namespace, contractResultTypeName, returnSchema, - hasParameters); + hasParameters, + asAsyncEnumerable, + aspNetOutputType); } break; @@ -177,12 +245,35 @@ private static string GenerateContentExecuteMethod( return sb.ToString(); } + private static string GenerateContentAsyncEnumerableMethod( + bool useList) + { + var sb = new StringBuilder(); + if (useList) + { + sb.AppendLine("foreach (var item in data)"); + sb.AppendLine("{"); + sb.AppendLine(4, "yield return item;"); + sb.AppendLine("}"); + } + else + { + sb.AppendLine("yield return data;"); + } + + sb.AppendLine(); + sb.AppendLine("await Task.CompletedTask;"); + return sb.ToString(); + } + private static void AppendGenerateContentForComplexData( StringBuilder sb, string @namespace, string contractResultTypeName, OpenApiSchema returnSchema, - bool hasParameters) + bool hasParameters, + bool asAsyncEnumerable, + AspNetOutputType aspNetOutputType) { var isTypeCustomPagination = returnSchema.IsTypeCustomPagination(); @@ -234,7 +325,23 @@ private static void AppendGenerateContentForComplexData( if (customPaginationSchema is not null) { var genericDataTypeName = customPaginationSchema.GetModelName(); - sb.AppendLine($"var paginationData = new {genericDataTypeName}<{returnName}>();"); + if (aspNetOutputType == AspNetOutputType.Mvc) + { + sb.AppendLine($"var paginationData = new {genericDataTypeName}<{returnName}>"); + sb.AppendLine("{"); + sb.AppendLine(4, "PageSize = 10,"); + sb.AppendLine( + 4, + customPaginationSchema.Properties.Keys.Contains("results", StringComparer.OrdinalIgnoreCase) + ? "Results = data," + : "Items = data,"); + sb.AppendLine("};"); + } + else + { + sb.AppendLine($"var paginationData = new {genericDataTypeName}<{returnName}>(10, null, data);"); + } + sb.AppendLine(); } } @@ -270,11 +377,25 @@ private static void AppendGenerateContentForComplexData( } } - sb.Append($"return {GetTaskName(@namespace)}.FromResult({contractResultTypeName}.Ok(paginationData));"); + if (asAsyncEnumerable) + { + sb.Append($"return {GetTaskName(@namespace)}.FromResult({contractResultTypeName}.Ok(GetDataAsync(paginationData)));"); + } + else + { + sb.Append($"return {GetTaskName(@namespace)}.FromResult({contractResultTypeName}.Ok(paginationData));"); + } } else { - sb.Append($"return {GetTaskName(@namespace)}.FromResult({contractResultTypeName}.Ok(data));"); + if (asAsyncEnumerable) + { + sb.Append($"return {GetTaskName(@namespace)}.FromResult({contractResultTypeName}.Ok(GetDataAsync(data)));"); + } + else + { + sb.Append($"return {GetTaskName(@namespace)}.FromResult({contractResultTypeName}.Ok(data));"); + } } } else @@ -332,10 +453,13 @@ private static string EnsureFullNamespaceIfNeeded( return value; } - var s1 = @namespace.Replace(".Generated", string.Empty, StringComparison.Ordinal); - var s2 = s1.Replace("Tests.Endpoints.", "Generated.Contracts.", StringComparison.Ordinal); + var index = @namespace.IndexOf("Generated", StringComparison.Ordinal); + if (index != -1) + { + @namespace = @namespace[index..]; + } - return $"{s2}.{value}"; + return $"{@namespace}.{value}"; } private static bool EndsWithWellKnownContract( diff --git a/src/Atc.Rest.ApiGenerator.Framework/Factories/Parameters/ServerClient/ContentGeneratorServerClientModelParametersFactory.cs b/src/Atc.Rest.ApiGenerator.Framework/Factories/Parameters/ServerClient/ContentGeneratorServerClientModelParametersFactory.cs index c97c77cfe..715d33c14 100644 --- a/src/Atc.Rest.ApiGenerator.Framework/Factories/Parameters/ServerClient/ContentGeneratorServerClientModelParametersFactory.cs +++ b/src/Atc.Rest.ApiGenerator.Framework/Factories/Parameters/ServerClient/ContentGeneratorServerClientModelParametersFactory.cs @@ -447,10 +447,29 @@ private static List ExtractRecordParameterBaseParameter } dataType ??= openApiParameter.Items.GetDataType(); + + if ("Object".Equals(dataType, StringComparison.Ordinal)) + { + dataType = "object"; + } } else { dataType = openApiParameter.GetDataType(); + + if ("Object".Equals(dataType, StringComparison.Ordinal)) + { + if (openApiParameter.AdditionalProperties is not null) + { + // A defined Object with AdditionalProperties is a Dictionary - https://swagger.io/docs/specification/data-models/dictionaries/ + var additionalPropertiesDataType = openApiParameter.AdditionalProperties.GetDataType(); + dataType = $"Dictionary"; + } + else + { + dataType = "object"; + } + } } var isSimpleType = useListForDataType diff --git a/src/Atc.Rest.ApiGenerator.Framework/Factories/Server/ContentGeneratorServerEndpointParametersFactory.cs b/src/Atc.Rest.ApiGenerator.Framework/Factories/Server/ContentGeneratorServerEndpointParametersFactory.cs index 27a2a8541..1f3e7c8c6 100644 --- a/src/Atc.Rest.ApiGenerator.Framework/Factories/Server/ContentGeneratorServerEndpointParametersFactory.cs +++ b/src/Atc.Rest.ApiGenerator.Framework/Factories/Server/ContentGeneratorServerEndpointParametersFactory.cs @@ -10,6 +10,7 @@ public static ContentGeneratorServerEndpointParameters Create( string route, string endpointSuffixName, OpenApiDocument openApiDocument, + string contractNamespace, bool usePartialClassForEndpoints) { var modelNamespace = $"{projectName}.{ContentGeneratorConstants.Contracts}.{apiGroupName}"; @@ -26,7 +27,7 @@ public static ContentGeneratorServerEndpointParameters Create( var endpointAuthorization = apiOperation.Value.ExtractApiOperationAuthorization(apiPathData); var responseModels = apiOperation.Value .ExtractApiOperationResponseModels(modelNamespace) - .AdjustNamespacesIfNeeded(operationSchemaMappings); + .AdjustNamespacesIfNeeded(operationSchemaMappings, contractNamespace); methodParameters.Add(new ContentGeneratorServerEndpointMethodParameters( OperationTypeRepresentation: apiOperation.Key.ToString(), diff --git a/src/Atc.Rest.ApiGenerator.Framework/ProjectGenerator/IServerApiGenerator.cs b/src/Atc.Rest.ApiGenerator.Framework/ProjectGenerator/IServerApiGenerator.cs index 6115dabe2..a16ca91bd 100644 --- a/src/Atc.Rest.ApiGenerator.Framework/ProjectGenerator/IServerApiGenerator.cs +++ b/src/Atc.Rest.ApiGenerator.Framework/ProjectGenerator/IServerApiGenerator.cs @@ -11,7 +11,8 @@ namespace Atc.Rest.ApiGenerator.Framework.ProjectGenerator; /// public interface IServerApiGenerator { - Task ScaffoldProjectFile(); + Task ScaffoldProjectFile( + bool usingCodingRules); void GenerateAssemblyMarker(); @@ -29,5 +30,6 @@ void MaintainApiSpecification( FileInfo apiSpecificationFile); void MaintainGlobalUsings( - bool removeNamespaceGroupSeparatorInGlobalUsings); + bool removeNamespaceGroupSeparatorInGlobalUsings, + bool usingCodingRules); } \ No newline at end of file diff --git a/src/Atc.Rest.ApiGenerator.Framework/ProjectGenerator/IServerDomainGenerator.cs b/src/Atc.Rest.ApiGenerator.Framework/ProjectGenerator/IServerDomainGenerator.cs index abe70d032..c4dc1da73 100644 --- a/src/Atc.Rest.ApiGenerator.Framework/ProjectGenerator/IServerDomainGenerator.cs +++ b/src/Atc.Rest.ApiGenerator.Framework/ProjectGenerator/IServerDomainGenerator.cs @@ -20,5 +20,6 @@ public interface IServerDomainGenerator void GenerateServiceCollectionEndpointHandlerExtensions(); void MaintainGlobalUsings( - bool removeNamespaceGroupSeparatorInGlobalUsings); + bool removeNamespaceGroupSeparatorInGlobalUsings, + bool usingCodingRules); } \ No newline at end of file diff --git a/src/Atc.Rest.ApiGenerator.Framework/ProjectGenerator/IServerHostGenerator.cs b/src/Atc.Rest.ApiGenerator.Framework/ProjectGenerator/IServerHostGenerator.cs index 0ae13a4e4..e6409bc59 100644 --- a/src/Atc.Rest.ApiGenerator.Framework/ProjectGenerator/IServerHostGenerator.cs +++ b/src/Atc.Rest.ApiGenerator.Framework/ProjectGenerator/IServerHostGenerator.cs @@ -36,7 +36,8 @@ void ScaffoldProgramFile( void ScaffoldWebConfig(); void MaintainGlobalUsings( - bool removeNamespaceGroupSeparatorInGlobalUsings); + bool removeNamespaceGroupSeparatorInGlobalUsings, + bool usingCodingRules); void MaintainWwwResources(); } \ No newline at end of file diff --git a/src/Atc.Rest.ApiGenerator.Framework/ProjectGenerator/IServerHostTestGenerator.cs b/src/Atc.Rest.ApiGenerator.Framework/ProjectGenerator/IServerHostTestGenerator.cs index 2cbedf16e..52ecd753e 100644 --- a/src/Atc.Rest.ApiGenerator.Framework/ProjectGenerator/IServerHostTestGenerator.cs +++ b/src/Atc.Rest.ApiGenerator.Framework/ProjectGenerator/IServerHostTestGenerator.cs @@ -11,7 +11,8 @@ namespace Atc.Rest.ApiGenerator.Framework.ProjectGenerator; /// public interface IServerHostTestGenerator { - Task ScaffoldProjectFile(); + Task ScaffoldProjectFile( + bool usingCodingRules); void ScaffoldAppSettingsIntegrationTestFile(); @@ -24,6 +25,6 @@ public interface IServerHostTestGenerator void GenerateEndpointTests(); void MaintainGlobalUsings( - bool usingCodingRules, - bool removeNamespaceGroupSeparatorInGlobalUsings); + bool removeNamespaceGroupSeparatorInGlobalUsings, + bool usingCodingRules); } \ No newline at end of file diff --git a/src/Atc.Rest.ApiGenerator.Framework/ProjectGenerator/ServerDomainTestGenerator.cs b/src/Atc.Rest.ApiGenerator.Framework/ProjectGenerator/ServerDomainTestGenerator.cs index ab09b3c21..d70f7a810 100644 --- a/src/Atc.Rest.ApiGenerator.Framework/ProjectGenerator/ServerDomainTestGenerator.cs +++ b/src/Atc.Rest.ApiGenerator.Framework/ProjectGenerator/ServerDomainTestGenerator.cs @@ -51,7 +51,7 @@ public async Task ScaffoldProjectFile() "Microsoft.NET.Sdk", [ [ - new("TargetFramework", Attributes: null, "net8.0"), + new("TargetFramework", Attributes: null, "net9.0"), ], ], [ diff --git a/src/Atc.Rest.ApiGenerator.Framework/Providers/INugetPackageReferenceProvider.cs b/src/Atc.Rest.ApiGenerator.Framework/Providers/INugetPackageReferenceProvider.cs index 3bea2a338..71e1729e8 100644 --- a/src/Atc.Rest.ApiGenerator.Framework/Providers/INugetPackageReferenceProvider.cs +++ b/src/Atc.Rest.ApiGenerator.Framework/Providers/INugetPackageReferenceProvider.cs @@ -19,9 +19,11 @@ public interface INugetPackageReferenceProvider Task> GetPackageReferencesForApiClientProject(); - Task> GetPackageReferencesForTestHostProjectForMvc(); + Task> GetPackageReferencesForTestHostProjectForMvc( + bool usingCodingRules); - Task> GetPackageReferencesForTestHostProjectForMinimalApi(); + Task> GetPackageReferencesForTestHostProjectForMinimalApi( + bool usingCodingRules); Task> GetPackageReferencesForTestDomainProjectForMvc(); diff --git a/src/Atc.Rest.ApiGenerator.Framework/Providers/NugetPackageReferenceProvider.cs b/src/Atc.Rest.ApiGenerator.Framework/Providers/NugetPackageReferenceProvider.cs index e50b9e7b4..0530c139a 100644 --- a/src/Atc.Rest.ApiGenerator.Framework/Providers/NugetPackageReferenceProvider.cs +++ b/src/Atc.Rest.ApiGenerator.Framework/Providers/NugetPackageReferenceProvider.cs @@ -8,29 +8,29 @@ public class NugetPackageReferenceProvider( private Dictionary PackageDefaultVersions { get; } = new(StringComparer.Ordinal) { { "Asp.Versioning.Http", "8.1.0" }, - { "Atc", "2.0.525" }, - { "Atc.Azure.Options", "3.0.31" }, - { "Atc.Rest", "2.0.525" }, + { "Atc", "2.0.552" }, + { "Atc.Azure.Options", "3.0.34" }, + { "Atc.Rest", "2.0.552" }, { "Atc.Rest.Client", "1.0.84" }, - { "Atc.Rest.Extended", "2.0.525" }, - { "Atc.Rest.FluentAssertions", "2.0.525" }, + { "Atc.Rest.Extended", "2.0.552" }, + { "Atc.Rest.FluentAssertions", "2.0.552" }, { "Atc.Rest.MinimalApi", "1.0.87" }, - { "Atc.XUnit", "2.0.525" }, + { "Atc.XUnit", "2.0.552" }, { "AutoFixture", "4.18.1" }, { "AutoFixture.AutoNSubstitute", "4.18.1" }, { "AutoFixture.Xunit2", "4.18.1" }, - { "FluentAssertions", "7.0.0" }, + { "FluentAssertions", "7.2.0" }, { "FluentValidation.AspNetCore", "11.3.0" }, { "Microsoft.ApplicationInsights.AspNetCore", "2.22.0" }, { "Microsoft.AspNetCore.Authentication.JwtBearer", "8.0.4" }, - { "Microsoft.AspNetCore.OpenApi", "8.0.6" }, - { "Microsoft.AspNetCore.Mvc.Testing", "8.0.6" }, + { "Microsoft.AspNetCore.OpenApi", "9.0.2" }, + { "Microsoft.AspNetCore.Mvc.Testing", "9.0.2" }, { "Microsoft.NETCore.Platforms", "7.0.4" }, - { "Microsoft.NET.Test.Sdk", "17.12.0" }, + { "Microsoft.NET.Test.Sdk", "17.13.0" }, { "NSubstitute", "5.3.0" }, - { "Swashbuckle.AspNetCore", "7.0.0" }, + { "Swashbuckle.AspNetCore", "7.3.1" }, { "xunit", "2.9.3" }, - { "xunit.runner.visualstudio", "3.0.1" }, + { "xunit.runner.visualstudio", "3.0.2" }, }; public async Task GetAtcApiGeneratorVersion() @@ -164,7 +164,8 @@ public async Task GetAtcApiGeneratorVersion() return packageReferences; } - public async Task> GetPackageReferencesForTestHostProjectForMvc() + public async Task> GetPackageReferencesForTestHostProjectForMvc( + bool usingCodingRules) { var atcVersion = await GetAtcVersionAsString3(); @@ -178,10 +179,16 @@ public async Task GetAtcApiGeneratorVersion() new("xunit.runner.visualstudio", PackageDefaultVersions["xunit.runner.visualstudio"], "all\nruntime; build; native; contentfiles; analyzers; buildtransitive"), }; + if (!usingCodingRules) + { + packageReferences.Add(new("AutoFixture", PackageDefaultVersions["AutoFixture"], null)); + } + return packageReferences; } - public async Task> GetPackageReferencesForTestHostProjectForMinimalApi() + public async Task> GetPackageReferencesForTestHostProjectForMinimalApi( + bool usingCodingRules) { var atcVersion = await GetAtcVersionAsString3(); diff --git a/src/Atc.Rest.ApiGenerator.Nuget/Atc.Rest.ApiGenerator.Nuget.csproj b/src/Atc.Rest.ApiGenerator.Nuget/Atc.Rest.ApiGenerator.Nuget.csproj index 89537e251..876d3617f 100644 --- a/src/Atc.Rest.ApiGenerator.Nuget/Atc.Rest.ApiGenerator.Nuget.csproj +++ b/src/Atc.Rest.ApiGenerator.Nuget/Atc.Rest.ApiGenerator.Nuget.csproj @@ -1,13 +1,13 @@ - net8.0 + net9.0 false - - + + diff --git a/src/Atc.Rest.ApiGenerator.OpenApi/Atc.Rest.ApiGenerator.OpenApi.csproj b/src/Atc.Rest.ApiGenerator.OpenApi/Atc.Rest.ApiGenerator.OpenApi.csproj index bf2f7e865..db7e74e0e 100644 --- a/src/Atc.Rest.ApiGenerator.OpenApi/Atc.Rest.ApiGenerator.OpenApi.csproj +++ b/src/Atc.Rest.ApiGenerator.OpenApi/Atc.Rest.ApiGenerator.OpenApi.csproj @@ -1,20 +1,24 @@ - net8.0 + net9.0 false - - - - - + + + + + + + + + diff --git a/src/Atc.Rest.ApiGenerator.OpenApi/Extensions/OpenApiDocumentExtensions.cs b/src/Atc.Rest.ApiGenerator.OpenApi/Extensions/OpenApiDocumentExtensions.cs index 91be6b2b9..1e18d3ce5 100644 --- a/src/Atc.Rest.ApiGenerator.OpenApi/Extensions/OpenApiDocumentExtensions.cs +++ b/src/Atc.Rest.ApiGenerator.OpenApi/Extensions/OpenApiDocumentExtensions.cs @@ -152,6 +152,32 @@ public static bool IsUsingRequiredForSystem( return false; } + public static bool IsUsingRequiredForSystemNet( + this OpenApiDocument openApiDocument, + bool includeDeprecated) + { + foreach (var apiPathPair in openApiDocument.Paths) + { + foreach (var apiOperationPair in apiPathPair.Value.Operations) + { + if (apiOperationPair.Value.Deprecated && !includeDeprecated) + { + continue; + } + + var statusCodes = apiOperationPair.Value.Responses.GetHttpStatusCodes(); + if (statusCodes.Exists(x => x + is HttpStatusCode.Created + or HttpStatusCode.BadRequest)) + { + return true; + } + } + } + + return false; + } + public static bool IsUsingRequiredForSystemCollectionGeneric( this OpenApiDocument openApiDocument, bool includeDeprecated) @@ -247,6 +273,34 @@ public static bool IsUsingRequiredForSystemLinq( return false; } + public static bool IsUsingRequiredForSystemText( + this OpenApiDocument openApiDocument, + bool includeDeprecated) + { + foreach (var apiPathPair in openApiDocument.Paths) + { + foreach (var apiOperationPair in apiPathPair.Value.Operations) + { + if (apiOperationPair.Value.Deprecated && !includeDeprecated) + { + continue; + } + + var okResponseModel = apiOperationPair.Value + .ExtractApiOperationResponseModels() + .FirstOrDefault(x => x.StatusCode == HttpStatusCode.OK); + + if (okResponseModel?.MediaType != null && + okResponseModel.MediaType != MediaTypeNames.Application.Json) + { + return true; + } + } + } + + return false; + } + public static bool IsUsingRequiredForSystemTextJsonSerializationAndSystemRuntimeSerialization( this OpenApiDocument openApiDocument, bool includeDeprecated) diff --git a/src/Atc.Rest.ApiGenerator/Atc.Rest.ApiGenerator.csproj b/src/Atc.Rest.ApiGenerator/Atc.Rest.ApiGenerator.csproj index 87c2f45e5..f3ffb12eb 100644 --- a/src/Atc.Rest.ApiGenerator/Atc.Rest.ApiGenerator.csproj +++ b/src/Atc.Rest.ApiGenerator/Atc.Rest.ApiGenerator.csproj @@ -1,22 +1,22 @@ - net8.0 + net9.0 Atc.Rest.ApiGenerator rest;api;netstandard;generator Atc.Rest.ApiGenerator is a WebApi C# code generator using a OpenApi 3.0.x specification YAML file. - - - - - - - - - + + + + + + + + + diff --git a/src/Atc.Rest.ApiGenerator/Generators/ServerApiGenerator.cs b/src/Atc.Rest.ApiGenerator/Generators/ServerApiGenerator.cs index cdae8e65e..32e22dc92 100644 --- a/src/Atc.Rest.ApiGenerator/Generators/ServerApiGenerator.cs +++ b/src/Atc.Rest.ApiGenerator/Generators/ServerApiGenerator.cs @@ -68,7 +68,8 @@ public async Task Generate() if (projectOptions.ApiOptions.Generator.AspNetOutputType == AspNetOutputType.Mvc) { - await serverApiGeneratorMvc.ScaffoldProjectFile(); + await serverApiGeneratorMvc.ScaffoldProjectFile( + projectOptions.UsingCodingRules); serverApiGeneratorMvc.GenerateAssemblyMarker(); serverApiGeneratorMvc.GenerateModels(); @@ -78,11 +79,14 @@ public async Task Generate() serverApiGeneratorMvc.GenerateEndpoints(); serverApiGeneratorMvc.MaintainApiSpecification(projectOptions.DocumentFile); - serverApiGeneratorMvc.MaintainGlobalUsings(projectOptions.ApiOptions.Generator.RemoveNamespaceGroupSeparatorInGlobalUsings); + serverApiGeneratorMvc.MaintainGlobalUsings( + projectOptions.ApiOptions.Generator.RemoveNamespaceGroupSeparatorInGlobalUsings, + projectOptions.UsingCodingRules); } else { - await serverApiGeneratorMinimalApi.ScaffoldProjectFile(); + await serverApiGeneratorMinimalApi.ScaffoldProjectFile( + projectOptions.UsingCodingRules); serverApiGeneratorMinimalApi.GenerateAssemblyMarker(); serverApiGeneratorMinimalApi.GenerateModels(); @@ -92,7 +96,9 @@ public async Task Generate() serverApiGeneratorMinimalApi.GenerateEndpoints(); serverApiGeneratorMinimalApi.MaintainApiSpecification(projectOptions.DocumentFile); - serverApiGeneratorMinimalApi.MaintainGlobalUsings(projectOptions.ApiOptions.Generator.RemoveNamespaceGroupSeparatorInGlobalUsings); + serverApiGeneratorMinimalApi.MaintainGlobalUsings( + projectOptions.ApiOptions.Generator.RemoveNamespaceGroupSeparatorInGlobalUsings, + projectOptions.UsingCodingRules); } return true; diff --git a/src/Atc.Rest.ApiGenerator/Generators/ServerDomainGenerator.cs b/src/Atc.Rest.ApiGenerator/Generators/ServerDomainGenerator.cs index 118b286f3..5f3f3cb19 100644 --- a/src/Atc.Rest.ApiGenerator/Generators/ServerDomainGenerator.cs +++ b/src/Atc.Rest.ApiGenerator/Generators/ServerDomainGenerator.cs @@ -95,7 +95,8 @@ public async Task Generate() serverDomainGeneratorMvc.GenerateAssemblyMarker(); serverDomainGeneratorMvc.MaintainGlobalUsings( - projectOptions.ApiOptions.Generator.RemoveNamespaceGroupSeparatorInGlobalUsings); + projectOptions.ApiOptions.Generator.RemoveNamespaceGroupSeparatorInGlobalUsings, + projectOptions.UsingCodingRules); } else { @@ -106,7 +107,8 @@ public async Task Generate() serverDomainGeneratorMinimalApi.GenerateServiceCollectionEndpointHandlerExtensions(); serverDomainGeneratorMinimalApi.MaintainGlobalUsings( - projectOptions.ApiOptions.Generator.RemoveNamespaceGroupSeparatorInGlobalUsings); + projectOptions.ApiOptions.Generator.RemoveNamespaceGroupSeparatorInGlobalUsings, + projectOptions.UsingCodingRules); } if (serverDomainTestGenerator is not null && diff --git a/src/Atc.Rest.ApiGenerator/Generators/ServerHostGenerator.cs b/src/Atc.Rest.ApiGenerator/Generators/ServerHostGenerator.cs index a91b66671..be76e03a4 100644 --- a/src/Atc.Rest.ApiGenerator/Generators/ServerHostGenerator.cs +++ b/src/Atc.Rest.ApiGenerator/Generators/ServerHostGenerator.cs @@ -119,7 +119,8 @@ public async Task Generate() serverHostGeneratorMvc.GenerateConfigureSwaggerDocOptions(); serverHostGeneratorMvc.MaintainGlobalUsings( - projectOptions.ApiOptions.Generator.RemoveNamespaceGroupSeparatorInGlobalUsings); + projectOptions.ApiOptions.Generator.RemoveNamespaceGroupSeparatorInGlobalUsings, + projectOptions.UsingCodingRules); serverHostGeneratorMvc.MaintainWwwResources(); if (serverHostTestGeneratorMvc is not null && @@ -127,7 +128,9 @@ public async Task Generate() { logger.LogInformation($"{ContentWriterConstants.AreaGenerateTest} Working on server host unit-test generation ({projectOptions.ProjectName}.Tests)"); - await serverHostTestGeneratorMvc.ScaffoldProjectFile(); + await serverHostTestGeneratorMvc.ScaffoldProjectFile( + projectOptions.UsingCodingRules); + serverHostTestGeneratorMvc.ScaffoldAppSettingsIntegrationTestFile(); serverHostTestGeneratorMvc.GenerateWebApiStartupFactoryFile(); @@ -136,8 +139,8 @@ public async Task Generate() serverHostTestGeneratorMvc.GenerateEndpointTests(); serverHostTestGeneratorMvc.MaintainGlobalUsings( - projectOptions.UsingCodingRules, - projectOptions.ApiOptions.Generator.RemoveNamespaceGroupSeparatorInGlobalUsings); + projectOptions.ApiOptions.Generator.RemoveNamespaceGroupSeparatorInGlobalUsings, + projectOptions.UsingCodingRules); } } else @@ -157,7 +160,9 @@ public async Task Generate() serverHostGeneratorMinimalApi.GenerateConfigureSwaggerDocOptions(); serverHostGeneratorMinimalApi.MaintainGlobalUsings( - projectOptions.ApiOptions.Generator.RemoveNamespaceGroupSeparatorInGlobalUsings); + projectOptions.ApiOptions.Generator.RemoveNamespaceGroupSeparatorInGlobalUsings, + projectOptions.UsingCodingRules); + serverHostGeneratorMinimalApi.MaintainWwwResources(); if (serverHostTestGeneratorMinimalApi is not null && @@ -165,7 +170,9 @@ public async Task Generate() { logger.LogInformation($"{ContentWriterConstants.AreaGenerateTest} Working on server host unit-test generation ({projectOptions.ProjectName}.Tests)"); - await serverHostTestGeneratorMinimalApi.ScaffoldProjectFile(); + await serverHostTestGeneratorMinimalApi.ScaffoldProjectFile( + projectOptions.UsingCodingRules); + serverHostTestGeneratorMinimalApi.ScaffoldAppSettingsIntegrationTestFile(); serverHostTestGeneratorMinimalApi.GenerateWebApiStartupFactoryFile(); @@ -174,8 +181,8 @@ public async Task Generate() serverHostTestGeneratorMinimalApi.GenerateEndpointTests(); serverHostTestGeneratorMinimalApi.MaintainGlobalUsings( - projectOptions.UsingCodingRules, - projectOptions.ApiOptions.Generator.RemoveNamespaceGroupSeparatorInGlobalUsings); + projectOptions.ApiOptions.Generator.RemoveNamespaceGroupSeparatorInGlobalUsings, + projectOptions.UsingCodingRules); } } diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 19967457b..dc1cb0c85 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -54,7 +54,7 @@ - + \ No newline at end of file diff --git a/test/.editorconfig b/test/.editorconfig index 92d063912..05bffccc8 100644 --- a/test/.editorconfig +++ b/test/.editorconfig @@ -1,8 +1,8 @@ # ATC coding rules - https://github.com/atc-net/atc-coding-rules # Version: 1.0.0 -# Updated: 25-09-2023 +# Updated: 09-01-2025 # Location: test -# Distribution: DotNet8 +# Distribution: DotNet9 # Inspired by: https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/code-style-rule-options ########################################## @@ -24,6 +24,7 @@ dotnet_diagnostic.MA0004.severity = none # https://github.com/atc-net dotnet_diagnostic.MA0016.severity = none # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/Meziantou/MA0016.md dotnet_diagnostic.MA0051.severity = none # Method Length + # Microsoft - Code Analysis # https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ dotnet_diagnostic.CA1068.severity = none # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/MicrosoftCodeAnalysis/CA1068.md diff --git a/test/Atc.CodeGeneration.CSharp.Tests/Atc.CodeGeneration.CSharp.Tests.csproj b/test/Atc.CodeGeneration.CSharp.Tests/Atc.CodeGeneration.CSharp.Tests.csproj index 1a746cfca..dbe709dc2 100644 --- a/test/Atc.CodeGeneration.CSharp.Tests/Atc.CodeGeneration.CSharp.Tests.csproj +++ b/test/Atc.CodeGeneration.CSharp.Tests/Atc.CodeGeneration.CSharp.Tests.csproj @@ -1,18 +1,18 @@ - net8.0 + net9.0 false - - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Atc.Rest.ApiGenerator.CLI.Tests.csproj b/test/Atc.Rest.ApiGenerator.CLI.Tests/Atc.Rest.ApiGenerator.CLI.Tests.csproj index 64458158f..594b1588f 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Atc.Rest.ApiGenerator.CLI.Tests.csproj +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Atc.Rest.ApiGenerator.CLI.Tests.csproj @@ -1,7 +1,7 @@ - net8.0 + net9.0 false false false @@ -63,20 +63,20 @@ - - - - - - + + + + + + - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyServerAll/Mvc_WOPD/src/DemoSample.Api.Generated/Contracts/Files/Results/GetFileByIdResult.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyServerAll/Mvc_WOPD/src/DemoSample.Api.Generated/Contracts/Files/Results/GetFileByIdResult.verified.cs index f27365b12..fb1ca966b 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyServerAll/Mvc_WOPD/src/DemoSample.Api.Generated/Contracts/Files/Results/GetFileByIdResult.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyServerAll/Mvc_WOPD/src/DemoSample.Api.Generated/Contracts/Files/Results/GetFileByIdResult.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,12 +19,12 @@ private GetFileByIdResult(ActionResult result) : base(result) { } /// /// 200 - Ok response. /// - public static GetFileByIdResult Ok(byte[] bytes, string fileName) - => new GetFileByIdResult(ResultFactory.CreateFileContentResult(bytes, fileName)); + public static GetFileByIdResult Ok(byte[] bytes, string contentType, string fileName) + => new GetFileByIdResult(ResultFactory.CreateFileContentResult(bytes, fileName, contentType)); /// /// 404 - NotFound response. /// public static GetFileByIdResult NotFound(string? message = null) => new GetFileByIdResult(new NotFoundObjectResult(message)); -} +} \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyServerAll/Mvc_WOPD/test/DemoSample.Api.Tests/Endpoints/EventArgs/GetEventArgByIdHandlerStub.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyServerAll/Mvc_WOPD/test/DemoSample.Api.Tests/Endpoints/EventArgs/GetEventArgByIdHandlerStub.verified.cs index 915772fe0..a0d243e41 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyServerAll/Mvc_WOPD/test/DemoSample.Api.Tests/Endpoints/EventArgs/GetEventArgByIdHandlerStub.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyServerAll/Mvc_WOPD/test/DemoSample.Api.Tests/Endpoints/EventArgs/GetEventArgByIdHandlerStub.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 @@ -13,8 +13,8 @@ public Task ExecuteAsync( GetEventArgByIdParameters parameters, CancellationToken cancellationToken = default) { - var data = new Fixture().Create(); + var data = new Fixture().Create(); return Task.FromResult(GetEventArgByIdResult.Ok(data)); } -} +} \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyServerAll/Mvc_WOPD/test/DemoSample.Api.Tests/Endpoints/EventArgs/GetEventArgsHandlerStub.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyServerAll/Mvc_WOPD/test/DemoSample.Api.Tests/Endpoints/EventArgs/GetEventArgsHandlerStub.verified.cs index c8a3fa3e9..c614f0ea4 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyServerAll/Mvc_WOPD/test/DemoSample.Api.Tests/Endpoints/EventArgs/GetEventArgsHandlerStub.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyServerAll/Mvc_WOPD/test/DemoSample.Api.Tests/Endpoints/EventArgs/GetEventArgsHandlerStub.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 @@ -12,8 +12,8 @@ public class GetEventArgsHandlerStub : IGetEventArgsHandler public Task ExecuteAsync( CancellationToken cancellationToken = default) { - var data = new Fixture().Create>(); + var data = new Fixture().Create>(); return Task.FromResult(GetEventArgsResult.Ok(data)); } -} +} \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyServerAll/Mvc_WOPD/test/DemoSample.Api.Tests/Endpoints/Files/GetFileByIdHandlerStub.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyServerAll/Mvc_WOPD/test/DemoSample.Api.Tests/Endpoints/Files/GetFileByIdHandlerStub.verified.cs index 92e14e1a9..b6447c22e 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyServerAll/Mvc_WOPD/test/DemoSample.Api.Tests/Endpoints/Files/GetFileByIdHandlerStub.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyServerAll/Mvc_WOPD/test/DemoSample.Api.Tests/Endpoints/Files/GetFileByIdHandlerStub.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 @@ -14,6 +14,6 @@ public Task ExecuteAsync( CancellationToken cancellationToken = default) { var bytes = Encoding.UTF8.GetBytes("Hello World"); - return Task.FromResult(GetFileByIdResult.Ok(bytes, "dummy.txt")); + return Task.FromResult(GetFileByIdResult.Ok(bytes, "text/plain", "dummy.txt")); } -} +} \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyServerAll/Mvc_WOPD/test/DemoSample.Api.Tests/Endpoints/Tasks/GetTasksHandlerStub.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyServerAll/Mvc_WOPD/test/DemoSample.Api.Tests/Endpoints/Tasks/GetTasksHandlerStub.verified.cs index 4de36cb4d..41ba7e236 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyServerAll/Mvc_WOPD/test/DemoSample.Api.Tests/Endpoints/Tasks/GetTasksHandlerStub.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyServerAll/Mvc_WOPD/test/DemoSample.Api.Tests/Endpoints/Tasks/GetTasksHandlerStub.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 @@ -7,13 +7,13 @@ namespace DemoSample.Api.Tests.Endpoints.Tasks; [GeneratedCode("ApiGenerator", "x.x.x.x")] -public class GetTasksHandlerStub : DemoSample.Api.Generated.Contracts.Tasks.IGetTasksHandler +public class GetTasksHandlerStub : Generated.Contracts.Tasks.IGetTasksHandler { - public Task ExecuteAsync( + public Task ExecuteAsync( CancellationToken cancellationToken = default) { - var data = new Fixture().Create>(); + var data = new Fixture().Create>(); - return Task.FromResult(DemoSample.Api.Generated.Contracts.Tasks.GetTasksResult.Ok(data)); + return Task.FromResult(Generated.Contracts.Tasks.GetTasksResult.Ok(data)); } -} +} \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyServerAll/Mvc_WPD/src/DemoSample.Api.Generated/Contracts/Files/Results/GetFileByIdResult.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyServerAll/Mvc_WPD/src/DemoSample.Api.Generated/Contracts/Files/Results/GetFileByIdResult.verified.cs index 438324624..fb1ca966b 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyServerAll/Mvc_WPD/src/DemoSample.Api.Generated/Contracts/Files/Results/GetFileByIdResult.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyServerAll/Mvc_WPD/src/DemoSample.Api.Generated/Contracts/Files/Results/GetFileByIdResult.verified.cs @@ -19,8 +19,8 @@ private GetFileByIdResult(ActionResult result) : base(result) { } /// /// 200 - Ok response. /// - public static GetFileByIdResult Ok(byte[] bytes, string fileName) - => new GetFileByIdResult(ResultFactory.CreateFileContentResult(bytes, fileName)); + public static GetFileByIdResult Ok(byte[] bytes, string contentType, string fileName) + => new GetFileByIdResult(ResultFactory.CreateFileContentResult(bytes, fileName, contentType)); /// /// 404 - NotFound response. diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyServerAll/Mvc_WPD/test/DemoSample.Api.Tests/Endpoints/EventArgs/GetEventArgByIdHandlerStub.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyServerAll/Mvc_WPD/test/DemoSample.Api.Tests/Endpoints/EventArgs/GetEventArgByIdHandlerStub.verified.cs index 915772fe0..a0d243e41 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyServerAll/Mvc_WPD/test/DemoSample.Api.Tests/Endpoints/EventArgs/GetEventArgByIdHandlerStub.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyServerAll/Mvc_WPD/test/DemoSample.Api.Tests/Endpoints/EventArgs/GetEventArgByIdHandlerStub.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 @@ -13,8 +13,8 @@ public Task ExecuteAsync( GetEventArgByIdParameters parameters, CancellationToken cancellationToken = default) { - var data = new Fixture().Create(); + var data = new Fixture().Create(); return Task.FromResult(GetEventArgByIdResult.Ok(data)); } -} +} \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyServerAll/Mvc_WPD/test/DemoSample.Api.Tests/Endpoints/EventArgs/GetEventArgsHandlerStub.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyServerAll/Mvc_WPD/test/DemoSample.Api.Tests/Endpoints/EventArgs/GetEventArgsHandlerStub.verified.cs index c8a3fa3e9..c614f0ea4 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyServerAll/Mvc_WPD/test/DemoSample.Api.Tests/Endpoints/EventArgs/GetEventArgsHandlerStub.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyServerAll/Mvc_WPD/test/DemoSample.Api.Tests/Endpoints/EventArgs/GetEventArgsHandlerStub.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 @@ -12,8 +12,8 @@ public class GetEventArgsHandlerStub : IGetEventArgsHandler public Task ExecuteAsync( CancellationToken cancellationToken = default) { - var data = new Fixture().Create>(); + var data = new Fixture().Create>(); return Task.FromResult(GetEventArgsResult.Ok(data)); } -} +} \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyServerAll/Mvc_WPD/test/DemoSample.Api.Tests/Endpoints/Files/GetFileByIdHandlerStub.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyServerAll/Mvc_WPD/test/DemoSample.Api.Tests/Endpoints/Files/GetFileByIdHandlerStub.verified.cs index 92e14e1a9..b6447c22e 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyServerAll/Mvc_WPD/test/DemoSample.Api.Tests/Endpoints/Files/GetFileByIdHandlerStub.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyServerAll/Mvc_WPD/test/DemoSample.Api.Tests/Endpoints/Files/GetFileByIdHandlerStub.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 @@ -14,6 +14,6 @@ public Task ExecuteAsync( CancellationToken cancellationToken = default) { var bytes = Encoding.UTF8.GetBytes("Hello World"); - return Task.FromResult(GetFileByIdResult.Ok(bytes, "dummy.txt")); + return Task.FromResult(GetFileByIdResult.Ok(bytes, "text/plain", "dummy.txt")); } -} +} \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyServerAll/Mvc_WPD/test/DemoSample.Api.Tests/Endpoints/Tasks/GetTasksHandlerStub.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyServerAll/Mvc_WPD/test/DemoSample.Api.Tests/Endpoints/Tasks/GetTasksHandlerStub.verified.cs index 4de36cb4d..41ba7e236 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyServerAll/Mvc_WPD/test/DemoSample.Api.Tests/Endpoints/Tasks/GetTasksHandlerStub.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/DemoSample/VerifyServerAll/Mvc_WPD/test/DemoSample.Api.Tests/Endpoints/Tasks/GetTasksHandlerStub.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 @@ -7,13 +7,13 @@ namespace DemoSample.Api.Tests.Endpoints.Tasks; [GeneratedCode("ApiGenerator", "x.x.x.x")] -public class GetTasksHandlerStub : DemoSample.Api.Generated.Contracts.Tasks.IGetTasksHandler +public class GetTasksHandlerStub : Generated.Contracts.Tasks.IGetTasksHandler { - public Task ExecuteAsync( + public Task ExecuteAsync( CancellationToken cancellationToken = default) { - var data = new Fixture().Create>(); + var data = new Fixture().Create>(); - return Task.FromResult(DemoSample.Api.Generated.Contracts.Tasks.GetTasksResult.Ok(data)); + return Task.FromResult(Generated.Contracts.Tasks.GetTasksResult.Ok(data)); } -} +} \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAllResponseTypes/VerifyClient/WOPD/src/ExAllResponseTypes.ApiClient.Generated/Endpoints/Example/GetExampleEndpointResult.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAllResponseTypes/VerifyClient/WOPD/src/ExAllResponseTypes.ApiClient.Generated/Endpoints/Example/GetExampleEndpointResult.verified.cs index b0d06f62e..be4c17d12 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAllResponseTypes/VerifyClient/WOPD/src/ExAllResponseTypes.ApiClient.Generated/Endpoints/Example/GetExampleEndpointResult.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAllResponseTypes/VerifyClient/WOPD/src/ExAllResponseTypes.ApiClient.Generated/Endpoints/Example/GetExampleEndpointResult.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 @@ -217,6 +217,11 @@ public string? ProcessingContent ? result : throw new InvalidOperationException("Content is not the expected type - please use the IsProcessing property first."); + public string? EarlyHintsContent + => IsEarlyHints && ContentObject is string result + ? result + : throw new InvalidOperationException("Content is not the expected type - please use the IsEarlyHints property first."); + public ExampleModel OkContent => IsOk && ContentObject is ExampleModel result ? result @@ -501,4 +506,4 @@ public string? NetworkAuthenticationRequiredContent => IsNetworkAuthenticationRequired && ContentObject is string result ? result : throw new InvalidOperationException("Content is not the expected type - please use the IsNetworkAuthenticationRequired property first."); -} +} \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAllResponseTypes/VerifyClient/WOPD/src/ExAllResponseTypes.ApiClient.Generated/Endpoints/Example/Interfaces/IGetExampleEndpointResult.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAllResponseTypes/VerifyClient/WOPD/src/ExAllResponseTypes.ApiClient.Generated/Endpoints/Example/Interfaces/IGetExampleEndpointResult.verified.cs index b37101b61..c0af08668 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAllResponseTypes/VerifyClient/WOPD/src/ExAllResponseTypes.ApiClient.Generated/Endpoints/Example/Interfaces/IGetExampleEndpointResult.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAllResponseTypes/VerifyClient/WOPD/src/ExAllResponseTypes.ApiClient.Generated/Endpoints/Example/Interfaces/IGetExampleEndpointResult.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 @@ -143,6 +143,8 @@ public interface IGetExampleEndpointResult : IEndpointResponse string? ProcessingContent { get; } + string? EarlyHintsContent { get; } + ExampleModel OkContent { get; } string? CreatedContent { get; } @@ -256,4 +258,4 @@ public interface IGetExampleEndpointResult : IEndpointResponse string? NotExtendedContent { get; } string? NetworkAuthenticationRequiredContent { get; } -} +} \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAllResponseTypes/VerifyClient/WPD/src/ExAllResponseTypes.ApiClient.Generated/Endpoints/Example/GetExampleEndpointResult.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAllResponseTypes/VerifyClient/WPD/src/ExAllResponseTypes.ApiClient.Generated/Endpoints/Example/GetExampleEndpointResult.verified.cs index 10d904f27..0f46a665b 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAllResponseTypes/VerifyClient/WPD/src/ExAllResponseTypes.ApiClient.Generated/Endpoints/Example/GetExampleEndpointResult.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAllResponseTypes/VerifyClient/WPD/src/ExAllResponseTypes.ApiClient.Generated/Endpoints/Example/GetExampleEndpointResult.verified.cs @@ -217,6 +217,11 @@ public ProblemDetails ProcessingContent ? result : throw new InvalidOperationException("Content is not the expected type - please use the IsProcessing property first."); + public ProblemDetails EarlyHintsContent + => IsEarlyHints && ContentObject is ProblemDetails result + ? result + : throw new InvalidOperationException("Content is not the expected type - please use the IsEarlyHints property first."); + public ExampleModel OkContent => IsOk && ContentObject is ExampleModel result ? result diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAllResponseTypes/VerifyClient/WPD/src/ExAllResponseTypes.ApiClient.Generated/Endpoints/Example/Interfaces/IGetExampleEndpointResult.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAllResponseTypes/VerifyClient/WPD/src/ExAllResponseTypes.ApiClient.Generated/Endpoints/Example/Interfaces/IGetExampleEndpointResult.verified.cs index d4e709779..4486f7827 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAllResponseTypes/VerifyClient/WPD/src/ExAllResponseTypes.ApiClient.Generated/Endpoints/Example/Interfaces/IGetExampleEndpointResult.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAllResponseTypes/VerifyClient/WPD/src/ExAllResponseTypes.ApiClient.Generated/Endpoints/Example/Interfaces/IGetExampleEndpointResult.verified.cs @@ -143,6 +143,8 @@ public interface IGetExampleEndpointResult : IEndpointResponse ProblemDetails ProcessingContent { get; } + ProblemDetails EarlyHintsContent { get; } + ExampleModel OkContent { get; } ProblemDetails CreatedContent { get; } diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAllResponseTypes/VerifyServerAll/Mvc_WOPD/src/ExAllResponseTypes.Api.Generated/Contracts/Example/Results/GetExampleResult.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAllResponseTypes/VerifyServerAll/Mvc_WOPD/src/ExAllResponseTypes.Api.Generated/Contracts/Example/Results/GetExampleResult.verified.cs index 48a957153..cf2d55195 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAllResponseTypes/VerifyServerAll/Mvc_WOPD/src/ExAllResponseTypes.Api.Generated/Contracts/Example/Results/GetExampleResult.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAllResponseTypes/VerifyServerAll/Mvc_WOPD/src/ExAllResponseTypes.Api.Generated/Contracts/Example/Results/GetExampleResult.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 @@ -38,7 +38,7 @@ public static GetExampleResult Processing(string? message = null) /// 103 - EarlyHints response. /// public static GetExampleResult EarlyHints() - => new GetExampleResult(ResultFactory.CreateContentResult(HttpStatusCode.EarlyHints, string? message = null)); + => new GetExampleResult(ResultFactory.CreateContentResult(HttpStatusCode.EarlyHints, string.Empty)); /// /// 200 - Ok response. diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAllResponseTypes/VerifyServerAll/Mvc_WPD/src/ExAllResponseTypes.Api.Generated/Contracts/Example/Results/GetExampleResult.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAllResponseTypes/VerifyServerAll/Mvc_WPD/src/ExAllResponseTypes.Api.Generated/Contracts/Example/Results/GetExampleResult.verified.cs index ccd230b9a..14ea6e9fd 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAllResponseTypes/VerifyServerAll/Mvc_WPD/src/ExAllResponseTypes.Api.Generated/Contracts/Example/Results/GetExampleResult.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAllResponseTypes/VerifyServerAll/Mvc_WPD/src/ExAllResponseTypes.Api.Generated/Contracts/Example/Results/GetExampleResult.verified.cs @@ -38,7 +38,7 @@ public static GetExampleResult Processing(string? message = null) /// 103 - EarlyHints response. /// public static GetExampleResult EarlyHints() - => new GetExampleResult(ResultFactory.CreateContentResultWithProblemDetails(HttpStatusCode.EarlyHints)); + => new GetExampleResult(ResultFactory.CreateContentResultWithProblemDetails(HttpStatusCode.EarlyHints, string.Empty)); /// /// 200 - Ok response. diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/MinimalApi_WOPD/src/ExAsyncEnumerable.Api.Generated/Contracts/Users/Results/GetUsersResult.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/MinimalApi_WOPD/src/ExAsyncEnumerable.Api.Generated/Contracts/Users/Results/GetUsersResult.verified.cs index 0269925a0..44c888180 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/MinimalApi_WOPD/src/ExAsyncEnumerable.Api.Generated/Contracts/Users/Results/GetUsersResult.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/MinimalApi_WOPD/src/ExAsyncEnumerable.Api.Generated/Contracts/Users/Results/GetUsersResult.verified.cs @@ -24,7 +24,7 @@ private GetUsersResult(IResult result) /// /// 200 - Ok response. /// - public static GetUsersResult Ok(IAsyncEnumerable> result) + public static GetUsersResult Ok(IAsyncEnumerable result) => new(TypedResults.Ok(result)); /// diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/MinimalApi_WOPD/src/ExAsyncEnumerable.Api/Extensions/WebApplicationExtensions.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/MinimalApi_WOPD/src/ExAsyncEnumerable.Api/Extensions/WebApplicationExtensions.verified.cs index df8a3eea3..29cb48de5 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/MinimalApi_WOPD/src/ExAsyncEnumerable.Api/Extensions/WebApplicationExtensions.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/MinimalApi_WOPD/src/ExAsyncEnumerable.Api/Extensions/WebApplicationExtensions.verified.cs @@ -2,6 +2,7 @@ public static class WebApplicationExtensions { + [SuppressMessage("Spacing Rules", "SA1010:Opening Square Brackets Must Be Spaced Correctly", Justification = "OK.")] private static readonly string[] PatchHttpMethods = ["patch"]; public static RouteHandlerBuilder MapPatch( diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/MinimalApi_WOPD/src/ExAsyncEnumerable.Api/Program.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/MinimalApi_WOPD/src/ExAsyncEnumerable.Api/Program.verified.cs index 0905347c1..629635a2c 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/MinimalApi_WOPD/src/ExAsyncEnumerable.Api/Program.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/MinimalApi_WOPD/src/ExAsyncEnumerable.Api/Program.verified.cs @@ -55,7 +55,6 @@ public static void Main(string[] args) app.UseStaticFiles(); - app.UseHttpsRedirection(); app.UseHsts(); diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/MinimalApi_WOPD/src/ExAsyncEnumerable.Domain/GlobalUsings.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/MinimalApi_WOPD/src/ExAsyncEnumerable.Domain/GlobalUsings.verified.cs index 96b6a39d7..68af4d8d7 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/MinimalApi_WOPD/src/ExAsyncEnumerable.Domain/GlobalUsings.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/MinimalApi_WOPD/src/ExAsyncEnumerable.Domain/GlobalUsings.verified.cs @@ -3,6 +3,8 @@ global using ExAsyncEnumerable.Api.Generated.Contracts.Customers; global using ExAsyncEnumerable.Api.Generated.Contracts.Users; +global using ExAsyncEnumerable.Domain.Handlers.Customers; +global using ExAsyncEnumerable.Domain.Handlers.Users; global using Microsoft.Extensions.Configuration; global using Microsoft.Extensions.DependencyInjection; \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/MinimalApi_WOPD/test/ExAsyncEnumerable.Api.Tests/Endpoints/Customers/GetCustomersHandlerStub.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/MinimalApi_WOPD/test/ExAsyncEnumerable.Api.Tests/Endpoints/Customers/GetCustomersHandlerStub.verified.cs index 6e02e77ce..5ea1a9367 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/MinimalApi_WOPD/test/ExAsyncEnumerable.Api.Tests/Endpoints/Customers/GetCustomersHandlerStub.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/MinimalApi_WOPD/test/ExAsyncEnumerable.Api.Tests/Endpoints/Customers/GetCustomersHandlerStub.verified.cs @@ -15,8 +15,16 @@ public Task ExecuteAsync( { var data = new Fixture().Create>(); - var paginationData = new PaginationResult(); + var paginationData = new PaginationResult(10, null, data); - return Task.FromResult(GetCustomersResult.Ok(paginationData)); + return Task.FromResult(GetCustomersResult.Ok(GetDataAsync(paginationData))); + } + + private static async IAsyncEnumerable> GetDataAsync( + PaginationResult data) + { + yield return data; + + await Task.CompletedTask; } } \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/MinimalApi_WOPD/test/ExAsyncEnumerable.Api.Tests/Endpoints/Users/GetUsersHandlerStub.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/MinimalApi_WOPD/test/ExAsyncEnumerable.Api.Tests/Endpoints/Users/GetUsersHandlerStub.verified.cs index 9b1bd62d0..0ca4a701f 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/MinimalApi_WOPD/test/ExAsyncEnumerable.Api.Tests/Endpoints/Users/GetUsersHandlerStub.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/MinimalApi_WOPD/test/ExAsyncEnumerable.Api.Tests/Endpoints/Users/GetUsersHandlerStub.verified.cs @@ -14,6 +14,17 @@ public Task ExecuteAsync( { var data = new Fixture().Create>(); - return Task.FromResult(GetUsersResult.Ok(data)); + return Task.FromResult(GetUsersResult.Ok(GetDataAsync(data))); + } + + private static async IAsyncEnumerable GetDataAsync( + List data) + { + foreach (var item in data) + { + yield return item; + } + + await Task.CompletedTask; } } \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/MinimalApi_WOPD/test/ExAsyncEnumerable.Api.Tests/GlobalUsings.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/MinimalApi_WOPD/test/ExAsyncEnumerable.Api.Tests/GlobalUsings.verified.cs index b7906808e..df28029fb 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/MinimalApi_WOPD/test/ExAsyncEnumerable.Api.Tests/GlobalUsings.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/MinimalApi_WOPD/test/ExAsyncEnumerable.Api.Tests/GlobalUsings.verified.cs @@ -1,21 +1,6 @@ global using System.CodeDom.Compiler; -global using System.Reflection; -global using System.Text; -global using System.Text.Json; -global using System.Text.Json.Serialization; - -global using Atc.Rest.Options; -global using Atc.XUnit; global using AutoFixture; -global using ExAsyncEnumerable.Api.Generated; global using ExAsyncEnumerable.Api.Generated.Contracts.Customers; -global using ExAsyncEnumerable.Api.Generated.Contracts.Users; - -global using Microsoft.AspNetCore.Hosting; -global using Microsoft.AspNetCore.Http; -global using Microsoft.Extensions.Configuration; -global using Microsoft.Extensions.DependencyInjection; - -global using Xunit; \ No newline at end of file +global using ExAsyncEnumerable.Api.Generated.Contracts.Users; \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/MinimalApi_WPD/src/ExAsyncEnumerable.Api.Generated/Contracts/Users/Results/GetUsersResult.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/MinimalApi_WPD/src/ExAsyncEnumerable.Api.Generated/Contracts/Users/Results/GetUsersResult.verified.cs index 0269925a0..44c888180 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/MinimalApi_WPD/src/ExAsyncEnumerable.Api.Generated/Contracts/Users/Results/GetUsersResult.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/MinimalApi_WPD/src/ExAsyncEnumerable.Api.Generated/Contracts/Users/Results/GetUsersResult.verified.cs @@ -24,7 +24,7 @@ private GetUsersResult(IResult result) /// /// 200 - Ok response. /// - public static GetUsersResult Ok(IAsyncEnumerable> result) + public static GetUsersResult Ok(IAsyncEnumerable result) => new(TypedResults.Ok(result)); /// diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/MinimalApi_WPD/src/ExAsyncEnumerable.Api/Extensions/WebApplicationExtensions.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/MinimalApi_WPD/src/ExAsyncEnumerable.Api/Extensions/WebApplicationExtensions.verified.cs index df8a3eea3..29cb48de5 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/MinimalApi_WPD/src/ExAsyncEnumerable.Api/Extensions/WebApplicationExtensions.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/MinimalApi_WPD/src/ExAsyncEnumerable.Api/Extensions/WebApplicationExtensions.verified.cs @@ -2,6 +2,7 @@ public static class WebApplicationExtensions { + [SuppressMessage("Spacing Rules", "SA1010:Opening Square Brackets Must Be Spaced Correctly", Justification = "OK.")] private static readonly string[] PatchHttpMethods = ["patch"]; public static RouteHandlerBuilder MapPatch( diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/MinimalApi_WPD/src/ExAsyncEnumerable.Api/Program.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/MinimalApi_WPD/src/ExAsyncEnumerable.Api/Program.verified.cs index 0905347c1..629635a2c 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/MinimalApi_WPD/src/ExAsyncEnumerable.Api/Program.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/MinimalApi_WPD/src/ExAsyncEnumerable.Api/Program.verified.cs @@ -55,7 +55,6 @@ public static void Main(string[] args) app.UseStaticFiles(); - app.UseHttpsRedirection(); app.UseHsts(); diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/MinimalApi_WPD/src/ExAsyncEnumerable.Domain/GlobalUsings.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/MinimalApi_WPD/src/ExAsyncEnumerable.Domain/GlobalUsings.verified.cs index 96b6a39d7..68af4d8d7 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/MinimalApi_WPD/src/ExAsyncEnumerable.Domain/GlobalUsings.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/MinimalApi_WPD/src/ExAsyncEnumerable.Domain/GlobalUsings.verified.cs @@ -3,6 +3,8 @@ global using ExAsyncEnumerable.Api.Generated.Contracts.Customers; global using ExAsyncEnumerable.Api.Generated.Contracts.Users; +global using ExAsyncEnumerable.Domain.Handlers.Customers; +global using ExAsyncEnumerable.Domain.Handlers.Users; global using Microsoft.Extensions.Configuration; global using Microsoft.Extensions.DependencyInjection; \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/MinimalApi_WPD/test/ExAsyncEnumerable.Api.Tests/Endpoints/Customers/GetCustomersHandlerStub.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/MinimalApi_WPD/test/ExAsyncEnumerable.Api.Tests/Endpoints/Customers/GetCustomersHandlerStub.verified.cs index 6e02e77ce..5ea1a9367 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/MinimalApi_WPD/test/ExAsyncEnumerable.Api.Tests/Endpoints/Customers/GetCustomersHandlerStub.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/MinimalApi_WPD/test/ExAsyncEnumerable.Api.Tests/Endpoints/Customers/GetCustomersHandlerStub.verified.cs @@ -15,8 +15,16 @@ public Task ExecuteAsync( { var data = new Fixture().Create>(); - var paginationData = new PaginationResult(); + var paginationData = new PaginationResult(10, null, data); - return Task.FromResult(GetCustomersResult.Ok(paginationData)); + return Task.FromResult(GetCustomersResult.Ok(GetDataAsync(paginationData))); + } + + private static async IAsyncEnumerable> GetDataAsync( + PaginationResult data) + { + yield return data; + + await Task.CompletedTask; } } \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/MinimalApi_WPD/test/ExAsyncEnumerable.Api.Tests/Endpoints/Users/GetUsersHandlerStub.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/MinimalApi_WPD/test/ExAsyncEnumerable.Api.Tests/Endpoints/Users/GetUsersHandlerStub.verified.cs index 9b1bd62d0..0ca4a701f 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/MinimalApi_WPD/test/ExAsyncEnumerable.Api.Tests/Endpoints/Users/GetUsersHandlerStub.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/MinimalApi_WPD/test/ExAsyncEnumerable.Api.Tests/Endpoints/Users/GetUsersHandlerStub.verified.cs @@ -14,6 +14,17 @@ public Task ExecuteAsync( { var data = new Fixture().Create>(); - return Task.FromResult(GetUsersResult.Ok(data)); + return Task.FromResult(GetUsersResult.Ok(GetDataAsync(data))); + } + + private static async IAsyncEnumerable GetDataAsync( + List data) + { + foreach (var item in data) + { + yield return item; + } + + await Task.CompletedTask; } } \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/MinimalApi_WPD/test/ExAsyncEnumerable.Api.Tests/GlobalUsings.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/MinimalApi_WPD/test/ExAsyncEnumerable.Api.Tests/GlobalUsings.verified.cs index b7906808e..df28029fb 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/MinimalApi_WPD/test/ExAsyncEnumerable.Api.Tests/GlobalUsings.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/MinimalApi_WPD/test/ExAsyncEnumerable.Api.Tests/GlobalUsings.verified.cs @@ -1,21 +1,6 @@ global using System.CodeDom.Compiler; -global using System.Reflection; -global using System.Text; -global using System.Text.Json; -global using System.Text.Json.Serialization; - -global using Atc.Rest.Options; -global using Atc.XUnit; global using AutoFixture; -global using ExAsyncEnumerable.Api.Generated; global using ExAsyncEnumerable.Api.Generated.Contracts.Customers; -global using ExAsyncEnumerable.Api.Generated.Contracts.Users; - -global using Microsoft.AspNetCore.Hosting; -global using Microsoft.AspNetCore.Http; -global using Microsoft.Extensions.Configuration; -global using Microsoft.Extensions.DependencyInjection; - -global using Xunit; \ No newline at end of file +global using ExAsyncEnumerable.Api.Generated.Contracts.Users; \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/Mvc_WOPD/src/ExAsyncEnumerable.Api.Generated/GlobalUsings.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/Mvc_WOPD/src/ExAsyncEnumerable.Api.Generated/GlobalUsings.verified.cs index b2975b59e..3a33e4dd5 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/Mvc_WOPD/src/ExAsyncEnumerable.Api.Generated/GlobalUsings.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/Mvc_WOPD/src/ExAsyncEnumerable.Api.Generated/GlobalUsings.verified.cs @@ -1,6 +1,5 @@ global using System.CodeDom.Compiler; global using System.ComponentModel.DataAnnotations; -global using System.Net; global using Atc.Factories; global using Atc.Rest.Results; diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/Mvc_WOPD/test/ExAsyncEnumerable.Api.Tests/Endpoints/Customers/GetCustomersHandlerStub.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/Mvc_WOPD/test/ExAsyncEnumerable.Api.Tests/Endpoints/Customers/GetCustomersHandlerStub.verified.cs index 6e02e77ce..94a18803d 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/Mvc_WOPD/test/ExAsyncEnumerable.Api.Tests/Endpoints/Customers/GetCustomersHandlerStub.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/Mvc_WOPD/test/ExAsyncEnumerable.Api.Tests/Endpoints/Customers/GetCustomersHandlerStub.verified.cs @@ -15,8 +15,20 @@ public Task ExecuteAsync( { var data = new Fixture().Create>(); - var paginationData = new PaginationResult(); + var paginationData = new PaginationResult + { + PageSize = 10, + Items = data, + }; - return Task.FromResult(GetCustomersResult.Ok(paginationData)); + return Task.FromResult(GetCustomersResult.Ok(GetDataAsync(paginationData))); + } + + private static async IAsyncEnumerable> GetDataAsync( + PaginationResult data) + { + yield return data; + + await Task.CompletedTask; } } \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/Mvc_WOPD/test/ExAsyncEnumerable.Api.Tests/Endpoints/Users/GetUsersHandlerStub.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/Mvc_WOPD/test/ExAsyncEnumerable.Api.Tests/Endpoints/Users/GetUsersHandlerStub.verified.cs index 9b1bd62d0..0ca4a701f 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/Mvc_WOPD/test/ExAsyncEnumerable.Api.Tests/Endpoints/Users/GetUsersHandlerStub.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/Mvc_WOPD/test/ExAsyncEnumerable.Api.Tests/Endpoints/Users/GetUsersHandlerStub.verified.cs @@ -14,6 +14,17 @@ public Task ExecuteAsync( { var data = new Fixture().Create>(); - return Task.FromResult(GetUsersResult.Ok(data)); + return Task.FromResult(GetUsersResult.Ok(GetDataAsync(data))); + } + + private static async IAsyncEnumerable GetDataAsync( + List data) + { + foreach (var item in data) + { + yield return item; + } + + await Task.CompletedTask; } } \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/Mvc_WPD/src/ExAsyncEnumerable.Api.Generated/GlobalUsings.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/Mvc_WPD/src/ExAsyncEnumerable.Api.Generated/GlobalUsings.verified.cs index b2975b59e..3a33e4dd5 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/Mvc_WPD/src/ExAsyncEnumerable.Api.Generated/GlobalUsings.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/Mvc_WPD/src/ExAsyncEnumerable.Api.Generated/GlobalUsings.verified.cs @@ -1,6 +1,5 @@ global using System.CodeDom.Compiler; global using System.ComponentModel.DataAnnotations; -global using System.Net; global using Atc.Factories; global using Atc.Rest.Results; diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/Mvc_WPD/test/ExAsyncEnumerable.Api.Tests/Endpoints/Customers/GetCustomersHandlerStub.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/Mvc_WPD/test/ExAsyncEnumerable.Api.Tests/Endpoints/Customers/GetCustomersHandlerStub.verified.cs index 6e02e77ce..94a18803d 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/Mvc_WPD/test/ExAsyncEnumerable.Api.Tests/Endpoints/Customers/GetCustomersHandlerStub.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/Mvc_WPD/test/ExAsyncEnumerable.Api.Tests/Endpoints/Customers/GetCustomersHandlerStub.verified.cs @@ -15,8 +15,20 @@ public Task ExecuteAsync( { var data = new Fixture().Create>(); - var paginationData = new PaginationResult(); + var paginationData = new PaginationResult + { + PageSize = 10, + Items = data, + }; - return Task.FromResult(GetCustomersResult.Ok(paginationData)); + return Task.FromResult(GetCustomersResult.Ok(GetDataAsync(paginationData))); + } + + private static async IAsyncEnumerable> GetDataAsync( + PaginationResult data) + { + yield return data; + + await Task.CompletedTask; } } \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/Mvc_WPD/test/ExAsyncEnumerable.Api.Tests/Endpoints/Users/GetUsersHandlerStub.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/Mvc_WPD/test/ExAsyncEnumerable.Api.Tests/Endpoints/Users/GetUsersHandlerStub.verified.cs index 9b1bd62d0..0ca4a701f 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/Mvc_WPD/test/ExAsyncEnumerable.Api.Tests/Endpoints/Users/GetUsersHandlerStub.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExAsyncEnumerable/VerifyServerAll/Mvc_WPD/test/ExAsyncEnumerable.Api.Tests/Endpoints/Users/GetUsersHandlerStub.verified.cs @@ -14,6 +14,17 @@ public Task ExecuteAsync( { var data = new Fixture().Create>(); - return Task.FromResult(GetUsersResult.Ok(data)); + return Task.FromResult(GetUsersResult.Ok(GetDataAsync(data))); + } + + private static async IAsyncEnumerable GetDataAsync( + List data) + { + foreach (var item in data) + { + yield return item; + } + + await Task.CompletedTask; } } \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExGenericPagination/VerifyServerAll/Mvc_WOPD/src/ExGenericPagination.Api.Generated/GlobalUsings.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExGenericPagination/VerifyServerAll/Mvc_WOPD/src/ExGenericPagination.Api.Generated/GlobalUsings.verified.cs index c916cfed3..014f505b6 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExGenericPagination/VerifyServerAll/Mvc_WOPD/src/ExGenericPagination.Api.Generated/GlobalUsings.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExGenericPagination/VerifyServerAll/Mvc_WOPD/src/ExGenericPagination.Api.Generated/GlobalUsings.verified.cs @@ -1,6 +1,5 @@ global using System.CodeDom.Compiler; global using System.ComponentModel.DataAnnotations; -global using System.Net; global using Atc.Rest.Results; diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExGenericPagination/VerifyServerAll/Mvc_WOPD/test/ExGenericPagination.Api.Tests/Endpoints/Cats/GetCatsHandlerStub.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExGenericPagination/VerifyServerAll/Mvc_WOPD/test/ExGenericPagination.Api.Tests/Endpoints/Cats/GetCatsHandlerStub.verified.cs index 9fbde33da..99a3e5ed8 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExGenericPagination/VerifyServerAll/Mvc_WOPD/test/ExGenericPagination.Api.Tests/Endpoints/Cats/GetCatsHandlerStub.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExGenericPagination/VerifyServerAll/Mvc_WOPD/test/ExGenericPagination.Api.Tests/Endpoints/Cats/GetCatsHandlerStub.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 @@ -15,8 +15,12 @@ public Task ExecuteAsync( { var data = new Fixture().Create>(); - var paginationData = new PaginatedResult(); + var paginationData = new PaginatedResult + { + PageSize = 10, + Results = data, + }; return Task.FromResult(GetCatsResult.Ok(paginationData)); } -} +} \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExGenericPagination/VerifyServerAll/Mvc_WOPD/test/ExGenericPagination.Api.Tests/Endpoints/Dogs/GetDogsHandlerStub.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExGenericPagination/VerifyServerAll/Mvc_WOPD/test/ExGenericPagination.Api.Tests/Endpoints/Dogs/GetDogsHandlerStub.verified.cs index 22f0d49ee..1a27cc233 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExGenericPagination/VerifyServerAll/Mvc_WOPD/test/ExGenericPagination.Api.Tests/Endpoints/Dogs/GetDogsHandlerStub.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExGenericPagination/VerifyServerAll/Mvc_WOPD/test/ExGenericPagination.Api.Tests/Endpoints/Dogs/GetDogsHandlerStub.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 @@ -15,8 +15,12 @@ public Task ExecuteAsync( { var data = new Fixture().Create>(); - var paginationData = new PaginatedResult(); + var paginationData = new PaginatedResult + { + PageSize = 10, + Results = data, + }; return Task.FromResult(GetDogsResult.Ok(paginationData)); } -} +} \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExGenericPagination/VerifyServerAll/Mvc_WPD/src/ExGenericPagination.Api.Generated/GlobalUsings.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExGenericPagination/VerifyServerAll/Mvc_WPD/src/ExGenericPagination.Api.Generated/GlobalUsings.verified.cs index c916cfed3..014f505b6 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExGenericPagination/VerifyServerAll/Mvc_WPD/src/ExGenericPagination.Api.Generated/GlobalUsings.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExGenericPagination/VerifyServerAll/Mvc_WPD/src/ExGenericPagination.Api.Generated/GlobalUsings.verified.cs @@ -1,6 +1,5 @@ global using System.CodeDom.Compiler; global using System.ComponentModel.DataAnnotations; -global using System.Net; global using Atc.Rest.Results; diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExGenericPagination/VerifyServerAll/Mvc_WPD/test/ExGenericPagination.Api.Tests/Endpoints/Cats/GetCatsHandlerStub.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExGenericPagination/VerifyServerAll/Mvc_WPD/test/ExGenericPagination.Api.Tests/Endpoints/Cats/GetCatsHandlerStub.verified.cs index 9fbde33da..99a3e5ed8 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExGenericPagination/VerifyServerAll/Mvc_WPD/test/ExGenericPagination.Api.Tests/Endpoints/Cats/GetCatsHandlerStub.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExGenericPagination/VerifyServerAll/Mvc_WPD/test/ExGenericPagination.Api.Tests/Endpoints/Cats/GetCatsHandlerStub.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 @@ -15,8 +15,12 @@ public Task ExecuteAsync( { var data = new Fixture().Create>(); - var paginationData = new PaginatedResult(); + var paginationData = new PaginatedResult + { + PageSize = 10, + Results = data, + }; return Task.FromResult(GetCatsResult.Ok(paginationData)); } -} +} \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExGenericPagination/VerifyServerAll/Mvc_WPD/test/ExGenericPagination.Api.Tests/Endpoints/Dogs/GetDogsHandlerStub.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExGenericPagination/VerifyServerAll/Mvc_WPD/test/ExGenericPagination.Api.Tests/Endpoints/Dogs/GetDogsHandlerStub.verified.cs index 22f0d49ee..1a27cc233 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExGenericPagination/VerifyServerAll/Mvc_WPD/test/ExGenericPagination.Api.Tests/Endpoints/Dogs/GetDogsHandlerStub.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExGenericPagination/VerifyServerAll/Mvc_WPD/test/ExGenericPagination.Api.Tests/Endpoints/Dogs/GetDogsHandlerStub.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 @@ -15,8 +15,12 @@ public Task ExecuteAsync( { var data = new Fixture().Create>(); - var paginationData = new PaginatedResult(); + var paginationData = new PaginatedResult + { + PageSize = 10, + Results = data, + }; return Task.FromResult(GetDogsResult.Ok(paginationData)); } -} +} \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyServerAll/Mvc_WOPD/src/ExNsWithTask.Api.Generated/GlobalUsings.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyServerAll/Mvc_WOPD/src/ExNsWithTask.Api.Generated/GlobalUsings.verified.cs index 7fe5898fe..87836292f 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyServerAll/Mvc_WOPD/src/ExNsWithTask.Api.Generated/GlobalUsings.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyServerAll/Mvc_WOPD/src/ExNsWithTask.Api.Generated/GlobalUsings.verified.cs @@ -1,6 +1,5 @@ global using System.CodeDom.Compiler; global using System.ComponentModel.DataAnnotations; -global using System.Net; global using Atc.Rest.Results; diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyServerAll/Mvc_WOPD/test/ExNsWithTask.Api.Tests/Endpoints/EventArgs/GetEventArgByIdHandlerStub.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyServerAll/Mvc_WOPD/test/ExNsWithTask.Api.Tests/Endpoints/EventArgs/GetEventArgByIdHandlerStub.verified.cs index 87dd34fb6..1e2397f70 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyServerAll/Mvc_WOPD/test/ExNsWithTask.Api.Tests/Endpoints/EventArgs/GetEventArgByIdHandlerStub.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyServerAll/Mvc_WOPD/test/ExNsWithTask.Api.Tests/Endpoints/EventArgs/GetEventArgByIdHandlerStub.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 @@ -13,8 +13,8 @@ public Task ExecuteAsync( GetEventArgByIdParameters parameters, CancellationToken cancellationToken = default) { - var data = new Fixture().Create(); + var data = new Fixture().Create(); return Task.FromResult(GetEventArgByIdResult.Ok(data)); } -} +} \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyServerAll/Mvc_WOPD/test/ExNsWithTask.Api.Tests/Endpoints/EventArgs/GetEventArgsHandlerStub.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyServerAll/Mvc_WOPD/test/ExNsWithTask.Api.Tests/Endpoints/EventArgs/GetEventArgsHandlerStub.verified.cs index 9e62c04f8..d5a63f63b 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyServerAll/Mvc_WOPD/test/ExNsWithTask.Api.Tests/Endpoints/EventArgs/GetEventArgsHandlerStub.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyServerAll/Mvc_WOPD/test/ExNsWithTask.Api.Tests/Endpoints/EventArgs/GetEventArgsHandlerStub.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 @@ -12,8 +12,8 @@ public class GetEventArgsHandlerStub : IGetEventArgsHandler public Task ExecuteAsync( CancellationToken cancellationToken = default) { - var data = new Fixture().Create>(); + var data = new Fixture().Create>(); return Task.FromResult(GetEventArgsResult.Ok(data)); } -} +} \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyServerAll/Mvc_WOPD/test/ExNsWithTask.Api.Tests/Endpoints/Orders/GetOrdersHandlerStub.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyServerAll/Mvc_WOPD/test/ExNsWithTask.Api.Tests/Endpoints/Orders/GetOrdersHandlerStub.verified.cs index b052336ee..78f5ceef0 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyServerAll/Mvc_WOPD/test/ExNsWithTask.Api.Tests/Endpoints/Orders/GetOrdersHandlerStub.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyServerAll/Mvc_WOPD/test/ExNsWithTask.Api.Tests/Endpoints/Orders/GetOrdersHandlerStub.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 @@ -15,8 +15,12 @@ public Task ExecuteAsync( { var data = new Fixture().Create>(); - var paginationData = new PaginationResult(); + var paginationData = new PaginationResult + { + PageSize = 10, + Results = data, + }; return Task.FromResult(GetOrdersResult.Ok(paginationData)); } -} +} \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyServerAll/Mvc_WOPD/test/ExNsWithTask.Api.Tests/Endpoints/Tasks/GetTasksHandlerStub.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyServerAll/Mvc_WOPD/test/ExNsWithTask.Api.Tests/Endpoints/Tasks/GetTasksHandlerStub.verified.cs index 1660556b1..e5f60a075 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyServerAll/Mvc_WOPD/test/ExNsWithTask.Api.Tests/Endpoints/Tasks/GetTasksHandlerStub.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyServerAll/Mvc_WOPD/test/ExNsWithTask.Api.Tests/Endpoints/Tasks/GetTasksHandlerStub.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 @@ -7,13 +7,13 @@ namespace ExNsWithTask.Api.Tests.Endpoints.Tasks; [GeneratedCode("ApiGenerator", "x.x.x.x")] -public class GetTasksHandlerStub : ExNsWithTask.Api.Generated.Contracts.Tasks.IGetTasksHandler +public class GetTasksHandlerStub : Generated.Contracts.Tasks.IGetTasksHandler { - public Task ExecuteAsync( + public Task ExecuteAsync( CancellationToken cancellationToken = default) { - var data = new Fixture().Create>(); + var data = new Fixture().Create>(); - return Task.FromResult(ExNsWithTask.Api.Generated.Contracts.Tasks.GetTasksResult.Ok(data)); + return Task.FromResult(Generated.Contracts.Tasks.GetTasksResult.Ok(data)); } -} +} \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyServerAll/Mvc_WOPD/test/ExNsWithTask.Api.Tests/Endpoints/TestUnits/ListTestUnitsHandlerStub.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyServerAll/Mvc_WOPD/test/ExNsWithTask.Api.Tests/Endpoints/TestUnits/ListTestUnitsHandlerStub.verified.cs index d8d0b7f5a..cbe294eed 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyServerAll/Mvc_WOPD/test/ExNsWithTask.Api.Tests/Endpoints/TestUnits/ListTestUnitsHandlerStub.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyServerAll/Mvc_WOPD/test/ExNsWithTask.Api.Tests/Endpoints/TestUnits/ListTestUnitsHandlerStub.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 @@ -15,8 +15,12 @@ public Task ExecuteAsync( { var data = new Fixture().Create>(); - var paginationData = new PaginationResult(); + var paginationData = new PaginationResult + { + PageSize = 10, + Results = data, + }; return Task.FromResult(ListTestUnitsResult.Ok(paginationData)); } -} +} \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyServerAll/Mvc_WPD/src/ExNsWithTask.Api.Generated/GlobalUsings.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyServerAll/Mvc_WPD/src/ExNsWithTask.Api.Generated/GlobalUsings.verified.cs index 7fe5898fe..87836292f 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyServerAll/Mvc_WPD/src/ExNsWithTask.Api.Generated/GlobalUsings.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyServerAll/Mvc_WPD/src/ExNsWithTask.Api.Generated/GlobalUsings.verified.cs @@ -1,6 +1,5 @@ global using System.CodeDom.Compiler; global using System.ComponentModel.DataAnnotations; -global using System.Net; global using Atc.Rest.Results; diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyServerAll/Mvc_WPD/test/ExNsWithTask.Api.Tests/Endpoints/EventArgs/GetEventArgByIdHandlerStub.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyServerAll/Mvc_WPD/test/ExNsWithTask.Api.Tests/Endpoints/EventArgs/GetEventArgByIdHandlerStub.verified.cs index 87dd34fb6..1e2397f70 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyServerAll/Mvc_WPD/test/ExNsWithTask.Api.Tests/Endpoints/EventArgs/GetEventArgByIdHandlerStub.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyServerAll/Mvc_WPD/test/ExNsWithTask.Api.Tests/Endpoints/EventArgs/GetEventArgByIdHandlerStub.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 @@ -13,8 +13,8 @@ public Task ExecuteAsync( GetEventArgByIdParameters parameters, CancellationToken cancellationToken = default) { - var data = new Fixture().Create(); + var data = new Fixture().Create(); return Task.FromResult(GetEventArgByIdResult.Ok(data)); } -} +} \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyServerAll/Mvc_WPD/test/ExNsWithTask.Api.Tests/Endpoints/EventArgs/GetEventArgsHandlerStub.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyServerAll/Mvc_WPD/test/ExNsWithTask.Api.Tests/Endpoints/EventArgs/GetEventArgsHandlerStub.verified.cs index 9e62c04f8..d5a63f63b 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyServerAll/Mvc_WPD/test/ExNsWithTask.Api.Tests/Endpoints/EventArgs/GetEventArgsHandlerStub.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyServerAll/Mvc_WPD/test/ExNsWithTask.Api.Tests/Endpoints/EventArgs/GetEventArgsHandlerStub.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 @@ -12,8 +12,8 @@ public class GetEventArgsHandlerStub : IGetEventArgsHandler public Task ExecuteAsync( CancellationToken cancellationToken = default) { - var data = new Fixture().Create>(); + var data = new Fixture().Create>(); return Task.FromResult(GetEventArgsResult.Ok(data)); } -} +} \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyServerAll/Mvc_WPD/test/ExNsWithTask.Api.Tests/Endpoints/Orders/GetOrdersHandlerStub.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyServerAll/Mvc_WPD/test/ExNsWithTask.Api.Tests/Endpoints/Orders/GetOrdersHandlerStub.verified.cs index b052336ee..78f5ceef0 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyServerAll/Mvc_WPD/test/ExNsWithTask.Api.Tests/Endpoints/Orders/GetOrdersHandlerStub.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyServerAll/Mvc_WPD/test/ExNsWithTask.Api.Tests/Endpoints/Orders/GetOrdersHandlerStub.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 @@ -15,8 +15,12 @@ public Task ExecuteAsync( { var data = new Fixture().Create>(); - var paginationData = new PaginationResult(); + var paginationData = new PaginationResult + { + PageSize = 10, + Results = data, + }; return Task.FromResult(GetOrdersResult.Ok(paginationData)); } -} +} \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyServerAll/Mvc_WPD/test/ExNsWithTask.Api.Tests/Endpoints/Tasks/GetTasksHandlerStub.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyServerAll/Mvc_WPD/test/ExNsWithTask.Api.Tests/Endpoints/Tasks/GetTasksHandlerStub.verified.cs index 1660556b1..e5f60a075 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyServerAll/Mvc_WPD/test/ExNsWithTask.Api.Tests/Endpoints/Tasks/GetTasksHandlerStub.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyServerAll/Mvc_WPD/test/ExNsWithTask.Api.Tests/Endpoints/Tasks/GetTasksHandlerStub.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 @@ -7,13 +7,13 @@ namespace ExNsWithTask.Api.Tests.Endpoints.Tasks; [GeneratedCode("ApiGenerator", "x.x.x.x")] -public class GetTasksHandlerStub : ExNsWithTask.Api.Generated.Contracts.Tasks.IGetTasksHandler +public class GetTasksHandlerStub : Generated.Contracts.Tasks.IGetTasksHandler { - public Task ExecuteAsync( + public Task ExecuteAsync( CancellationToken cancellationToken = default) { - var data = new Fixture().Create>(); + var data = new Fixture().Create>(); - return Task.FromResult(ExNsWithTask.Api.Generated.Contracts.Tasks.GetTasksResult.Ok(data)); + return Task.FromResult(Generated.Contracts.Tasks.GetTasksResult.Ok(data)); } -} +} \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyServerAll/Mvc_WPD/test/ExNsWithTask.Api.Tests/Endpoints/TestUnits/ListTestUnitsHandlerStub.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyServerAll/Mvc_WPD/test/ExNsWithTask.Api.Tests/Endpoints/TestUnits/ListTestUnitsHandlerStub.verified.cs index d8d0b7f5a..cbe294eed 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyServerAll/Mvc_WPD/test/ExNsWithTask.Api.Tests/Endpoints/TestUnits/ListTestUnitsHandlerStub.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/ExNsWithTask/VerifyServerAll/Mvc_WPD/test/ExNsWithTask.Api.Tests/Endpoints/TestUnits/ListTestUnitsHandlerStub.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 @@ -15,8 +15,12 @@ public Task ExecuteAsync( { var data = new Fixture().Create>(); - var paginationData = new PaginationResult(); + var paginationData = new PaginationResult + { + PageSize = 10, + Results = data, + }; return Task.FromResult(ListTestUnitsResult.Ok(paginationData)); } -} +} \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/src/Structure1.Api.Generated/Addresses/MyContracts/Results/GetAddressesByPostalCodesResult.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/src/Structure1.Api.Generated/Addresses/MyContracts/Results/GetAddressesByPostalCodesResult.verified.cs index 89f5f0ccf..acf69fc86 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/src/Structure1.Api.Generated/Addresses/MyContracts/Results/GetAddressesByPostalCodesResult.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/src/Structure1.Api.Generated/Addresses/MyContracts/Results/GetAddressesByPostalCodesResult.verified.cs @@ -24,7 +24,7 @@ private GetAddressesByPostalCodesResult(IResult result) /// /// 200 - Ok response. /// - public static GetAddressesByPostalCodesResult Ok(List
result) + public static GetAddressesByPostalCodesResult Ok(IEnumerable
result) => new(TypedResults.Ok(result)); /// diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/src/Structure1.Api.Generated/EventArgs/MyContracts/Results/GetEventArgsResult.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/src/Structure1.Api.Generated/EventArgs/MyContracts/Results/GetEventArgsResult.verified.cs index 6730ef585..984d8b0c0 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/src/Structure1.Api.Generated/EventArgs/MyContracts/Results/GetEventArgsResult.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/src/Structure1.Api.Generated/EventArgs/MyContracts/Results/GetEventArgsResult.verified.cs @@ -24,7 +24,7 @@ private GetEventArgsResult(IResult result) /// /// 200 - Ok response. /// - public static GetEventArgsResult Ok(List result) + public static GetEventArgsResult Ok(IEnumerable result) => new(TypedResults.Ok(result)); /// diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/src/Structure1.Api.Generated/Files/MyContracts/Results/GetFileByIdResult.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/src/Structure1.Api.Generated/Files/MyContracts/Results/GetFileByIdResult.verified.cs index 3c6a7cc14..62cd92fc2 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/src/Structure1.Api.Generated/Files/MyContracts/Results/GetFileByIdResult.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/src/Structure1.Api.Generated/Files/MyContracts/Results/GetFileByIdResult.verified.cs @@ -24,12 +24,18 @@ private GetFileByIdResult(IResult result) /// /// 200 - Ok response. /// - public static GetFileByIdResult Ok(string? message = null) - => new(TypedResults.Ok(message)); + public static GetFileByIdResult Ok(byte[] bytes, string contentType, string fileName) + => new(TypedResults.Bytes(bytes, contentType, fileName)); /// /// 404 - NotFound response. /// public static GetFileByIdResult NotFound(string? message = null) => new(TypedResults.NotFound(message)); + + /// + /// Performs an implicit conversion from GetFileByIdResult to IResult. + /// + public static IResult ToIResult(GetFileByIdResult result) + => result.Result; } \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/src/Structure1.Api.Generated/MyEndpoints/EventArgsEndpointDefinition.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/src/Structure1.Api.Generated/MyEndpoints/EventArgsEndpointDefinition.verified.cs index 06ab7175d..9e7e1797c 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/src/Structure1.Api.Generated/MyEndpoints/EventArgsEndpointDefinition.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/src/Structure1.Api.Generated/MyEndpoints/EventArgsEndpointDefinition.verified.cs @@ -26,7 +26,7 @@ public void DefineEndpoints( .WithName("GetEventArgs") .WithSummary("Get EventArgs List.") .WithDescription("Get EventArgs List.") - .Produces>(); + .Produces>(); eventArgs .MapGet("{id}", GetEventArgById) @@ -34,7 +34,7 @@ public void DefineEndpoints( .WithSummary("Get EventArgs By Id.") .WithDescription("Get EventArgs By Id.") .AddEndpointFilter>() - .Produces() + .Produces() .Produces(StatusCodes.Status400BadRequest) .Produces(StatusCodes.Status404NotFound); } diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/src/Structure1.Api.Generated/MyEndpoints/TasksEndpointDefinition.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/src/Structure1.Api.Generated/MyEndpoints/TasksEndpointDefinition.verified.cs index ec754252e..064106e0f 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/src/Structure1.Api.Generated/MyEndpoints/TasksEndpointDefinition.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/src/Structure1.Api.Generated/MyEndpoints/TasksEndpointDefinition.verified.cs @@ -26,7 +26,7 @@ public void DefineEndpoints( .WithName("GetTasks") .WithSummary("Returns tasks.") .WithDescription("Returns tasks.") - .Produces>(); + .Produces>(); } internal async Task GetTasks( diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/src/Structure1.Api.Generated/Tasks/MyContracts/Results/GetTasksResult.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/src/Structure1.Api.Generated/Tasks/MyContracts/Results/GetTasksResult.verified.cs index 28966b69c..a8d973f1f 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/src/Structure1.Api.Generated/Tasks/MyContracts/Results/GetTasksResult.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/src/Structure1.Api.Generated/Tasks/MyContracts/Results/GetTasksResult.verified.cs @@ -24,7 +24,7 @@ private GetTasksResult(IResult result) /// /// 200 - Ok response. /// - public static GetTasksResult Ok(List result) + public static GetTasksResult Ok(IEnumerable result) => new(TypedResults.Ok(result)); /// diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/src/Structure1.Api.Generated/Users/MyContracts/Models/CreateUserRequest.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/src/Structure1.Api.Generated/Users/MyContracts/Models/CreateUserRequest.verified.cs index 9e09a2294..8aec8d7b7 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/src/Structure1.Api.Generated/Users/MyContracts/Models/CreateUserRequest.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/src/Structure1.Api.Generated/Users/MyContracts/Models/CreateUserRequest.verified.cs @@ -19,7 +19,7 @@ public record CreateUserRequest( [property: Uri] Uri Homepage, [property: Required] GenderType Gender, Address? MyNullableAddress, - [property: Required] Object Tags, - Object DesiredProperties1, - Object? DesiredProperties2, - Object? DesiredProperties3); \ No newline at end of file + [property: Required] Dictionary Tags, + Dictionary DesiredProperties1, + Dictionary? DesiredProperties2, + Dictionary? DesiredProperties3); \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/src/Structure1.Api.Generated/Users/MyContracts/Results/GetUsersResult.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/src/Structure1.Api.Generated/Users/MyContracts/Results/GetUsersResult.verified.cs index 614bf17bc..a32220259 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/src/Structure1.Api.Generated/Users/MyContracts/Results/GetUsersResult.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/src/Structure1.Api.Generated/Users/MyContracts/Results/GetUsersResult.verified.cs @@ -24,7 +24,7 @@ private GetUsersResult(IResult result) /// /// 200 - Ok response. /// - public static GetUsersResult Ok(List result) + public static GetUsersResult Ok(IEnumerable result) => new(TypedResults.Ok(result)); /// diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/src/Structure1.Api.Generated/Users/MyContracts/Results/PostUserResult.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/src/Structure1.Api.Generated/Users/MyContracts/Results/PostUserResult.verified.cs index d33998f47..5cfda3d7d 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/src/Structure1.Api.Generated/Users/MyContracts/Results/PostUserResult.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/src/Structure1.Api.Generated/Users/MyContracts/Results/PostUserResult.verified.cs @@ -38,4 +38,10 @@ public static PostUserResult BadRequest(string? message = null) /// public static PostUserResult Conflict(string? message = null) => new(TypedResults.Conflict(message)); + + /// + /// Performs an implicit conversion from PostUserResult to IResult. + /// + public static IResult ToIResult(PostUserResult result) + => result.Result; } \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/src/Structure1.Api/Extensions/WebApplicationExtensions.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/src/Structure1.Api/Extensions/WebApplicationExtensions.verified.cs index d8c6520fc..c45a50755 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/src/Structure1.Api/Extensions/WebApplicationExtensions.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/src/Structure1.Api/Extensions/WebApplicationExtensions.verified.cs @@ -2,6 +2,7 @@ public static class WebApplicationExtensions { + [SuppressMessage("Spacing Rules", "SA1010:Opening Square Brackets Must Be Spaced Correctly", Justification = "OK.")] private static readonly string[] PatchHttpMethods = ["patch"]; public static RouteHandlerBuilder MapPatch( diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/src/Structure1.Api/Program.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/src/Structure1.Api/Program.verified.cs index 7fc793bb9..ba083ff73 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/src/Structure1.Api/Program.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/src/Structure1.Api/Program.verified.cs @@ -55,7 +55,6 @@ public static void Main(string[] args) app.UseStaticFiles(); - app.UseHttpsRedirection(); app.UseHsts(); diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/src/Structure1.Domain/GlobalUsings.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/src/Structure1.Domain/GlobalUsings.verified.cs index 23a5d0c9f..2f6982cc0 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/src/Structure1.Domain/GlobalUsings.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/src/Structure1.Domain/GlobalUsings.verified.cs @@ -12,4 +12,13 @@ global using Structure1.Api.Generated.Orders.MyContracts; global using Structure1.Api.Generated.RouteWithDash.MyContracts; global using Structure1.Api.Generated.Tasks.MyContracts; -global using Structure1.Api.Generated.Users.MyContracts; \ No newline at end of file +global using Structure1.Api.Generated.Users.MyContracts; +global using Structure1.Domain.Accounts.MyHandlers; +global using Structure1.Domain.Addresses.MyHandlers; +global using Structure1.Domain.EventArgs.MyHandlers; +global using Structure1.Domain.Files.MyHandlers; +global using Structure1.Domain.Items.MyHandlers; +global using Structure1.Domain.Orders.MyHandlers; +global using Structure1.Domain.RouteWithDash.MyHandlers; +global using Structure1.Domain.Tasks.MyHandlers; +global using Structure1.Domain.Users.MyHandlers; \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/test/Structure1.Api.Tests/EventArgs/MyEndpoints/GetEventArgByIdHandlerStub.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/test/Structure1.Api.Tests/EventArgs/MyEndpoints/GetEventArgByIdHandlerStub.verified.cs index 97aa2826a..1fbe070e2 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/test/Structure1.Api.Tests/EventArgs/MyEndpoints/GetEventArgByIdHandlerStub.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/test/Structure1.Api.Tests/EventArgs/MyEndpoints/GetEventArgByIdHandlerStub.verified.cs @@ -13,7 +13,7 @@ public Task ExecuteAsync( GetEventArgByIdParameters parameters, CancellationToken cancellationToken = default) { - var data = new Fixture().Create(); + var data = new Fixture().Create(); return Task.FromResult(GetEventArgByIdResult.Ok(data)); } diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/test/Structure1.Api.Tests/EventArgs/MyEndpoints/GetEventArgsHandlerStub.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/test/Structure1.Api.Tests/EventArgs/MyEndpoints/GetEventArgsHandlerStub.verified.cs index 449d26600..01f3ae10b 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/test/Structure1.Api.Tests/EventArgs/MyEndpoints/GetEventArgsHandlerStub.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/test/Structure1.Api.Tests/EventArgs/MyEndpoints/GetEventArgsHandlerStub.verified.cs @@ -12,7 +12,7 @@ public class GetEventArgsHandlerStub : IGetEventArgsHandler public Task ExecuteAsync( CancellationToken cancellationToken = default) { - var data = new Fixture().Create>(); + var data = new Fixture().Create>(); return Task.FromResult(GetEventArgsResult.Ok(data)); } diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/test/Structure1.Api.Tests/Files/MyEndpoints/GetFileByIdHandlerStub.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/test/Structure1.Api.Tests/Files/MyEndpoints/GetFileByIdHandlerStub.verified.cs index 0246fcdd9..b34bdafe6 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/test/Structure1.Api.Tests/Files/MyEndpoints/GetFileByIdHandlerStub.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/test/Structure1.Api.Tests/Files/MyEndpoints/GetFileByIdHandlerStub.verified.cs @@ -14,6 +14,6 @@ public Task ExecuteAsync( CancellationToken cancellationToken = default) { var bytes = Encoding.UTF8.GetBytes("Hello World"); - return Task.FromResult(GetFileByIdResult.Ok(bytes, "dummy.txt")); + return Task.FromResult(GetFileByIdResult.Ok(bytes, "text/plain", "dummy.txt")); } } \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/test/Structure1.Api.Tests/GlobalUsings.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/test/Structure1.Api.Tests/GlobalUsings.verified.cs index d88aa660e..42f6f6f85 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/test/Structure1.Api.Tests/GlobalUsings.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/test/Structure1.Api.Tests/GlobalUsings.verified.cs @@ -1,21 +1,10 @@ global using System.CodeDom.Compiler; -global using System.Reflection; global using System.Text; -global using System.Text.Json; -global using System.Text.Json.Serialization; -global using Atc.Rest.Options; global using Atc.Rest.Results; -global using Atc.XUnit; global using AutoFixture; -global using Microsoft.AspNetCore.Hosting; -global using Microsoft.AspNetCore.Http; -global using Microsoft.Extensions.Configuration; -global using Microsoft.Extensions.DependencyInjection; - -global using Structure1.Api.Generated; global using Structure1.Api.Generated.Accounts.MyContracts; global using Structure1.Api.Generated.Addresses.MyContracts; global using Structure1.Api.Generated.EventArgs.MyContracts; @@ -24,6 +13,4 @@ global using Structure1.Api.Generated.MyContracts; global using Structure1.Api.Generated.Orders.MyContracts; global using Structure1.Api.Generated.RouteWithDash.MyContracts; -global using Structure1.Api.Generated.Users.MyContracts; - -global using Xunit; \ No newline at end of file +global using Structure1.Api.Generated.Users.MyContracts; \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/test/Structure1.Api.Tests/Tasks/MyEndpoints/GetTasksHandlerStub.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/test/Structure1.Api.Tests/Tasks/MyEndpoints/GetTasksHandlerStub.verified.cs index b03679c27..9a12a82f7 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/test/Structure1.Api.Tests/Tasks/MyEndpoints/GetTasksHandlerStub.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WOPD/test/Structure1.Api.Tests/Tasks/MyEndpoints/GetTasksHandlerStub.verified.cs @@ -7,13 +7,13 @@ namespace Structure1.Api.Tests.Tasks.MyEndpoints; [GeneratedCode("ApiGenerator", "x.x.x.x")] -public class GetTasksHandlerStub : Structure1.Api.Tests.Tasks.MyEndpoints.IGetTasksHandler +public class GetTasksHandlerStub : Generated.Tasks.MyContracts.IGetTasksHandler { - public Task ExecuteAsync( + public Task ExecuteAsync( CancellationToken cancellationToken = default) { - var data = new Fixture().Create>(); + var data = new Fixture().Create>(); - return Task.FromResult(Structure1.Api.Tests.Tasks.MyEndpoints.GetTasksResult.Ok(data)); + return Task.FromResult(Generated.Tasks.MyContracts.GetTasksResult.Ok(data)); } } \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/src/Structure1.Api.Generated/Addresses/MyContracts/Results/GetAddressesByPostalCodesResult.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/src/Structure1.Api.Generated/Addresses/MyContracts/Results/GetAddressesByPostalCodesResult.verified.cs index 89f5f0ccf..acf69fc86 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/src/Structure1.Api.Generated/Addresses/MyContracts/Results/GetAddressesByPostalCodesResult.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/src/Structure1.Api.Generated/Addresses/MyContracts/Results/GetAddressesByPostalCodesResult.verified.cs @@ -24,7 +24,7 @@ private GetAddressesByPostalCodesResult(IResult result) /// /// 200 - Ok response. /// - public static GetAddressesByPostalCodesResult Ok(List
result) + public static GetAddressesByPostalCodesResult Ok(IEnumerable
result) => new(TypedResults.Ok(result)); /// diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/src/Structure1.Api.Generated/EventArgs/MyContracts/Results/GetEventArgsResult.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/src/Structure1.Api.Generated/EventArgs/MyContracts/Results/GetEventArgsResult.verified.cs index 6730ef585..984d8b0c0 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/src/Structure1.Api.Generated/EventArgs/MyContracts/Results/GetEventArgsResult.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/src/Structure1.Api.Generated/EventArgs/MyContracts/Results/GetEventArgsResult.verified.cs @@ -24,7 +24,7 @@ private GetEventArgsResult(IResult result) /// /// 200 - Ok response. /// - public static GetEventArgsResult Ok(List result) + public static GetEventArgsResult Ok(IEnumerable result) => new(TypedResults.Ok(result)); /// diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/src/Structure1.Api.Generated/Files/MyContracts/Results/GetFileByIdResult.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/src/Structure1.Api.Generated/Files/MyContracts/Results/GetFileByIdResult.verified.cs index 3c6a7cc14..62cd92fc2 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/src/Structure1.Api.Generated/Files/MyContracts/Results/GetFileByIdResult.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/src/Structure1.Api.Generated/Files/MyContracts/Results/GetFileByIdResult.verified.cs @@ -24,12 +24,18 @@ private GetFileByIdResult(IResult result) /// /// 200 - Ok response. /// - public static GetFileByIdResult Ok(string? message = null) - => new(TypedResults.Ok(message)); + public static GetFileByIdResult Ok(byte[] bytes, string contentType, string fileName) + => new(TypedResults.Bytes(bytes, contentType, fileName)); /// /// 404 - NotFound response. /// public static GetFileByIdResult NotFound(string? message = null) => new(TypedResults.NotFound(message)); + + /// + /// Performs an implicit conversion from GetFileByIdResult to IResult. + /// + public static IResult ToIResult(GetFileByIdResult result) + => result.Result; } \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/src/Structure1.Api.Generated/MyEndpoints/EventArgsEndpointDefinition.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/src/Structure1.Api.Generated/MyEndpoints/EventArgsEndpointDefinition.verified.cs index 2d056c166..2d018a4e4 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/src/Structure1.Api.Generated/MyEndpoints/EventArgsEndpointDefinition.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/src/Structure1.Api.Generated/MyEndpoints/EventArgsEndpointDefinition.verified.cs @@ -26,7 +26,7 @@ public void DefineEndpoints( .WithName("GetEventArgs") .WithSummary("Get EventArgs List.") .WithDescription("Get EventArgs List.") - .Produces>(); + .Produces>(); eventArgs .MapGet("{id}", GetEventArgById) @@ -34,7 +34,7 @@ public void DefineEndpoints( .WithSummary("Get EventArgs By Id.") .WithDescription("Get EventArgs By Id.") .AddEndpointFilter>() - .Produces() + .Produces() .ProducesValidationProblem() .Produces(StatusCodes.Status404NotFound); } diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/src/Structure1.Api.Generated/MyEndpoints/TasksEndpointDefinition.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/src/Structure1.Api.Generated/MyEndpoints/TasksEndpointDefinition.verified.cs index ec754252e..064106e0f 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/src/Structure1.Api.Generated/MyEndpoints/TasksEndpointDefinition.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/src/Structure1.Api.Generated/MyEndpoints/TasksEndpointDefinition.verified.cs @@ -26,7 +26,7 @@ public void DefineEndpoints( .WithName("GetTasks") .WithSummary("Returns tasks.") .WithDescription("Returns tasks.") - .Produces>(); + .Produces>(); } internal async Task GetTasks( diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/src/Structure1.Api.Generated/Tasks/MyContracts/Results/GetTasksResult.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/src/Structure1.Api.Generated/Tasks/MyContracts/Results/GetTasksResult.verified.cs index 28966b69c..a8d973f1f 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/src/Structure1.Api.Generated/Tasks/MyContracts/Results/GetTasksResult.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/src/Structure1.Api.Generated/Tasks/MyContracts/Results/GetTasksResult.verified.cs @@ -24,7 +24,7 @@ private GetTasksResult(IResult result) /// /// 200 - Ok response. /// - public static GetTasksResult Ok(List result) + public static GetTasksResult Ok(IEnumerable result) => new(TypedResults.Ok(result)); /// diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/src/Structure1.Api.Generated/Users/MyContracts/Models/CreateUserRequest.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/src/Structure1.Api.Generated/Users/MyContracts/Models/CreateUserRequest.verified.cs index 9e09a2294..8aec8d7b7 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/src/Structure1.Api.Generated/Users/MyContracts/Models/CreateUserRequest.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/src/Structure1.Api.Generated/Users/MyContracts/Models/CreateUserRequest.verified.cs @@ -19,7 +19,7 @@ public record CreateUserRequest( [property: Uri] Uri Homepage, [property: Required] GenderType Gender, Address? MyNullableAddress, - [property: Required] Object Tags, - Object DesiredProperties1, - Object? DesiredProperties2, - Object? DesiredProperties3); \ No newline at end of file + [property: Required] Dictionary Tags, + Dictionary DesiredProperties1, + Dictionary? DesiredProperties2, + Dictionary? DesiredProperties3); \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/src/Structure1.Api.Generated/Users/MyContracts/Results/GetUsersResult.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/src/Structure1.Api.Generated/Users/MyContracts/Results/GetUsersResult.verified.cs index c1116b1e8..75f8a087a 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/src/Structure1.Api.Generated/Users/MyContracts/Results/GetUsersResult.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/src/Structure1.Api.Generated/Users/MyContracts/Results/GetUsersResult.verified.cs @@ -24,7 +24,7 @@ private GetUsersResult(IResult result) /// /// 200 - Ok response. /// - public static GetUsersResult Ok(List result) + public static GetUsersResult Ok(IEnumerable result) => new(TypedResults.Ok(result)); /// diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/src/Structure1.Api.Generated/Users/MyContracts/Results/PostUserResult.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/src/Structure1.Api.Generated/Users/MyContracts/Results/PostUserResult.verified.cs index 8e6d2e17a..2ebdf9c74 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/src/Structure1.Api.Generated/Users/MyContracts/Results/PostUserResult.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/src/Structure1.Api.Generated/Users/MyContracts/Results/PostUserResult.verified.cs @@ -38,4 +38,10 @@ public static PostUserResult BadRequest(string? message = null, IDictionary public static PostUserResult Conflict(string? message = null) => new(Results.Problem(message, null, StatusCodes.Status409Conflict)); + + /// + /// Performs an implicit conversion from PostUserResult to IResult. + /// + public static IResult ToIResult(PostUserResult result) + => result.Result; } \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/src/Structure1.Api/Extensions/WebApplicationExtensions.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/src/Structure1.Api/Extensions/WebApplicationExtensions.verified.cs index d8c6520fc..c45a50755 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/src/Structure1.Api/Extensions/WebApplicationExtensions.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/src/Structure1.Api/Extensions/WebApplicationExtensions.verified.cs @@ -2,6 +2,7 @@ public static class WebApplicationExtensions { + [SuppressMessage("Spacing Rules", "SA1010:Opening Square Brackets Must Be Spaced Correctly", Justification = "OK.")] private static readonly string[] PatchHttpMethods = ["patch"]; public static RouteHandlerBuilder MapPatch( diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/src/Structure1.Api/Program.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/src/Structure1.Api/Program.verified.cs index 7fc793bb9..ba083ff73 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/src/Structure1.Api/Program.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/src/Structure1.Api/Program.verified.cs @@ -55,7 +55,6 @@ public static void Main(string[] args) app.UseStaticFiles(); - app.UseHttpsRedirection(); app.UseHsts(); diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/src/Structure1.Domain/GlobalUsings.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/src/Structure1.Domain/GlobalUsings.verified.cs index 23a5d0c9f..2f6982cc0 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/src/Structure1.Domain/GlobalUsings.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/src/Structure1.Domain/GlobalUsings.verified.cs @@ -12,4 +12,13 @@ global using Structure1.Api.Generated.Orders.MyContracts; global using Structure1.Api.Generated.RouteWithDash.MyContracts; global using Structure1.Api.Generated.Tasks.MyContracts; -global using Structure1.Api.Generated.Users.MyContracts; \ No newline at end of file +global using Structure1.Api.Generated.Users.MyContracts; +global using Structure1.Domain.Accounts.MyHandlers; +global using Structure1.Domain.Addresses.MyHandlers; +global using Structure1.Domain.EventArgs.MyHandlers; +global using Structure1.Domain.Files.MyHandlers; +global using Structure1.Domain.Items.MyHandlers; +global using Structure1.Domain.Orders.MyHandlers; +global using Structure1.Domain.RouteWithDash.MyHandlers; +global using Structure1.Domain.Tasks.MyHandlers; +global using Structure1.Domain.Users.MyHandlers; \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/test/Structure1.Api.Tests/EventArgs/MyEndpoints/GetEventArgByIdHandlerStub.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/test/Structure1.Api.Tests/EventArgs/MyEndpoints/GetEventArgByIdHandlerStub.verified.cs index 97aa2826a..1fbe070e2 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/test/Structure1.Api.Tests/EventArgs/MyEndpoints/GetEventArgByIdHandlerStub.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/test/Structure1.Api.Tests/EventArgs/MyEndpoints/GetEventArgByIdHandlerStub.verified.cs @@ -13,7 +13,7 @@ public Task ExecuteAsync( GetEventArgByIdParameters parameters, CancellationToken cancellationToken = default) { - var data = new Fixture().Create(); + var data = new Fixture().Create(); return Task.FromResult(GetEventArgByIdResult.Ok(data)); } diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/test/Structure1.Api.Tests/EventArgs/MyEndpoints/GetEventArgsHandlerStub.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/test/Structure1.Api.Tests/EventArgs/MyEndpoints/GetEventArgsHandlerStub.verified.cs index 449d26600..01f3ae10b 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/test/Structure1.Api.Tests/EventArgs/MyEndpoints/GetEventArgsHandlerStub.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/test/Structure1.Api.Tests/EventArgs/MyEndpoints/GetEventArgsHandlerStub.verified.cs @@ -12,7 +12,7 @@ public class GetEventArgsHandlerStub : IGetEventArgsHandler public Task ExecuteAsync( CancellationToken cancellationToken = default) { - var data = new Fixture().Create>(); + var data = new Fixture().Create>(); return Task.FromResult(GetEventArgsResult.Ok(data)); } diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/test/Structure1.Api.Tests/Files/MyEndpoints/GetFileByIdHandlerStub.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/test/Structure1.Api.Tests/Files/MyEndpoints/GetFileByIdHandlerStub.verified.cs index 0246fcdd9..b34bdafe6 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/test/Structure1.Api.Tests/Files/MyEndpoints/GetFileByIdHandlerStub.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/test/Structure1.Api.Tests/Files/MyEndpoints/GetFileByIdHandlerStub.verified.cs @@ -14,6 +14,6 @@ public Task ExecuteAsync( CancellationToken cancellationToken = default) { var bytes = Encoding.UTF8.GetBytes("Hello World"); - return Task.FromResult(GetFileByIdResult.Ok(bytes, "dummy.txt")); + return Task.FromResult(GetFileByIdResult.Ok(bytes, "text/plain", "dummy.txt")); } } \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/test/Structure1.Api.Tests/GlobalUsings.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/test/Structure1.Api.Tests/GlobalUsings.verified.cs index d88aa660e..42f6f6f85 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/test/Structure1.Api.Tests/GlobalUsings.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/test/Structure1.Api.Tests/GlobalUsings.verified.cs @@ -1,21 +1,10 @@ global using System.CodeDom.Compiler; -global using System.Reflection; global using System.Text; -global using System.Text.Json; -global using System.Text.Json.Serialization; -global using Atc.Rest.Options; global using Atc.Rest.Results; -global using Atc.XUnit; global using AutoFixture; -global using Microsoft.AspNetCore.Hosting; -global using Microsoft.AspNetCore.Http; -global using Microsoft.Extensions.Configuration; -global using Microsoft.Extensions.DependencyInjection; - -global using Structure1.Api.Generated; global using Structure1.Api.Generated.Accounts.MyContracts; global using Structure1.Api.Generated.Addresses.MyContracts; global using Structure1.Api.Generated.EventArgs.MyContracts; @@ -24,6 +13,4 @@ global using Structure1.Api.Generated.MyContracts; global using Structure1.Api.Generated.Orders.MyContracts; global using Structure1.Api.Generated.RouteWithDash.MyContracts; -global using Structure1.Api.Generated.Users.MyContracts; - -global using Xunit; \ No newline at end of file +global using Structure1.Api.Generated.Users.MyContracts; \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/test/Structure1.Api.Tests/Tasks/MyEndpoints/GetTasksHandlerStub.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/test/Structure1.Api.Tests/Tasks/MyEndpoints/GetTasksHandlerStub.verified.cs index b03679c27..9a12a82f7 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/test/Structure1.Api.Tests/Tasks/MyEndpoints/GetTasksHandlerStub.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/MinimalApi_WPD/test/Structure1.Api.Tests/Tasks/MyEndpoints/GetTasksHandlerStub.verified.cs @@ -7,13 +7,13 @@ namespace Structure1.Api.Tests.Tasks.MyEndpoints; [GeneratedCode("ApiGenerator", "x.x.x.x")] -public class GetTasksHandlerStub : Structure1.Api.Tests.Tasks.MyEndpoints.IGetTasksHandler +public class GetTasksHandlerStub : Generated.Tasks.MyContracts.IGetTasksHandler { - public Task ExecuteAsync( + public Task ExecuteAsync( CancellationToken cancellationToken = default) { - var data = new Fixture().Create>(); + var data = new Fixture().Create>(); - return Task.FromResult(Structure1.Api.Tests.Tasks.MyEndpoints.GetTasksResult.Ok(data)); + return Task.FromResult(Generated.Tasks.MyContracts.GetTasksResult.Ok(data)); } } \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/Mvc_WOPD/src/Structure1.Api.Generated/Files/MyContracts/Results/GetFileByIdResult.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/Mvc_WOPD/src/Structure1.Api.Generated/Files/MyContracts/Results/GetFileByIdResult.verified.cs index 6d5e1b715..936fe076e 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/Mvc_WOPD/src/Structure1.Api.Generated/Files/MyContracts/Results/GetFileByIdResult.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/Mvc_WOPD/src/Structure1.Api.Generated/Files/MyContracts/Results/GetFileByIdResult.verified.cs @@ -19,8 +19,8 @@ private GetFileByIdResult(ActionResult result) : base(result) { } /// /// 200 - Ok response. /// - public static GetFileByIdResult Ok(byte[] bytes, string fileName) - => new GetFileByIdResult(ResultFactory.CreateFileContentResult(bytes, fileName)); + public static GetFileByIdResult Ok(byte[] bytes, string contentType, string fileName) + => new GetFileByIdResult(ResultFactory.CreateFileContentResult(bytes, fileName, contentType)); /// /// 404 - NotFound response. diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/Mvc_WOPD/src/Structure1.Api.Generated/MyEndpoints/EventArgsController.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/Mvc_WOPD/src/Structure1.Api.Generated/MyEndpoints/EventArgsController.verified.cs index 1db8993d0..6ca0fee19 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/Mvc_WOPD/src/Structure1.Api.Generated/MyEndpoints/EventArgsController.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/Mvc_WOPD/src/Structure1.Api.Generated/MyEndpoints/EventArgsController.verified.cs @@ -19,7 +19,7 @@ public sealed class EventArgsController : ControllerBase /// Operation: GetEventArgs. /// [HttpGet] - [ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK)] + [ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK)] public async Task GetEventArgs( [FromServices] IGetEventArgsHandler handler, CancellationToken cancellationToken) @@ -30,7 +30,7 @@ public async Task GetEventArgs( /// Operation: GetEventArgById. /// [HttpGet("{id}")] - [ProducesResponseType(typeof(Contracts.EventArgs.EventArgs), StatusCodes.Status200OK)] + [ProducesResponseType(typeof(EventArgs.MyContracts.EventArgs), StatusCodes.Status200OK)] [ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)] [ProducesResponseType(typeof(string), StatusCodes.Status404NotFound)] public async Task GetEventArgById( diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/Mvc_WOPD/src/Structure1.Api.Generated/MyEndpoints/TasksController.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/Mvc_WOPD/src/Structure1.Api.Generated/MyEndpoints/TasksController.verified.cs index 0c6b92783..9f4338626 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/Mvc_WOPD/src/Structure1.Api.Generated/MyEndpoints/TasksController.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/Mvc_WOPD/src/Structure1.Api.Generated/MyEndpoints/TasksController.verified.cs @@ -19,7 +19,7 @@ public sealed class TasksController : ControllerBase /// Operation: GetTasks. /// [HttpGet] - [ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK)] + [ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK)] public async Task GetTasks( [FromServices] IGetTasksHandler handler, CancellationToken cancellationToken) diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/Mvc_WOPD/test/Structure1.Api.Tests/EventArgs/MyEndpoints/GetEventArgByIdHandlerStub.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/Mvc_WOPD/test/Structure1.Api.Tests/EventArgs/MyEndpoints/GetEventArgByIdHandlerStub.verified.cs index 97aa2826a..1fbe070e2 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/Mvc_WOPD/test/Structure1.Api.Tests/EventArgs/MyEndpoints/GetEventArgByIdHandlerStub.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/Mvc_WOPD/test/Structure1.Api.Tests/EventArgs/MyEndpoints/GetEventArgByIdHandlerStub.verified.cs @@ -13,7 +13,7 @@ public Task ExecuteAsync( GetEventArgByIdParameters parameters, CancellationToken cancellationToken = default) { - var data = new Fixture().Create(); + var data = new Fixture().Create(); return Task.FromResult(GetEventArgByIdResult.Ok(data)); } diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/Mvc_WOPD/test/Structure1.Api.Tests/EventArgs/MyEndpoints/GetEventArgsHandlerStub.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/Mvc_WOPD/test/Structure1.Api.Tests/EventArgs/MyEndpoints/GetEventArgsHandlerStub.verified.cs index 449d26600..01f3ae10b 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/Mvc_WOPD/test/Structure1.Api.Tests/EventArgs/MyEndpoints/GetEventArgsHandlerStub.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/Mvc_WOPD/test/Structure1.Api.Tests/EventArgs/MyEndpoints/GetEventArgsHandlerStub.verified.cs @@ -12,7 +12,7 @@ public class GetEventArgsHandlerStub : IGetEventArgsHandler public Task ExecuteAsync( CancellationToken cancellationToken = default) { - var data = new Fixture().Create>(); + var data = new Fixture().Create>(); return Task.FromResult(GetEventArgsResult.Ok(data)); } diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/Mvc_WOPD/test/Structure1.Api.Tests/Files/MyEndpoints/GetFileByIdHandlerStub.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/Mvc_WOPD/test/Structure1.Api.Tests/Files/MyEndpoints/GetFileByIdHandlerStub.verified.cs index 0246fcdd9..b34bdafe6 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/Mvc_WOPD/test/Structure1.Api.Tests/Files/MyEndpoints/GetFileByIdHandlerStub.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/Mvc_WOPD/test/Structure1.Api.Tests/Files/MyEndpoints/GetFileByIdHandlerStub.verified.cs @@ -14,6 +14,6 @@ public Task ExecuteAsync( CancellationToken cancellationToken = default) { var bytes = Encoding.UTF8.GetBytes("Hello World"); - return Task.FromResult(GetFileByIdResult.Ok(bytes, "dummy.txt")); + return Task.FromResult(GetFileByIdResult.Ok(bytes, "text/plain", "dummy.txt")); } } \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/Mvc_WOPD/test/Structure1.Api.Tests/Tasks/MyEndpoints/GetTasksHandlerStub.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/Mvc_WOPD/test/Structure1.Api.Tests/Tasks/MyEndpoints/GetTasksHandlerStub.verified.cs index b03679c27..9a12a82f7 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/Mvc_WOPD/test/Structure1.Api.Tests/Tasks/MyEndpoints/GetTasksHandlerStub.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/Mvc_WOPD/test/Structure1.Api.Tests/Tasks/MyEndpoints/GetTasksHandlerStub.verified.cs @@ -7,13 +7,13 @@ namespace Structure1.Api.Tests.Tasks.MyEndpoints; [GeneratedCode("ApiGenerator", "x.x.x.x")] -public class GetTasksHandlerStub : Structure1.Api.Tests.Tasks.MyEndpoints.IGetTasksHandler +public class GetTasksHandlerStub : Generated.Tasks.MyContracts.IGetTasksHandler { - public Task ExecuteAsync( + public Task ExecuteAsync( CancellationToken cancellationToken = default) { - var data = new Fixture().Create>(); + var data = new Fixture().Create>(); - return Task.FromResult(Structure1.Api.Tests.Tasks.MyEndpoints.GetTasksResult.Ok(data)); + return Task.FromResult(Generated.Tasks.MyContracts.GetTasksResult.Ok(data)); } } \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/Mvc_WPD/src/Structure1.Api.Generated/Files/MyContracts/Results/GetFileByIdResult.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/Mvc_WPD/src/Structure1.Api.Generated/Files/MyContracts/Results/GetFileByIdResult.verified.cs index 6d5e1b715..936fe076e 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/Mvc_WPD/src/Structure1.Api.Generated/Files/MyContracts/Results/GetFileByIdResult.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/Mvc_WPD/src/Structure1.Api.Generated/Files/MyContracts/Results/GetFileByIdResult.verified.cs @@ -19,8 +19,8 @@ private GetFileByIdResult(ActionResult result) : base(result) { } /// /// 200 - Ok response. /// - public static GetFileByIdResult Ok(byte[] bytes, string fileName) - => new GetFileByIdResult(ResultFactory.CreateFileContentResult(bytes, fileName)); + public static GetFileByIdResult Ok(byte[] bytes, string contentType, string fileName) + => new GetFileByIdResult(ResultFactory.CreateFileContentResult(bytes, fileName, contentType)); /// /// 404 - NotFound response. diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/Mvc_WPD/src/Structure1.Api.Generated/MyEndpoints/EventArgsController.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/Mvc_WPD/src/Structure1.Api.Generated/MyEndpoints/EventArgsController.verified.cs index 1db8993d0..6ca0fee19 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/Mvc_WPD/src/Structure1.Api.Generated/MyEndpoints/EventArgsController.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/Mvc_WPD/src/Structure1.Api.Generated/MyEndpoints/EventArgsController.verified.cs @@ -19,7 +19,7 @@ public sealed class EventArgsController : ControllerBase /// Operation: GetEventArgs. /// [HttpGet] - [ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK)] + [ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK)] public async Task GetEventArgs( [FromServices] IGetEventArgsHandler handler, CancellationToken cancellationToken) @@ -30,7 +30,7 @@ public async Task GetEventArgs( /// Operation: GetEventArgById. /// [HttpGet("{id}")] - [ProducesResponseType(typeof(Contracts.EventArgs.EventArgs), StatusCodes.Status200OK)] + [ProducesResponseType(typeof(EventArgs.MyContracts.EventArgs), StatusCodes.Status200OK)] [ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)] [ProducesResponseType(typeof(string), StatusCodes.Status404NotFound)] public async Task GetEventArgById( diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/Mvc_WPD/src/Structure1.Api.Generated/MyEndpoints/TasksController.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/Mvc_WPD/src/Structure1.Api.Generated/MyEndpoints/TasksController.verified.cs index 0c6b92783..9f4338626 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/Mvc_WPD/src/Structure1.Api.Generated/MyEndpoints/TasksController.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/Mvc_WPD/src/Structure1.Api.Generated/MyEndpoints/TasksController.verified.cs @@ -19,7 +19,7 @@ public sealed class TasksController : ControllerBase /// Operation: GetTasks. /// [HttpGet] - [ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK)] + [ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK)] public async Task GetTasks( [FromServices] IGetTasksHandler handler, CancellationToken cancellationToken) diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/Mvc_WPD/test/Structure1.Api.Tests/EventArgs/MyEndpoints/GetEventArgByIdHandlerStub.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/Mvc_WPD/test/Structure1.Api.Tests/EventArgs/MyEndpoints/GetEventArgByIdHandlerStub.verified.cs index 97aa2826a..1fbe070e2 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/Mvc_WPD/test/Structure1.Api.Tests/EventArgs/MyEndpoints/GetEventArgByIdHandlerStub.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/Mvc_WPD/test/Structure1.Api.Tests/EventArgs/MyEndpoints/GetEventArgByIdHandlerStub.verified.cs @@ -13,7 +13,7 @@ public Task ExecuteAsync( GetEventArgByIdParameters parameters, CancellationToken cancellationToken = default) { - var data = new Fixture().Create(); + var data = new Fixture().Create(); return Task.FromResult(GetEventArgByIdResult.Ok(data)); } diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/Mvc_WPD/test/Structure1.Api.Tests/EventArgs/MyEndpoints/GetEventArgsHandlerStub.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/Mvc_WPD/test/Structure1.Api.Tests/EventArgs/MyEndpoints/GetEventArgsHandlerStub.verified.cs index 449d26600..01f3ae10b 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/Mvc_WPD/test/Structure1.Api.Tests/EventArgs/MyEndpoints/GetEventArgsHandlerStub.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/Mvc_WPD/test/Structure1.Api.Tests/EventArgs/MyEndpoints/GetEventArgsHandlerStub.verified.cs @@ -12,7 +12,7 @@ public class GetEventArgsHandlerStub : IGetEventArgsHandler public Task ExecuteAsync( CancellationToken cancellationToken = default) { - var data = new Fixture().Create>(); + var data = new Fixture().Create>(); return Task.FromResult(GetEventArgsResult.Ok(data)); } diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/Mvc_WPD/test/Structure1.Api.Tests/Files/MyEndpoints/GetFileByIdHandlerStub.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/Mvc_WPD/test/Structure1.Api.Tests/Files/MyEndpoints/GetFileByIdHandlerStub.verified.cs index 0246fcdd9..b34bdafe6 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/Mvc_WPD/test/Structure1.Api.Tests/Files/MyEndpoints/GetFileByIdHandlerStub.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/Mvc_WPD/test/Structure1.Api.Tests/Files/MyEndpoints/GetFileByIdHandlerStub.verified.cs @@ -14,6 +14,6 @@ public Task ExecuteAsync( CancellationToken cancellationToken = default) { var bytes = Encoding.UTF8.GetBytes("Hello World"); - return Task.FromResult(GetFileByIdResult.Ok(bytes, "dummy.txt")); + return Task.FromResult(GetFileByIdResult.Ok(bytes, "text/plain", "dummy.txt")); } } \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/Mvc_WPD/test/Structure1.Api.Tests/Tasks/MyEndpoints/GetTasksHandlerStub.verified.cs b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/Mvc_WPD/test/Structure1.Api.Tests/Tasks/MyEndpoints/GetTasksHandlerStub.verified.cs index b03679c27..9a12a82f7 100644 --- a/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/Mvc_WPD/test/Structure1.Api.Tests/Tasks/MyEndpoints/GetTasksHandlerStub.verified.cs +++ b/test/Atc.Rest.ApiGenerator.CLI.Tests/Scenarios/Structure1/VerifyServerAll/Mvc_WPD/test/Structure1.Api.Tests/Tasks/MyEndpoints/GetTasksHandlerStub.verified.cs @@ -7,13 +7,13 @@ namespace Structure1.Api.Tests.Tasks.MyEndpoints; [GeneratedCode("ApiGenerator", "x.x.x.x")] -public class GetTasksHandlerStub : Structure1.Api.Tests.Tasks.MyEndpoints.IGetTasksHandler +public class GetTasksHandlerStub : Generated.Tasks.MyContracts.IGetTasksHandler { - public Task ExecuteAsync( + public Task ExecuteAsync( CancellationToken cancellationToken = default) { - var data = new Fixture().Create>(); + var data = new Fixture().Create>(); - return Task.FromResult(Structure1.Api.Tests.Tasks.MyEndpoints.GetTasksResult.Ok(data)); + return Task.FromResult(Generated.Tasks.MyContracts.GetTasksResult.Ok(data)); } } \ No newline at end of file diff --git a/test/Atc.Rest.ApiGenerator.Contracts.Tests/Atc.Rest.ApiGenerator.Contracts.Tests.csproj b/test/Atc.Rest.ApiGenerator.Contracts.Tests/Atc.Rest.ApiGenerator.Contracts.Tests.csproj index f95fd3dc1..e372a14ab 100644 --- a/test/Atc.Rest.ApiGenerator.Contracts.Tests/Atc.Rest.ApiGenerator.Contracts.Tests.csproj +++ b/test/Atc.Rest.ApiGenerator.Contracts.Tests/Atc.Rest.ApiGenerator.Contracts.Tests.csproj @@ -1,18 +1,18 @@ - net8.0 + net9.0 false - - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/test/Atc.Rest.ApiGenerator.Framework.Mvc.Tests/Atc.Rest.ApiGenerator.Framework.Mvc.Tests.csproj b/test/Atc.Rest.ApiGenerator.Framework.Mvc.Tests/Atc.Rest.ApiGenerator.Framework.Mvc.Tests.csproj index ae98b1681..15b4084e6 100644 --- a/test/Atc.Rest.ApiGenerator.Framework.Mvc.Tests/Atc.Rest.ApiGenerator.Framework.Mvc.Tests.csproj +++ b/test/Atc.Rest.ApiGenerator.Framework.Mvc.Tests/Atc.Rest.ApiGenerator.Framework.Mvc.Tests.csproj @@ -1,19 +1,19 @@ - net8.0 + net9.0 false CA1014 - - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/test/Atc.Rest.ApiGenerator.Framework.Tests/Atc.Rest.ApiGenerator.Framework.Tests.csproj b/test/Atc.Rest.ApiGenerator.Framework.Tests/Atc.Rest.ApiGenerator.Framework.Tests.csproj index 9184a1fe1..2218d6231 100644 --- a/test/Atc.Rest.ApiGenerator.Framework.Tests/Atc.Rest.ApiGenerator.Framework.Tests.csproj +++ b/test/Atc.Rest.ApiGenerator.Framework.Tests/Atc.Rest.ApiGenerator.Framework.Tests.csproj @@ -1,19 +1,19 @@ - net8.0 + net9.0 false - - - - + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/test/Atc.Rest.ApiGenerator.Nuget.Tests/Atc.Rest.ApiGenerator.Nuget.Tests.csproj b/test/Atc.Rest.ApiGenerator.Nuget.Tests/Atc.Rest.ApiGenerator.Nuget.Tests.csproj index 50c1928a2..7557e0153 100644 --- a/test/Atc.Rest.ApiGenerator.Nuget.Tests/Atc.Rest.ApiGenerator.Nuget.Tests.csproj +++ b/test/Atc.Rest.ApiGenerator.Nuget.Tests/Atc.Rest.ApiGenerator.Nuget.Tests.csproj @@ -1,19 +1,19 @@ - net8.0 + net9.0 false - - - - + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/test/Atc.Rest.ApiGenerator.OpenApi.Tests/Atc.Rest.ApiGenerator.OpenApi.Tests.csproj b/test/Atc.Rest.ApiGenerator.OpenApi.Tests/Atc.Rest.ApiGenerator.OpenApi.Tests.csproj index 9c420da6a..0228a0972 100644 --- a/test/Atc.Rest.ApiGenerator.OpenApi.Tests/Atc.Rest.ApiGenerator.OpenApi.Tests.csproj +++ b/test/Atc.Rest.ApiGenerator.OpenApi.Tests/Atc.Rest.ApiGenerator.OpenApi.Tests.csproj @@ -1,18 +1,18 @@ - net8.0 + net9.0 false - - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/test/Directory.Build.props b/test/Directory.Build.props index 31909604c..60c2f1ab7 100644 --- a/test/Directory.Build.props +++ b/test/Directory.Build.props @@ -11,7 +11,7 @@ - +