diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a1242d0e58..37dead028a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -40,10 +40,10 @@ jobs: run: | echo "Adding GNU tar to PATH" echo C:\Program Files\Git\usr\bin>>"%GITHUB_PATH%" - - uses: actions/setup-dotnet@v3 + - uses: actions/setup-dotnet@v4 with: dotnet-version: | - 6.0.423 + 6.0 - uses: actions/checkout@v3 - name: 'Run: Compile, Test, Pack, Publish' run: ./build.cmd Compile Test Pack Publish @@ -76,10 +76,10 @@ jobs: name: ubuntu-latest runs-on: ubuntu-latest steps: - - uses: actions/setup-dotnet@v3 + - uses: actions/setup-dotnet@v4 with: dotnet-version: | - 6.0.423 + 6.0 - uses: actions/checkout@v3 - name: 'Run: Compile, Test, Pack, Publish' run: ./build.cmd Compile Test Pack Publish @@ -92,10 +92,10 @@ jobs: name: macos-latest runs-on: macos-latest steps: - - uses: actions/setup-dotnet@v3 + - uses: actions/setup-dotnet@v4 with: dotnet-version: | - 6.0.423 + 6.0 - uses: actions/checkout@v3 - name: 'Run: Compile, Test, Pack, Publish' run: ./build.cmd Compile Test Pack Publish diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 6198fa53bc..e0c1805f53 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -38,10 +38,10 @@ jobs: run: | echo "Adding GNU tar to PATH" echo C:\Program Files\Git\usr\bin>>"%GITHUB_PATH%" - - uses: actions/setup-dotnet@v3 + - uses: actions/setup-dotnet@v4 with: dotnet-version: | - 6.0.423 + 6.0 - uses: actions/checkout@v3 - name: 'Run: Compile, Test, Pack' run: ./build.cmd Compile Test Pack @@ -69,10 +69,10 @@ jobs: name: ubuntu-latest runs-on: ubuntu-latest steps: - - uses: actions/setup-dotnet@v3 + - uses: actions/setup-dotnet@v4 with: dotnet-version: | - 6.0.423 + 6.0 - uses: actions/checkout@v3 - name: 'Run: Compile, Test, Pack' run: ./build.cmd Compile Test Pack @@ -80,10 +80,10 @@ jobs: name: macos-latest runs-on: macos-latest steps: - - uses: actions/setup-dotnet@v3 + - uses: actions/setup-dotnet@v4 with: dotnet-version: | - 6.0.423 + 6.0 - uses: actions/checkout@v3 - name: 'Run: Compile, Test, Pack' run: ./build.cmd Compile Test Pack diff --git a/build/Build.CI.GitHubActions.cs b/build/Build.CI.GitHubActions.cs index 58ed828945..bbf5ea69d1 100644 --- a/build/Build.CI.GitHubActions.cs +++ b/build/Build.CI.GitHubActions.cs @@ -49,10 +49,7 @@ protected override GitHubActionsJob GetJobs(GitHubActionsImage image, IReadOnlyC var newSteps = new List(job.Steps); // only need to list the ones that are missing from default image - newSteps.Insert(0, new GitHubActionsSetupDotNetStep(new[] - { - "6.0.423" - })); + newSteps.Insert(0, new GitHubActionsSetupDotNetStep(["6.0"])); var onWindows = image.ToString().StartsWith("windows", StringComparison.OrdinalIgnoreCase); if (onWindows) @@ -98,7 +95,7 @@ public GitHubActionsSetupDotNetStep(string[] versions) public override void Write(CustomFileWriter writer) { - writer.WriteLine("- uses: actions/setup-dotnet@v3"); + writer.WriteLine("- uses: actions/setup-dotnet@v4"); using (writer.Indent()) { diff --git a/build/Build.cs b/build/Build.cs index fe6a754028..7e42cbdb7c 100644 --- a/build/Build.cs +++ b/build/Build.cs @@ -268,7 +268,7 @@ void PublishConsoleProject(Project project, string[] targetFrameworks) PublishConsoleProject(consoleX86Project, ["net462"]); PublishConsoleProject(consoleProject, ["net462"]); } - PublishConsoleProject(consoleCoreProject, ["net6.0", "net7.0", "net8.0"]); + PublishConsoleProject(consoleCoreProject, ["net6.0", "net8.0"]); void CopyConsoleBinaries(AbsolutePath target) { @@ -285,7 +285,6 @@ void CopyConsoleBinaries(AbsolutePath target) } CopyDirectoryRecursively(ArtifactsDirectory / "publish" / consoleCoreProject.Name / (configuration + "_net6.0"), target / "Net60"); - CopyDirectoryRecursively(ArtifactsDirectory / "publish" / consoleCoreProject.Name / (configuration + "_net7.0"), target / "Net70"); CopyDirectoryRecursively(ArtifactsDirectory / "publish" / consoleCoreProject.Name / (configuration + "_net8.0"), target / "Net80"); } diff --git a/src/NSwag.ApiDescription.Client/NSwag.ApiDescription.Client.targets b/src/NSwag.ApiDescription.Client/NSwag.ApiDescription.Client.targets index fdeea20bf5..662b846518 100644 --- a/src/NSwag.ApiDescription.Client/NSwag.ApiDescription.Client.targets +++ b/src/NSwag.ApiDescription.Client/NSwag.ApiDescription.Client.targets @@ -4,8 +4,6 @@ <_NSwagCommand>$(NSwagExe) <_NSwagCommand Condition="'$(MSBuildRuntimeType)' == 'Core'">dotnet --roll-forward-on-no-candidate-fx 2 "$(NSwagDir_Net60)/dotnet-nswag.dll" - <_NSwagCommand - Condition="'$(TargetFramework)' == 'net7.0'">dotnet --roll-forward-on-no-candidate-fx 2 "$(NSwagDir_Net70)/dotnet-nswag.dll" <_NSwagCommand Condition="'$(TargetFramework)' == 'net8.0'">dotnet --roll-forward-on-no-candidate-fx 2 "$(NSwagDir_Net80)/dotnet-nswag.dll" diff --git a/src/NSwag.AspNetCore/NSwag.AspNetCore.csproj b/src/NSwag.AspNetCore/NSwag.AspNetCore.csproj index 576eba1e67..b89c21a616 100644 --- a/src/NSwag.AspNetCore/NSwag.AspNetCore.csproj +++ b/src/NSwag.AspNetCore/NSwag.AspNetCore.csproj @@ -1,6 +1,6 @@  - net462;netstandard2.0;net6.0;net7.0;net8.0 + net462;netstandard2.0;net6.0;net8.0 Swagger Documentation AspNetCore NetCore TypeScript CodeGen $(MSBuildProjectName).nuspec symbols.nupkg @@ -47,11 +47,6 @@ - - - - - diff --git a/src/NSwag.AspNetCore/NSwag.AspNetCore.nuspec b/src/NSwag.AspNetCore/NSwag.AspNetCore.nuspec index c203394d1a..e43c66929c 100644 --- a/src/NSwag.AspNetCore/NSwag.AspNetCore.nuspec +++ b/src/NSwag.AspNetCore/NSwag.AspNetCore.nuspec @@ -46,15 +46,6 @@ - - - - - - - - - @@ -76,8 +67,6 @@ - - diff --git a/src/NSwag.Commands/NSwag.Commands.csproj b/src/NSwag.Commands/NSwag.Commands.csproj index 89b0e5430b..e078f8778f 100644 --- a/src/NSwag.Commands/NSwag.Commands.csproj +++ b/src/NSwag.Commands/NSwag.Commands.csproj @@ -1,7 +1,7 @@  - net462;net6.0;net7.0;net8.0 + net462;net6.0;net8.0 true $(NoWarn),618,1591 @@ -17,12 +17,6 @@ - - - - - - diff --git a/src/NSwag.Commands/NSwagDocument.cs b/src/NSwag.Commands/NSwagDocument.cs index fb4450afe8..7bd11df052 100644 --- a/src/NSwag.Commands/NSwagDocument.cs +++ b/src/NSwag.Commands/NSwagDocument.cs @@ -243,10 +243,6 @@ private string GetArgumentsPrefix() { return "\"" + System.IO.Path.Combine(RootBinaryDirectory, "Net60/dotnet-nswag.dll") + "\" "; } - else if (runtime == Runtime.Net70) - { - return "\"" + System.IO.Path.Combine(RootBinaryDirectory, "Net70/dotnet-nswag.dll") + "\" "; - } else if (runtime == Runtime.Net80) { return "\"" + System.IO.Path.Combine(RootBinaryDirectory, "Net80/dotnet-nswag.dll") + "\" "; diff --git a/src/NSwag.Commands/Runtime.cs b/src/NSwag.Commands/Runtime.cs index 1b2a9ed712..4e4a1f11ea 100644 --- a/src/NSwag.Commands/Runtime.cs +++ b/src/NSwag.Commands/Runtime.cs @@ -23,9 +23,6 @@ public enum Runtime /// .NET 6 app. Net60, - /// .NET 7 app. - Net70, - /// .NET 8 app. Net80, diff --git a/src/NSwag.Commands/RuntimeUtilities.cs b/src/NSwag.Commands/RuntimeUtilities.cs index 6659157246..92cbea8ecf 100644 --- a/src/NSwag.Commands/RuntimeUtilities.cs +++ b/src/NSwag.Commands/RuntimeUtilities.cs @@ -31,11 +31,6 @@ public static Runtime CurrentRuntime { return Runtime.Net80; } - - if (framework.Version.Major >= 7) - { - return Runtime.Net70; - } if (framework.Version.Major >= 6) { diff --git a/src/NSwag.ConsoleCore.Tests/GenerateSampleSpecificationTests.cs b/src/NSwag.ConsoleCore.Tests/GenerateSampleSpecificationTests.cs index f9db6bf172..41ca3a3d5f 100644 --- a/src/NSwag.ConsoleCore.Tests/GenerateSampleSpecificationTests.cs +++ b/src/NSwag.ConsoleCore.Tests/GenerateSampleSpecificationTests.cs @@ -12,8 +12,6 @@ public class GenerateSampleSpecificationTests [Theory] [InlineData("NSwag.Sample.NET60", "net6.0", false)] [InlineData("NSwag.Sample.NET60Minimal", "net6.0", false)] - [InlineData("NSwag.Sample.NET70", "net7.0", false)] - [InlineData("NSwag.Sample.NET70Minimal", "net7.0", true)] [InlineData("NSwag.Sample.NET80", "net8.0", false)] [InlineData("NSwag.Sample.NET80Minimal", "net8.0", true)] public async Task Should_generate_openapi_for_project(string projectName, string targetFramework, bool generatesCode) diff --git a/src/NSwag.ConsoleCore.Tests/NSwag.ConsoleCore.Tests.csproj b/src/NSwag.ConsoleCore.Tests/NSwag.ConsoleCore.Tests.csproj index 3f5a54312a..08ae2a5048 100644 --- a/src/NSwag.ConsoleCore.Tests/NSwag.ConsoleCore.Tests.csproj +++ b/src/NSwag.ConsoleCore.Tests/NSwag.ConsoleCore.Tests.csproj @@ -12,7 +12,8 @@ - + + diff --git a/src/NSwag.ConsoleCore/NSwag.ConsoleCore.csproj b/src/NSwag.ConsoleCore/NSwag.ConsoleCore.csproj index 211d6fd69b..2b08cb1eab 100644 --- a/src/NSwag.ConsoleCore/NSwag.ConsoleCore.csproj +++ b/src/NSwag.ConsoleCore/NSwag.ConsoleCore.csproj @@ -1,6 +1,6 @@  - net6.0;net7.0;net8.0 + net6.0;net8.0 Exe dotnet-nswag NSwag.ConsoleCore @@ -18,11 +18,6 @@ - - - - - diff --git a/src/NSwag.Generation.AspNetCore.Tests.Web/NSwag.Generation.AspNetCore.Tests.Web.csproj b/src/NSwag.Generation.AspNetCore.Tests.Web/NSwag.Generation.AspNetCore.Tests.Web.csproj index 44a8384265..d0e8b4d6bf 100644 --- a/src/NSwag.Generation.AspNetCore.Tests.Web/NSwag.Generation.AspNetCore.Tests.Web.csproj +++ b/src/NSwag.Generation.AspNetCore.Tests.Web/NSwag.Generation.AspNetCore.Tests.Web.csproj @@ -1,7 +1,7 @@  - net6.0;net7.0;net8.0 + net6.0;net8.0 true $(NoWarn),618,1591 enable diff --git a/src/NSwag.Generation.AspNetCore.Tests/NSwag.Generation.AspNetCore.Tests.csproj b/src/NSwag.Generation.AspNetCore.Tests/NSwag.Generation.AspNetCore.Tests.csproj index d3483b7f8e..8cf183c810 100644 --- a/src/NSwag.Generation.AspNetCore.Tests/NSwag.Generation.AspNetCore.Tests.csproj +++ b/src/NSwag.Generation.AspNetCore.Tests/NSwag.Generation.AspNetCore.Tests.csproj @@ -1,6 +1,6 @@  - net6.0;net7.0;net8.0 + net6.0;net8.0 $(NoWarn),618,1591 true @@ -16,14 +16,9 @@ - - - - - - + diff --git a/src/NSwag.Generation.AspNetCore/NSwag.Generation.AspNetCore.csproj b/src/NSwag.Generation.AspNetCore/NSwag.Generation.AspNetCore.csproj index 464b0a0e09..bceac8d52c 100644 --- a/src/NSwag.Generation.AspNetCore/NSwag.Generation.AspNetCore.csproj +++ b/src/NSwag.Generation.AspNetCore/NSwag.Generation.AspNetCore.csproj @@ -1,6 +1,6 @@ - net462;netstandard2.0;net6.0;net7.0;net8.0 + net462;netstandard2.0;net6.0;net8.0 Swagger Documentation AspNetCore $(DefineConstants);ASPNETCORE true @@ -18,12 +18,6 @@ - - - - - - diff --git a/src/NSwag.MSBuild/NSwag.MSBuild.nuspec b/src/NSwag.MSBuild/NSwag.MSBuild.nuspec index c97a281369..b438e64b3d 100644 --- a/src/NSwag.MSBuild/NSwag.MSBuild.nuspec +++ b/src/NSwag.MSBuild/NSwag.MSBuild.nuspec @@ -29,7 +29,6 @@ - diff --git a/src/NSwag.MSBuild/NSwag.MSBuild.props b/src/NSwag.MSBuild/NSwag.MSBuild.props index b70ce45bef..20efc1c697 100644 --- a/src/NSwag.MSBuild/NSwag.MSBuild.props +++ b/src/NSwag.MSBuild/NSwag.MSBuild.props @@ -4,12 +4,10 @@ "$(MSBuildThisFileDirectory)../tools/Win/NSwag.exe" "$(MSBuildThisFileDirectory)../tools/Win/NSwag.x86.exe" dotnet "$(MSBuildThisFileDirectory)../tools/Net60/dotnet-nswag.dll" - dotnet "$(MSBuildThisFileDirectory)../tools/Net70/dotnet-nswag.dll" dotnet "$(MSBuildThisFileDirectory)../tools/Net80/dotnet-nswag.dll" $(MSBuildThisFileDirectory)../tools/Win/ $(MSBuildThisFileDirectory)../tools/Net60/ - $(MSBuildThisFileDirectory)../tools/Net70/ $(MSBuildThisFileDirectory)../tools/Net80/ diff --git a/src/NSwag.NoInstaller.slnf b/src/NSwag.NoInstaller.slnf index 04cf6b380d..22d6de4ff5 100644 --- a/src/NSwag.NoInstaller.slnf +++ b/src/NSwag.NoInstaller.slnf @@ -32,8 +32,6 @@ "NSwag.Generation\\NSwag.Generation.csproj", "NSwag.Sample.NET60Minimal\\NSwag.Sample.NET60Minimal.csproj", "NSwag.Sample.NET60\\NSwag.Sample.NET60.csproj", - "NSwag.Sample.NET70Minimal\\NSwag.Sample.NET70Minimal.csproj", - "NSwag.Sample.NET70\\NSwag.Sample.NET70.csproj", "NSwag.Sample.NET80Minimal\\NSwag.Sample.NET80Minimal.csproj", "NSwag.Sample.NET80\\NSwag.Sample.NET80.csproj" ] diff --git a/src/NSwag.Npm/README.md b/src/NSwag.Npm/README.md index 62bd5ae8ce..083db8b3db 100644 --- a/src/NSwag.Npm/README.md +++ b/src/NSwag.Npm/README.md @@ -43,7 +43,7 @@ To specify what .NET Core binaries to execute, either use (default) or - nswag version /runtime:Net70 + nswag version /runtime:Net80 ## Development diff --git a/src/NSwag.Npm/bin/nswag.js b/src/NSwag.Npm/bin/nswag.js index 5957bc4202..16add27913 100644 --- a/src/NSwag.Npm/bin/nswag.js +++ b/src/NSwag.Npm/bin/nswag.js @@ -4,7 +4,6 @@ var defaultCoreVersion = "Net80"; var supportedCoreVersions = [ { ver: '6.0', dir: "Net60", }, - { ver: '7.0', dir: "Net70", }, { ver: '8.0', dir: "Net80", }, ]; @@ -17,7 +16,6 @@ var args = process.argv.splice(2, process.argv.length - 2).map(function (a) { re args = args.replace("--x86", "/runtime:WinX86"); args = args.replace("/runtime:x86", "/runtime:WinX86"); args = args.replace("--core 6.0", "/runtime:Net60"); -args = args.replace("--core 7.0", "/runtime:Net70"); args = args.replace("--core 8.0", "/runtime:Net80"); args = args.replace("--core", "/runtime:" + defaultCoreVersion); diff --git a/src/NSwag.Sample.NET70/Controllers/ValuesController.cs b/src/NSwag.Sample.NET70/Controllers/ValuesController.cs deleted file mode 100644 index bf61ff4b78..0000000000 --- a/src/NSwag.Sample.NET70/Controllers/ValuesController.cs +++ /dev/null @@ -1,80 +0,0 @@ -using System; -using System.Collections.Generic; -using Microsoft.AspNetCore.Mvc; - -namespace NSwag.Sample.NET70.Controllers -{ - [Route("api/[controller]")] - [ApiController] - public class ValuesController : ControllerBase - { - public class Person - { - public string FirstName { get; set; } = ""; - - public string? MiddleName { get; set; } - - public string LastName { get; set; } = ""; - - public DateTime DayOfBirth { get; set; } - } - - public enum TestEnum - { - Foo, - Bar - } - - [HttpGet] - public ActionResult> Get() - { - return new Person[] { }; - } - - // GET api/values/5 - [HttpGet("{id}")] - public ActionResult Get(int id) - { - return TestEnum.Foo; - } - - // GET api/values/ToString(5) - [HttpGet("ToString({id})")] - public ActionResult GetToString(int id) - { - return TestEnum.Foo.ToString(); - } - - // GET api/values/id:5 - [HttpGet("id:{id}")] - public ActionResult GetToId(int id) - { - return TestEnum.Foo.ToString(); - } - - // GET api/values/5 - [HttpGet("{id}/foo")] - public ActionResult GetFooBar(int id) - { - return "value"; - } - - // POST api/values - [HttpPost] - public void Post([FromBody] string value) - { - } - - // PUT api/values/5 - [HttpPut("{id}")] - public void Put(int id, [FromBody] string value) - { - } - - // DELETE api/values/5 - [HttpDelete("{id}")] - public void Delete(int id) - { - } - } -} diff --git a/src/NSwag.Sample.NET70/NSwag.Sample.NET70.csproj b/src/NSwag.Sample.NET70/NSwag.Sample.NET70.csproj deleted file mode 100644 index 7ffd30eec6..0000000000 --- a/src/NSwag.Sample.NET70/NSwag.Sample.NET70.csproj +++ /dev/null @@ -1,12 +0,0 @@ - - - - net7.0 - enable - - - - - - - diff --git a/src/NSwag.Sample.NET70/Program.cs b/src/NSwag.Sample.NET70/Program.cs deleted file mode 100644 index ba59da74aa..0000000000 --- a/src/NSwag.Sample.NET70/Program.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Hosting; -using NSwag.Sample.NET70; - -namespace NSwag.Sample.NET70 -{ - public class Program - { - public static void Main(string[] args) - { - CreateHostBuilder(args).Build().Run(); - } - - public static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup(); - }); - } -} diff --git a/src/NSwag.Sample.NET70/Properties/launchSettings.json b/src/NSwag.Sample.NET70/Properties/launchSettings.json deleted file mode 100644 index b9ab13135c..0000000000 --- a/src/NSwag.Sample.NET70/Properties/launchSettings.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "$schema": "http://json.schemastore.org/launchsettings.json", - "profiles": { - "NSwag.Sample.NET70": { - "commandName": "Project", - "launchBrowser": true, - "launchUrl": "swagger", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - }, - "applicationUrl": "https://localhost:7001;http://localhost:7000" - } - } -} \ No newline at end of file diff --git a/src/NSwag.Sample.NET70/Startup.cs b/src/NSwag.Sample.NET70/Startup.cs deleted file mode 100644 index c56a6a55e1..0000000000 --- a/src/NSwag.Sample.NET70/Startup.cs +++ /dev/null @@ -1,65 +0,0 @@ -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using NJsonSchema.Generation; -using System.Text.Json.Serialization; - -namespace NSwag.Sample.NET70 -{ - public class Startup - { - public Startup(IConfiguration configuration) - { - Configuration = configuration; - } - - public IConfiguration Configuration { get; } - - public void ConfigureServices(IServiceCollection services) - { - services.AddMvc(); - - services - .AddControllers() - .AddJsonOptions(options => - { - options.JsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull; - options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter()); - }); - - services.AddOpenApiDocument(document => - { - document.Description = "Hello world!"; - document.SchemaSettings.DefaultReferenceTypeNullHandling = ReferenceTypeNullHandling.NotNull; - }); - } - - public void Configure(IApplicationBuilder app, IWebHostEnvironment env) - { - if (env.IsDevelopment()) - { - app.UseDeveloperExceptionPage(); - } - - app.UseHttpsRedirection(); - app.UseRouting(); - app.UseAuthorization(); - app.UseEndpoints(endpoints => - { - endpoints.MapControllers(); - }); - - app.UseOpenApi(p => p.Path = "/swagger/{documentName}/swagger.yaml"); - app.UseSwaggerUi(p => p.DocumentPath = "/swagger/{documentName}/swagger.yaml"); - //app.UseApimundo(); - app.UseApimundo(settings => - { - //settings.CompareTo = "a:a:27:25:15:latest"; - settings.DocumentPath = "/swagger/v1/swagger.yaml"; - settings.ApimundoUrl = "https://localhost:5001"; - }); - } - } -} diff --git a/src/NSwag.Sample.NET70/appsettings.Development.json b/src/NSwag.Sample.NET70/appsettings.Development.json deleted file mode 100644 index e203e9407e..0000000000 --- a/src/NSwag.Sample.NET70/appsettings.Development.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Debug", - "System": "Information", - "Microsoft": "Information" - } - } -} diff --git a/src/NSwag.Sample.NET70/appsettings.json b/src/NSwag.Sample.NET70/appsettings.json deleted file mode 100644 index 7cb5ac8193..0000000000 --- a/src/NSwag.Sample.NET70/appsettings.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Warning", - "Microsoft.Hosting.Lifetime": "Information" - } - }, - "AllowedHosts": "*" -} diff --git a/src/NSwag.Sample.NET70/nswag.json b/src/NSwag.Sample.NET70/nswag.json deleted file mode 100644 index bb98150a97..0000000000 --- a/src/NSwag.Sample.NET70/nswag.json +++ /dev/null @@ -1,57 +0,0 @@ -{ - "runtime": "Net70", - "defaultVariables": null, - "documentGenerator": { - "aspNetCoreToOpenApi": { - "project": "NSwag.Sample.NET70.csproj", - "msBuildProjectExtensionsPath": null, - "configuration": null, - "runtime": null, - "targetFramework": null, - "noBuild": false, - "verbose": true, - "workingDirectory": null, - "requireParametersWithoutDefault": false, - "apiGroupNames": null, - "defaultPropertyNameHandling": "Default", - "defaultReferenceTypeNullHandling": "Null", - "defaultDictionaryValueReferenceTypeNullHandling": "NotNull", - "defaultResponseReferenceTypeNullHandling": "NotNull", - "defaultEnumHandling": "Integer", - "flattenInheritanceHierarchy": false, - "generateKnownTypes": true, - "generateEnumMappingDescription": false, - "generateXmlObjects": false, - "generateAbstractProperties": false, - "generateAbstractSchemas": true, - "ignoreObsoleteProperties": false, - "allowReferencesWithProperties": false, - "excludedTypeNames": [], - "serviceHost": null, - "serviceBasePath": null, - "serviceSchemes": [], - "infoTitle": "My Title", - "infoDescription": null, - "infoVersion": "1.0.0", - "documentTemplate": null, - "documentProcessorTypes": [], - "operationProcessorTypes": [], - "typeNameGeneratorType": null, - "schemaNameGeneratorType": null, - "contractResolverType": null, - "serializerSettingsType": null, - "documentName": "v1", - "aspNetCoreEnvironment": null, - "createWebHostBuilderMethod": null, - "startupType": null, - "allowNullableBodyParameters": true, - "output": "openapi.json", - "outputType": "Swagger2", - "assemblyPaths": [], - "assemblyConfig": null, - "referencePaths": [], - "useNuGetCache": false - } - }, - "codeGenerators": {} -} diff --git a/src/NSwag.Sample.NET70/openapi.json b/src/NSwag.Sample.NET70/openapi.json deleted file mode 100644 index 90ee6fab4b..0000000000 --- a/src/NSwag.Sample.NET70/openapi.json +++ /dev/null @@ -1,279 +0,0 @@ -{ - "x-generator": "NSwag", - "openapi": "3.0.0", - "info": { - "title": "My Title", - "description": "Hello world!", - "version": "1.0.0" - }, - "paths": { - "/api/Values": { - "get": { - "tags": [ - "Values" - ], - "operationId": "Values_GetAll", - "responses": { - "200": { - "description": "", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Person" - } - } - } - } - } - } - }, - "post": { - "tags": [ - "Values" - ], - "operationId": "Values_Post", - "requestBody": { - "x-name": "value", - "content": { - "application/json": { - "schema": { - "type": "string" - } - } - }, - "required": true, - "x-position": 1 - }, - "responses": { - "200": { - "description": "" - } - } - } - }, - "/api/Values/{id}": { - "get": { - "tags": [ - "Values" - ], - "operationId": "Values_Get", - "parameters": [ - { - "name": "id", - "in": "path", - "required": true, - "schema": { - "type": "integer", - "format": "int32" - }, - "x-position": 1 - } - ], - "responses": { - "200": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TestEnum" - } - } - } - } - } - }, - "put": { - "tags": [ - "Values" - ], - "operationId": "Values_Put", - "parameters": [ - { - "name": "id", - "in": "path", - "required": true, - "schema": { - "type": "integer", - "format": "int32" - }, - "x-position": 1 - } - ], - "requestBody": { - "x-name": "value", - "content": { - "application/json": { - "schema": { - "type": "string" - } - } - }, - "required": true, - "x-position": 2 - }, - "responses": { - "200": { - "description": "" - } - } - }, - "delete": { - "tags": [ - "Values" - ], - "operationId": "Values_Delete", - "parameters": [ - { - "name": "id", - "in": "path", - "required": true, - "schema": { - "type": "integer", - "format": "int32" - }, - "x-position": 1 - } - ], - "responses": { - "200": { - "description": "" - } - } - } - }, - "/api/Values/ToString({id})": { - "get": { - "tags": [ - "Values" - ], - "operationId": "Values_GetToString", - "parameters": [ - { - "name": "id", - "in": "path", - "required": true, - "schema": { - "type": "integer", - "format": "int32" - }, - "x-position": 1 - } - ], - "responses": { - "200": { - "description": "", - "content": { - "application/json": { - "schema": { - "type": "string" - } - } - } - } - } - } - }, - "/api/Values/id:{id}": { - "get": { - "tags": [ - "Values" - ], - "operationId": "Values_GetToId", - "parameters": [ - { - "name": "id", - "in": "path", - "required": true, - "schema": { - "type": "integer", - "format": "int32" - }, - "x-position": 1 - } - ], - "responses": { - "200": { - "description": "", - "content": { - "application/json": { - "schema": { - "type": "string" - } - } - } - } - } - } - }, - "/api/Values/{id}/foo": { - "get": { - "tags": [ - "Values" - ], - "operationId": "Values_GetFooBar", - "parameters": [ - { - "name": "id", - "in": "path", - "required": true, - "schema": { - "type": "integer", - "format": "int32" - }, - "x-position": 1 - } - ], - "responses": { - "200": { - "description": "", - "content": { - "application/json": { - "schema": { - "type": "string" - } - } - } - } - } - } - } - }, - "components": { - "schemas": { - "Person": { - "type": "object", - "additionalProperties": false, - "properties": { - "firstName": { - "type": "string" - }, - "middleName": { - "type": "string", - "nullable": true - }, - "lastName": { - "type": "string" - }, - "dayOfBirth": { - "type": "string", - "format": "date-time" - } - } - }, - "TestEnum": { - "type": "string", - "description": "", - "x-enumNames": [ - "Foo", - "Bar" - ], - "enum": [ - "Foo", - "Bar" - ] - } - } - } -} \ No newline at end of file diff --git a/src/NSwag.Sample.NET70Minimal/GeneratedClientsCs.gen b/src/NSwag.Sample.NET70Minimal/GeneratedClientsCs.gen deleted file mode 100644 index c4b072884b..0000000000 --- a/src/NSwag.Sample.NET70Minimal/GeneratedClientsCs.gen +++ /dev/null @@ -1,832 +0,0 @@ -//---------------------- -// -// Generated using the NSwag toolchain v (http://NSwag.org) -// -//---------------------- - -#pragma warning disable 108 // Disable "CS0108 '{derivedDto}.ToJson()' hides inherited member '{dtoBase}.ToJson()'. Use the new keyword if hiding was intended." -#pragma warning disable 114 // Disable "CS0114 '{derivedDto}.RaisePropertyChanged(String)' hides inherited member 'dtoBase.RaisePropertyChanged(String)'. To make the current member override that implementation, add the override keyword. Otherwise add the new keyword." -#pragma warning disable 472 // Disable "CS0472 The result of the expression is always 'false' since a value of type 'Int32' is never equal to 'null' of type 'Int32?' -#pragma warning disable 612 // Disable "CS0612 '...' is obsolete" -#pragma warning disable 649 // Disable "CS0649 Field is never assigned to, and will always have its default value null" -#pragma warning disable 1573 // Disable "CS1573 Parameter '...' has no matching param tag in the XML comment for ... -#pragma warning disable 1591 // Disable "CS1591 Missing XML comment for publicly visible type or member ..." -#pragma warning disable 8073 // Disable "CS8073 The result of the expression is always 'false' since a value of type 'T' is never equal to 'null' of type 'T?'" -#pragma warning disable 3016 // Disable "CS3016 Arrays as attribute arguments is not CLS-compliant" -#pragma warning disable 8603 // Disable "CS8603 Possible null reference return" -#pragma warning disable 8604 // Disable "CS8604 Possible null reference argument for parameter" -#pragma warning disable 8625 // Disable "CS8625 Cannot convert null literal to non-nullable reference type" -#pragma warning disable 8765 // Disable "CS8765 Nullability of type of parameter doesn't match overridden member (possibly because of nullability attributes)." - -namespace MyNamespace -{ - using System = global::System; - - [System.CodeDom.Compiler.GeneratedCode("NSwag", "")] - public partial class Client - { - #pragma warning disable 8618 - private string _baseUrl; - #pragma warning restore 8618 - - private System.Net.Http.HttpClient _httpClient; - private static System.Lazy _settings = new System.Lazy(CreateSerializerSettings, true); - private Newtonsoft.Json.JsonSerializerSettings _instanceSettings; - - #pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. - public Client(string baseUrl, System.Net.Http.HttpClient httpClient) - #pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. - { - BaseUrl = baseUrl; - _httpClient = httpClient; - Initialize(); - } - - private static Newtonsoft.Json.JsonSerializerSettings CreateSerializerSettings() - { - var settings = new Newtonsoft.Json.JsonSerializerSettings(); - UpdateJsonSerializerSettings(settings); - return settings; - } - - public string BaseUrl - { - get { return _baseUrl; } - set - { - _baseUrl = value; - if (!string.IsNullOrEmpty(_baseUrl) && !_baseUrl.EndsWith("/")) - _baseUrl += '/'; - } - } - - protected Newtonsoft.Json.JsonSerializerSettings JsonSerializerSettings { get { return _instanceSettings ?? _settings.Value; } } - - static partial void UpdateJsonSerializerSettings(Newtonsoft.Json.JsonSerializerSettings settings); - - partial void Initialize(); - - partial void PrepareRequest(System.Net.Http.HttpClient client, System.Net.Http.HttpRequestMessage request, string url); - partial void PrepareRequest(System.Net.Http.HttpClient client, System.Net.Http.HttpRequestMessage request, System.Text.StringBuilder urlBuilder); - partial void ProcessResponse(System.Net.Http.HttpClient client, System.Net.Http.HttpResponseMessage response); - - /// A server side error occurred. - public virtual System.Threading.Tasks.Task GetAsync() - { - return GetAsync(System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// A server side error occurred. - public virtual async System.Threading.Tasks.Task GetAsync(System.Threading.CancellationToken cancellationToken) - { - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - request_.Method = new System.Net.Http.HttpMethod("GET"); - request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); - - var urlBuilder_ = new System.Text.StringBuilder(); - if (!string.IsNullOrEmpty(_baseUrl)) urlBuilder_.Append(_baseUrl); - // Operation Path: "" - - PrepareRequest(client_, request_, urlBuilder_); - - var url_ = urlBuilder_.ToString(); - request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); - - PrepareRequest(client_, request_, url_); - - var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); - var disposeResponse_ = true; - try - { - var headers_ = new System.Collections.Generic.Dictionary>(); - foreach (var item_ in response_.Headers) - headers_[item_.Key] = item_.Value; - if (response_.Content != null && response_.Content.Headers != null) - { - foreach (var item_ in response_.Content.Headers) - headers_[item_.Key] = item_.Value; - } - - ProcessResponse(client_, response_); - - var status_ = (int)response_.StatusCode; - if (status_ == 200) - { - var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false); - if (objectResponse_.Object == null) - { - throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); - } - return objectResponse_.Object; - } - else - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null); - } - } - finally - { - if (disposeResponse_) - response_.Dispose(); - } - } - } - finally - { - if (disposeClient_) - client_.Dispose(); - } - } - - /// A server side error occurred. - public virtual System.Threading.Tasks.Task CalculateSumAsync(int a, int b) - { - return CalculateSumAsync(a, b, System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// A server side error occurred. - public virtual async System.Threading.Tasks.Task CalculateSumAsync(int a, int b, System.Threading.CancellationToken cancellationToken) - { - if (a == null) - throw new System.ArgumentNullException("a"); - - if (b == null) - throw new System.ArgumentNullException("b"); - - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - request_.Method = new System.Net.Http.HttpMethod("GET"); - request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); - - var urlBuilder_ = new System.Text.StringBuilder(); - if (!string.IsNullOrEmpty(_baseUrl)) urlBuilder_.Append(_baseUrl); - // Operation Path: "sum/{a}/{b}" - urlBuilder_.Append("sum/"); - urlBuilder_.Append(System.Uri.EscapeDataString(ConvertToString(a, System.Globalization.CultureInfo.InvariantCulture))); - urlBuilder_.Append('/'); - urlBuilder_.Append(System.Uri.EscapeDataString(ConvertToString(b, System.Globalization.CultureInfo.InvariantCulture))); - - PrepareRequest(client_, request_, urlBuilder_); - - var url_ = urlBuilder_.ToString(); - request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); - - PrepareRequest(client_, request_, url_); - - var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); - var disposeResponse_ = true; - try - { - var headers_ = new System.Collections.Generic.Dictionary>(); - foreach (var item_ in response_.Headers) - headers_[item_.Key] = item_.Value; - if (response_.Content != null && response_.Content.Headers != null) - { - foreach (var item_ in response_.Content.Headers) - headers_[item_.Key] = item_.Value; - } - - ProcessResponse(client_, response_); - - var status_ = (int)response_.StatusCode; - if (status_ == 200) - { - var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false); - if (objectResponse_.Object == null) - { - throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); - } - return objectResponse_.Object; - } - else - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null); - } - } - finally - { - if (disposeResponse_) - response_.Dispose(); - } - } - } - finally - { - if (disposeClient_) - client_.Dispose(); - } - } - - /// A server side error occurred. - public virtual System.Threading.Tasks.Task AbsoluteValueAsync(int a) - { - return AbsoluteValueAsync(a, System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// A server side error occurred. - public virtual async System.Threading.Tasks.Task AbsoluteValueAsync(int a, System.Threading.CancellationToken cancellationToken) - { - if (a == null) - throw new System.ArgumentNullException("a"); - - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - request_.Method = new System.Net.Http.HttpMethod("GET"); - request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); - - var urlBuilder_ = new System.Text.StringBuilder(); - if (!string.IsNullOrEmpty(_baseUrl)) urlBuilder_.Append(_baseUrl); - // Operation Path: "abs({a})" - urlBuilder_.Append("abs("); - urlBuilder_.Append(System.Uri.EscapeDataString(ConvertToString(a, System.Globalization.CultureInfo.InvariantCulture))); - urlBuilder_.Append(')'); - - PrepareRequest(client_, request_, urlBuilder_); - - var url_ = urlBuilder_.ToString(); - request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); - - PrepareRequest(client_, request_, url_); - - var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); - var disposeResponse_ = true; - try - { - var headers_ = new System.Collections.Generic.Dictionary>(); - foreach (var item_ in response_.Headers) - headers_[item_.Key] = item_.Value; - if (response_.Content != null && response_.Content.Headers != null) - { - foreach (var item_ in response_.Content.Headers) - headers_[item_.Key] = item_.Value; - } - - ProcessResponse(client_, response_); - - var status_ = (int)response_.StatusCode; - if (status_ == 200) - { - var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false); - if (objectResponse_.Object == null) - { - throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); - } - return objectResponse_.Object; - } - else - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null); - } - } - finally - { - if (disposeResponse_) - response_.Dispose(); - } - } - } - finally - { - if (disposeClient_) - client_.Dispose(); - } - } - - /// - /// Hello world! - /// - /// A server side error occurred. - public virtual System.Threading.Tasks.Task IdentityAsync(int id) - { - return IdentityAsync(id, System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// - /// Hello world! - /// - /// A server side error occurred. - public virtual async System.Threading.Tasks.Task IdentityAsync(int id, System.Threading.CancellationToken cancellationToken) - { - if (id == null) - throw new System.ArgumentNullException("id"); - - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - request_.Method = new System.Net.Http.HttpMethod("GET"); - request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); - - var urlBuilder_ = new System.Text.StringBuilder(); - if (!string.IsNullOrEmpty(_baseUrl)) urlBuilder_.Append(_baseUrl); - // Operation Path: "id:{id}" - urlBuilder_.Append("id:"); - urlBuilder_.Append(System.Uri.EscapeDataString(ConvertToString(id, System.Globalization.CultureInfo.InvariantCulture))); - - PrepareRequest(client_, request_, urlBuilder_); - - var url_ = urlBuilder_.ToString(); - request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); - - PrepareRequest(client_, request_, url_); - - var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); - var disposeResponse_ = true; - try - { - var headers_ = new System.Collections.Generic.Dictionary>(); - foreach (var item_ in response_.Headers) - headers_[item_.Key] = item_.Value; - if (response_.Content != null && response_.Content.Headers != null) - { - foreach (var item_ in response_.Content.Headers) - headers_[item_.Key] = item_.Value; - } - - ProcessResponse(client_, response_); - - var status_ = (int)response_.StatusCode; - if (status_ == 200) - { - var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false); - if (objectResponse_.Object == null) - { - throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); - } - return objectResponse_.Object; - } - else - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null); - } - } - finally - { - if (disposeResponse_) - response_.Dispose(); - } - } - } - finally - { - if (disposeClient_) - client_.Dispose(); - } - } - - protected struct ObjectResponseResult - { - public ObjectResponseResult(T responseObject, string responseText) - { - this.Object = responseObject; - this.Text = responseText; - } - - public T Object { get; } - - public string Text { get; } - } - - public bool ReadResponseAsString { get; set; } - - protected virtual async System.Threading.Tasks.Task> ReadObjectResponseAsync(System.Net.Http.HttpResponseMessage response, System.Collections.Generic.IReadOnlyDictionary> headers, System.Threading.CancellationToken cancellationToken) - { - if (response == null || response.Content == null) - { - return new ObjectResponseResult(default(T), string.Empty); - } - - if (ReadResponseAsString) - { - var responseText = await response.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - var typedBody = Newtonsoft.Json.JsonConvert.DeserializeObject(responseText, JsonSerializerSettings); - return new ObjectResponseResult(typedBody, responseText); - } - catch (Newtonsoft.Json.JsonException exception) - { - var message = "Could not deserialize the response body string as " + typeof(T).FullName + "."; - throw new ApiException(message, (int)response.StatusCode, responseText, headers, exception); - } - } - else - { - try - { - using (var responseStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false)) - using (var streamReader = new System.IO.StreamReader(responseStream)) - using (var jsonTextReader = new Newtonsoft.Json.JsonTextReader(streamReader)) - { - var serializer = Newtonsoft.Json.JsonSerializer.Create(JsonSerializerSettings); - var typedBody = serializer.Deserialize(jsonTextReader); - return new ObjectResponseResult(typedBody, string.Empty); - } - } - catch (Newtonsoft.Json.JsonException exception) - { - var message = "Could not deserialize the response body stream as " + typeof(T).FullName + "."; - throw new ApiException(message, (int)response.StatusCode, string.Empty, headers, exception); - } - } - } - - private string ConvertToString(object value, System.Globalization.CultureInfo cultureInfo) - { - if (value == null) - { - return ""; - } - - if (value is System.Enum) - { - var name = System.Enum.GetName(value.GetType(), value); - if (name != null) - { - var field = System.Reflection.IntrospectionExtensions.GetTypeInfo(value.GetType()).GetDeclaredField(name); - if (field != null) - { - var attribute = System.Reflection.CustomAttributeExtensions.GetCustomAttribute(field, typeof(System.Runtime.Serialization.EnumMemberAttribute)) - as System.Runtime.Serialization.EnumMemberAttribute; - if (attribute != null) - { - return attribute.Value != null ? attribute.Value : name; - } - } - - var converted = System.Convert.ToString(System.Convert.ChangeType(value, System.Enum.GetUnderlyingType(value.GetType()), cultureInfo)); - return converted == null ? string.Empty : converted; - } - } - else if (value is bool) - { - return System.Convert.ToString((bool)value, cultureInfo).ToLowerInvariant(); - } - else if (value is byte[]) - { - return System.Convert.ToBase64String((byte[]) value); - } - else if (value is string[]) - { - return string.Join(",", (string[])value); - } - else if (value.GetType().IsArray) - { - var valueArray = (System.Array)value; - var valueTextArray = new string[valueArray.Length]; - for (var i = 0; i < valueArray.Length; i++) - { - valueTextArray[i] = ConvertToString(valueArray.GetValue(i), cultureInfo); - } - return string.Join(",", valueTextArray); - } - - var result = System.Convert.ToString(value, cultureInfo); - return result == null ? "" : result; - } - } - - [System.CodeDom.Compiler.GeneratedCode("NSwag", "")] - public partial class ExampleClient - { - #pragma warning disable 8618 - private string _baseUrl; - #pragma warning restore 8618 - - private System.Net.Http.HttpClient _httpClient; - private static System.Lazy _settings = new System.Lazy(CreateSerializerSettings, true); - private Newtonsoft.Json.JsonSerializerSettings _instanceSettings; - - #pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. - public ExampleClient(string baseUrl, System.Net.Http.HttpClient httpClient) - #pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. - { - BaseUrl = baseUrl; - _httpClient = httpClient; - Initialize(); - } - - private static Newtonsoft.Json.JsonSerializerSettings CreateSerializerSettings() - { - var settings = new Newtonsoft.Json.JsonSerializerSettings(); - UpdateJsonSerializerSettings(settings); - return settings; - } - - public string BaseUrl - { - get { return _baseUrl; } - set - { - _baseUrl = value; - if (!string.IsNullOrEmpty(_baseUrl) && !_baseUrl.EndsWith("/")) - _baseUrl += '/'; - } - } - - protected Newtonsoft.Json.JsonSerializerSettings JsonSerializerSettings { get { return _instanceSettings ?? _settings.Value; } } - - static partial void UpdateJsonSerializerSettings(Newtonsoft.Json.JsonSerializerSettings settings); - - partial void Initialize(); - - partial void PrepareRequest(System.Net.Http.HttpClient client, System.Net.Http.HttpRequestMessage request, string url); - partial void PrepareRequest(System.Net.Http.HttpClient client, System.Net.Http.HttpRequestMessage request, System.Text.StringBuilder urlBuilder); - partial void ProcessResponse(System.Net.Http.HttpClient client, System.Net.Http.HttpResponseMessage response); - - /// A server side error occurred. - public virtual System.Threading.Tasks.Task GetAsync() - { - return GetAsync(System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// A server side error occurred. - public virtual async System.Threading.Tasks.Task GetAsync(System.Threading.CancellationToken cancellationToken) - { - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - request_.Method = new System.Net.Http.HttpMethod("GET"); - request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/octet-stream")); - - var urlBuilder_ = new System.Text.StringBuilder(); - if (!string.IsNullOrEmpty(_baseUrl)) urlBuilder_.Append(_baseUrl); - // Operation Path: "examples" - urlBuilder_.Append("examples"); - - PrepareRequest(client_, request_, urlBuilder_); - - var url_ = urlBuilder_.ToString(); - request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); - - PrepareRequest(client_, request_, url_); - - var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); - var disposeResponse_ = true; - try - { - var headers_ = new System.Collections.Generic.Dictionary>(); - foreach (var item_ in response_.Headers) - headers_[item_.Key] = item_.Value; - if (response_.Content != null && response_.Content.Headers != null) - { - foreach (var item_ in response_.Content.Headers) - headers_[item_.Key] = item_.Value; - } - - ProcessResponse(client_, response_); - - var status_ = (int)response_.StatusCode; - if (status_ == 200 || status_ == 206) - { - var responseStream_ = response_.Content == null ? System.IO.Stream.Null : await response_.Content.ReadAsStreamAsync().ConfigureAwait(false); - var fileResponse_ = new FileResponse(status_, headers_, responseStream_, null, response_); - disposeClient_ = false; disposeResponse_ = false; // response and client are disposed by FileResponse - return fileResponse_; - } - else - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null); - } - } - finally - { - if (disposeResponse_) - response_.Dispose(); - } - } - } - finally - { - if (disposeClient_) - client_.Dispose(); - } - } - - protected struct ObjectResponseResult - { - public ObjectResponseResult(T responseObject, string responseText) - { - this.Object = responseObject; - this.Text = responseText; - } - - public T Object { get; } - - public string Text { get; } - } - - public bool ReadResponseAsString { get; set; } - - protected virtual async System.Threading.Tasks.Task> ReadObjectResponseAsync(System.Net.Http.HttpResponseMessage response, System.Collections.Generic.IReadOnlyDictionary> headers, System.Threading.CancellationToken cancellationToken) - { - if (response == null || response.Content == null) - { - return new ObjectResponseResult(default(T), string.Empty); - } - - if (ReadResponseAsString) - { - var responseText = await response.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - var typedBody = Newtonsoft.Json.JsonConvert.DeserializeObject(responseText, JsonSerializerSettings); - return new ObjectResponseResult(typedBody, responseText); - } - catch (Newtonsoft.Json.JsonException exception) - { - var message = "Could not deserialize the response body string as " + typeof(T).FullName + "."; - throw new ApiException(message, (int)response.StatusCode, responseText, headers, exception); - } - } - else - { - try - { - using (var responseStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false)) - using (var streamReader = new System.IO.StreamReader(responseStream)) - using (var jsonTextReader = new Newtonsoft.Json.JsonTextReader(streamReader)) - { - var serializer = Newtonsoft.Json.JsonSerializer.Create(JsonSerializerSettings); - var typedBody = serializer.Deserialize(jsonTextReader); - return new ObjectResponseResult(typedBody, string.Empty); - } - } - catch (Newtonsoft.Json.JsonException exception) - { - var message = "Could not deserialize the response body stream as " + typeof(T).FullName + "."; - throw new ApiException(message, (int)response.StatusCode, string.Empty, headers, exception); - } - } - } - - private string ConvertToString(object value, System.Globalization.CultureInfo cultureInfo) - { - if (value == null) - { - return ""; - } - - if (value is System.Enum) - { - var name = System.Enum.GetName(value.GetType(), value); - if (name != null) - { - var field = System.Reflection.IntrospectionExtensions.GetTypeInfo(value.GetType()).GetDeclaredField(name); - if (field != null) - { - var attribute = System.Reflection.CustomAttributeExtensions.GetCustomAttribute(field, typeof(System.Runtime.Serialization.EnumMemberAttribute)) - as System.Runtime.Serialization.EnumMemberAttribute; - if (attribute != null) - { - return attribute.Value != null ? attribute.Value : name; - } - } - - var converted = System.Convert.ToString(System.Convert.ChangeType(value, System.Enum.GetUnderlyingType(value.GetType()), cultureInfo)); - return converted == null ? string.Empty : converted; - } - } - else if (value is bool) - { - return System.Convert.ToString((bool)value, cultureInfo).ToLowerInvariant(); - } - else if (value is byte[]) - { - return System.Convert.ToBase64String((byte[]) value); - } - else if (value is string[]) - { - return string.Join(",", (string[])value); - } - else if (value.GetType().IsArray) - { - var valueArray = (System.Array)value; - var valueTextArray = new string[valueArray.Length]; - for (var i = 0; i < valueArray.Length; i++) - { - valueTextArray[i] = ConvertToString(valueArray.GetValue(i), cultureInfo); - } - return string.Join(",", valueTextArray); - } - - var result = System.Convert.ToString(value, cultureInfo); - return result == null ? "" : result; - } - } - - - - [System.CodeDom.Compiler.GeneratedCode("NSwag", "")] - public partial class FileResponse : System.IDisposable - { - private System.IDisposable _client; - private System.IDisposable _response; - - public int StatusCode { get; private set; } - - public System.Collections.Generic.IReadOnlyDictionary> Headers { get; private set; } - - public System.IO.Stream Stream { get; private set; } - - public bool IsPartial - { - get { return StatusCode == 206; } - } - - public FileResponse(int statusCode, System.Collections.Generic.IReadOnlyDictionary> headers, System.IO.Stream stream, System.IDisposable client, System.IDisposable response) - { - StatusCode = statusCode; - Headers = headers; - Stream = stream; - _client = client; - _response = response; - } - - public void Dispose() - { - Stream.Dispose(); - if (_response != null) - _response.Dispose(); - if (_client != null) - _client.Dispose(); - } - } - - - [System.CodeDom.Compiler.GeneratedCode("NSwag", "")] - public partial class ApiException : System.Exception - { - public int StatusCode { get; private set; } - - public string Response { get; private set; } - - public System.Collections.Generic.IReadOnlyDictionary> Headers { get; private set; } - - public ApiException(string message, int statusCode, string response, System.Collections.Generic.IReadOnlyDictionary> headers, System.Exception innerException) - : base(message + "\n\nStatus: " + statusCode + "\nResponse: \n" + ((response == null) ? "(null)" : response.Substring(0, response.Length >= 512 ? 512 : response.Length)), innerException) - { - StatusCode = statusCode; - Response = response; - Headers = headers; - } - - public override string ToString() - { - return string.Format("HTTP Response: \n\n{0}\n\n{1}", Response, base.ToString()); - } - } - - [System.CodeDom.Compiler.GeneratedCode("NSwag", "")] - public partial class ApiException : ApiException - { - public TResult Result { get; private set; } - - public ApiException(string message, int statusCode, string response, System.Collections.Generic.IReadOnlyDictionary> headers, TResult result, System.Exception innerException) - : base(message, statusCode, response, headers, innerException) - { - Result = result; - } - } - -} - -#pragma warning restore 108 -#pragma warning restore 114 -#pragma warning restore 472 -#pragma warning restore 612 -#pragma warning restore 1573 -#pragma warning restore 1591 -#pragma warning restore 8073 -#pragma warning restore 3016 -#pragma warning restore 8603 -#pragma warning restore 8604 -#pragma warning restore 8625 \ No newline at end of file diff --git a/src/NSwag.Sample.NET70Minimal/GeneratedClientsTs.gen b/src/NSwag.Sample.NET70Minimal/GeneratedClientsTs.gen deleted file mode 100644 index 21ee891e02..0000000000 --- a/src/NSwag.Sample.NET70Minimal/GeneratedClientsTs.gen +++ /dev/null @@ -1,259 +0,0 @@ -//---------------------- -// -// Generated using the NSwag toolchain v (http://NSwag.org) -// -//---------------------- - -/* tslint:disable */ -/* eslint-disable */ -// ReSharper disable InconsistentNaming - -export class Client { - private http: { fetch(url: RequestInfo, init?: RequestInit): Promise }; - private baseUrl: string; - protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined; - - constructor(baseUrl?: string, http?: { fetch(url: RequestInfo, init?: RequestInit): Promise }) { - this.http = http ? http : window as any; - this.baseUrl = baseUrl ?? ""; - } - - get(): Promise { - let url_ = this.baseUrl + "/"; - url_ = url_.replace(/[?&]$/, ""); - - let options_: RequestInit = { - method: "GET", - headers: { - "Accept": "application/json" - } - }; - - return this.http.fetch(url_, options_).then((_response: Response) => { - return this.processGet(_response); - }); - } - - protected processGet(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - let result200: any = null; - let resultData200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver); - result200 = resultData200 !== undefined ? resultData200 : null; - - return result200; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - calculateSum(a: number, b: number): Promise { - let url_ = this.baseUrl + "/sum/{a}/{b}"; - if (a === undefined || a === null) - throw new Error("The parameter 'a' must be defined."); - url_ = url_.replace("{a}", encodeURIComponent("" + a)); - if (b === undefined || b === null) - throw new Error("The parameter 'b' must be defined."); - url_ = url_.replace("{b}", encodeURIComponent("" + b)); - url_ = url_.replace(/[?&]$/, ""); - - let options_: RequestInit = { - method: "GET", - headers: { - "Accept": "application/json" - } - }; - - return this.http.fetch(url_, options_).then((_response: Response) => { - return this.processCalculateSum(_response); - }); - } - - protected processCalculateSum(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - let result200: any = null; - let resultData200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver); - result200 = resultData200 !== undefined ? resultData200 : null; - - return result200; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - absoluteValue(a: number): Promise { - let url_ = this.baseUrl + "/abs({a})"; - if (a === undefined || a === null) - throw new Error("The parameter 'a' must be defined."); - url_ = url_.replace("{a}", encodeURIComponent("" + a)); - url_ = url_.replace(/[?&]$/, ""); - - let options_: RequestInit = { - method: "GET", - headers: { - "Accept": "application/json" - } - }; - - return this.http.fetch(url_, options_).then((_response: Response) => { - return this.processAbsoluteValue(_response); - }); - } - - protected processAbsoluteValue(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - let result200: any = null; - let resultData200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver); - result200 = resultData200 !== undefined ? resultData200 : null; - - return result200; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } - - identity(id: number): Promise { - let url_ = this.baseUrl + "/id:{id}"; - if (id === undefined || id === null) - throw new Error("The parameter 'id' must be defined."); - url_ = url_.replace("{id}", encodeURIComponent("" + id)); - url_ = url_.replace(/[?&]$/, ""); - - let options_: RequestInit = { - method: "GET", - headers: { - "Accept": "application/json" - } - }; - - return this.http.fetch(url_, options_).then((_response: Response) => { - return this.processIdentity(_response); - }); - } - - protected processIdentity(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200) { - return response.text().then((_responseText) => { - let result200: any = null; - let resultData200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver); - result200 = resultData200 !== undefined ? resultData200 : null; - - return result200; - }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } -} - -export class ExampleClient { - private http: { fetch(url: RequestInfo, init?: RequestInit): Promise }; - private baseUrl: string; - protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined; - - constructor(baseUrl?: string, http?: { fetch(url: RequestInfo, init?: RequestInit): Promise }) { - this.http = http ? http : window as any; - this.baseUrl = baseUrl ?? ""; - } - - get(): Promise { - let url_ = this.baseUrl + "/examples"; - url_ = url_.replace(/[?&]$/, ""); - - let options_: RequestInit = { - method: "GET", - headers: { - "Accept": "application/octet-stream" - } - }; - - return this.http.fetch(url_, options_).then((_response: Response) => { - return this.processGet(_response); - }); - } - - protected processGet(response: Response): Promise { - const status = response.status; - let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; - if (status === 200 || status === 206) { - const contentDisposition = response.headers ? response.headers.get("content-disposition") : undefined; - let fileNameMatch = contentDisposition ? /filename\*=(?:(\\?['"])(.*?)\1|(?:[^\s]+'.*?')?([^;\n]*))/g.exec(contentDisposition) : undefined; - let fileName = fileNameMatch && fileNameMatch.length > 1 ? fileNameMatch[3] || fileNameMatch[2] : undefined; - if (fileName) { - fileName = decodeURIComponent(fileName); - } else { - fileNameMatch = contentDisposition ? /filename="?([^"]*?)"?(;|$)/g.exec(contentDisposition) : undefined; - fileName = fileNameMatch && fileNameMatch.length > 1 ? fileNameMatch[1] : undefined; - } - return response.blob().then(blob => { return { fileName: fileName, data: blob, status: status, headers: _headers }; }); - } else if (status !== 200 && status !== 204) { - return response.text().then((_responseText) => { - return throwException("An unexpected server error occurred.", status, _responseText, _headers); - }); - } - return Promise.resolve(null as any); - } -} - -export interface FileResponse { - data: Blob; - status: number; - fileName?: string; - headers?: { [name: string]: any }; -} - -export class ApiException extends Error { - message: string; - status: number; - response: string; - headers: { [key: string]: any; }; - result: any; - - constructor(message: string, status: number, response: string, headers: { [key: string]: any; }, result: any) { - super(); - - this.message = message; - this.status = status; - this.response = response; - this.headers = headers; - this.result = result; - } - - protected isApiException = true; - - static isApiException(obj: any): obj is ApiException { - return obj.isApiException === true; - } -} - -function throwException(message: string, status: number, response: string, headers: { [key: string]: any; }, result?: any): any { - if (result !== null && result !== undefined) - throw result; - else - throw new ApiException(message, status, response, headers, null); -} \ No newline at end of file diff --git a/src/NSwag.Sample.NET70Minimal/GeneratedControllersCs.gen b/src/NSwag.Sample.NET70Minimal/GeneratedControllersCs.gen deleted file mode 100644 index 4acb62516b..0000000000 --- a/src/NSwag.Sample.NET70Minimal/GeneratedControllersCs.gen +++ /dev/null @@ -1,170 +0,0 @@ -//---------------------- -// -// Generated using the NSwag toolchain v (http://NSwag.org) -// -//---------------------- - -#pragma warning disable 108 // Disable "CS0108 '{derivedDto}.ToJson()' hides inherited member '{dtoBase}.ToJson()'. Use the new keyword if hiding was intended." -#pragma warning disable 114 // Disable "CS0114 '{derivedDto}.RaisePropertyChanged(String)' hides inherited member 'dtoBase.RaisePropertyChanged(String)'. To make the current member override that implementation, add the override keyword. Otherwise add the new keyword." -#pragma warning disable 472 // Disable "CS0472 The result of the expression is always 'false' since a value of type 'Int32' is never equal to 'null' of type 'Int32?' -#pragma warning disable 612 // Disable "CS0612 '...' is obsolete" -#pragma warning disable 649 // Disable "CS0649 Field is never assigned to, and will always have its default value null" -#pragma warning disable 1573 // Disable "CS1573 Parameter '...' has no matching param tag in the XML comment for ... -#pragma warning disable 1591 // Disable "CS1591 Missing XML comment for publicly visible type or member ..." -#pragma warning disable 8073 // Disable "CS8073 The result of the expression is always 'false' since a value of type 'T' is never equal to 'null' of type 'T?'" -#pragma warning disable 3016 // Disable "CS3016 Arrays as attribute arguments is not CLS-compliant" -#pragma warning disable 8603 // Disable "CS8603 Possible null reference return" -#pragma warning disable 8604 // Disable "CS8604 Possible null reference argument for parameter" -#pragma warning disable 8625 // Disable "CS8625 Cannot convert null literal to non-nullable reference type" -#pragma warning disable 8765 // Disable "CS8765 Nullability of type of parameter doesn't match overridden member (possibly because of nullability attributes)." - -namespace MyNamespace -{ - using System = global::System; - - [System.CodeDom.Compiler.GeneratedCode("NSwag", "")] - public interface IController - { - - System.Threading.Tasks.Task GetAsync(); - - - - System.Threading.Tasks.Task CalculateSumAsync(int a, int b); - - - System.Threading.Tasks.Task AbsoluteValueAsync(int a); - - /// - /// Hello world! - /// - - System.Threading.Tasks.Task IdentityAsync(int id); - - } - - [System.CodeDom.Compiler.GeneratedCode("NSwag", "")] - - public partial class Controller : Microsoft.AspNetCore.Mvc.ControllerBase - { - private IController _implementation; - - public Controller(IController implementation) - { - _implementation = implementation; - } - - [Microsoft.AspNetCore.Mvc.HttpGet, Microsoft.AspNetCore.Mvc.Route("")] - public System.Threading.Tasks.Task Get() - { - - return _implementation.GetAsync(); - } - - [Microsoft.AspNetCore.Mvc.HttpGet, Microsoft.AspNetCore.Mvc.Route("sum/{a}/{b}")] - public System.Threading.Tasks.Task CalculateSum(int a, int b) - { - - return _implementation.CalculateSumAsync(a, b); - } - - [Microsoft.AspNetCore.Mvc.HttpGet, Microsoft.AspNetCore.Mvc.Route("abs({a})")] - public System.Threading.Tasks.Task AbsoluteValue(int a) - { - - return _implementation.AbsoluteValueAsync(a); - } - - /// - /// Hello world! - /// - [Microsoft.AspNetCore.Mvc.HttpGet, Microsoft.AspNetCore.Mvc.Route("id:{id}")] - public System.Threading.Tasks.Task Identity(int id) - { - - return _implementation.IdentityAsync(id); - } - - } - - [System.CodeDom.Compiler.GeneratedCode("NSwag", "")] - public interface IExampleController - { - - System.Threading.Tasks.Task GetAsync(); - - } - - [System.CodeDom.Compiler.GeneratedCode("NSwag", "")] - - public partial class ExampleController : Microsoft.AspNetCore.Mvc.ControllerBase - { - private IExampleController _implementation; - - public ExampleController(IExampleController implementation) - { - _implementation = implementation; - } - - [Microsoft.AspNetCore.Mvc.HttpGet, Microsoft.AspNetCore.Mvc.Route("examples")] - public System.Threading.Tasks.Task Get() - { - - return _implementation.GetAsync(); - } - - } - - - - [System.CodeDom.Compiler.GeneratedCode("NSwag", "")] - public partial class FileResponse : System.IDisposable - { - private System.IDisposable _client; - private System.IDisposable _response; - - public int StatusCode { get; private set; } - - public System.Collections.Generic.IReadOnlyDictionary> Headers { get; private set; } - - public System.IO.Stream Stream { get; private set; } - - public bool IsPartial - { - get { return StatusCode == 206; } - } - - public FileResponse(int statusCode, System.Collections.Generic.IReadOnlyDictionary> headers, System.IO.Stream stream, System.IDisposable client, System.IDisposable response) - { - StatusCode = statusCode; - Headers = headers; - Stream = stream; - _client = client; - _response = response; - } - - public void Dispose() - { - Stream.Dispose(); - if (_response != null) - _response.Dispose(); - if (_client != null) - _client.Dispose(); - } - } - - - -} - -#pragma warning restore 108 -#pragma warning restore 114 -#pragma warning restore 472 -#pragma warning restore 612 -#pragma warning restore 1573 -#pragma warning restore 1591 -#pragma warning restore 8073 -#pragma warning restore 3016 -#pragma warning restore 8603 -#pragma warning restore 8604 -#pragma warning restore 8625 \ No newline at end of file diff --git a/src/NSwag.Sample.NET70Minimal/NSwag.Sample.NET70Minimal.csproj b/src/NSwag.Sample.NET70Minimal/NSwag.Sample.NET70Minimal.csproj deleted file mode 100644 index 48b3281097..0000000000 --- a/src/NSwag.Sample.NET70Minimal/NSwag.Sample.NET70Minimal.csproj +++ /dev/null @@ -1,11 +0,0 @@ - - - net7.0 - - - - - - - - diff --git a/src/NSwag.Sample.NET70Minimal/Program.cs b/src/NSwag.Sample.NET70Minimal/Program.cs deleted file mode 100644 index b02dc8fba6..0000000000 --- a/src/NSwag.Sample.NET70Minimal/Program.cs +++ /dev/null @@ -1,65 +0,0 @@ -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.DependencyInjection; -using System; - -var builder = WebApplication.CreateBuilder(args); - -// Optional: Use controllers -builder.Services.AddControllers(); - -builder.Services.AddEndpointsApiExplorer(); -builder.Services.AddOpenApiDocument(settings => -{ - settings.Title = "Minimal API"; - settings.Version = "v1"; -}); - -var app = builder.Build(); -app.UseDeveloperExceptionPage(); - -app.UseOpenApi(); -app.UseSwaggerUi(); - -app.MapGet("/", (Func)(() => "Hello World!")) - .WithTags("General"); - -app.MapGet("/sum/{a}/{b}", (Func)((a, b) => a + b)) - .WithName("CalculateSum") - .WithTags("Calculator"); - -app.MapGet("/abs({a})", (Func)(a => Math.Abs(a))) - .WithName("AbsoluteValue") - .WithTags("Calculator"); - -app.MapGet("/id:{id}", (int id) => id) - .WithName("Identity") - .WithTags("Calculator") - .WithOpenApi(x => - { - x.Description = "Hello world!"; - return x; - }); - - -// Optional: Use controllers -app.UseRouting(); -app.UseEndpoints(x => -{ - x.MapControllers(); -}); - -app.Run(); - -// Optional: Use controllers -[ApiController] -[Route("examples")] -public class ExampleController : ControllerBase -{ - [HttpGet] - public IActionResult Get() - { - return Ok("Get Method"); - } -} \ No newline at end of file diff --git a/src/NSwag.Sample.NET70Minimal/Properties/launchSettings.json b/src/NSwag.Sample.NET70Minimal/Properties/launchSettings.json deleted file mode 100644 index 68f0b4fb35..0000000000 --- a/src/NSwag.Sample.NET70Minimal/Properties/launchSettings.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "$schema": "http://json.schemastore.org/launchsettings.json", - "profiles": { - "NSwag.Sample.NET70Minimal": { - "commandName": "Project", - "launchBrowser": true, - "launchUrl": "swagger", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - }, - "applicationUrl": "https://localhost:7001;http://localhost:7000" - } - } -} \ No newline at end of file diff --git a/src/NSwag.Sample.NET70Minimal/nswag.json b/src/NSwag.Sample.NET70Minimal/nswag.json deleted file mode 100644 index 4d1dd750d0..0000000000 --- a/src/NSwag.Sample.NET70Minimal/nswag.json +++ /dev/null @@ -1,231 +0,0 @@ -{ - "runtime": "Net70", - "defaultVariables": null, - "documentGenerator": { - "aspNetCoreToOpenApi": { - "project": "NSwag.Sample.NET70Minimal.csproj", - "documentName": "v1", - "msBuildProjectExtensionsPath": null, - "configuration": null, - "runtime": null, - "targetFramework": null, - "noBuild": false, - "msBuildOutputPath": null, - "verbose": true, - "workingDirectory": null, - "aspNetCoreEnvironment": null, - "output": "openapi.json", - "newLineBehavior": "Auto" - } - }, - "codeGenerators": { - "openApiToTypeScriptClient": { - "className": "{controller}Client", - "moduleName": "", - "namespace": "", - "typeScriptVersion": 2.7, - "template": "Fetch", - "promiseType": "Promise", - "httpClass": "HttpClient", - "withCredentials": false, - "useSingletonProvider": false, - "injectionTokenType": "OpaqueToken", - "rxJsVersion": 6.0, - "dateTimeType": "Date", - "nullValue": "Undefined", - "generateClientClasses": true, - "generateClientInterfaces": false, - "generateOptionalParameters": false, - "exportTypes": true, - "wrapDtoExceptions": false, - "exceptionClass": "ApiException", - "clientBaseClass": null, - "wrapResponses": false, - "wrapResponseMethods": [], - "generateResponseClasses": true, - "responseClass": "SwaggerResponse", - "protectedMethods": [], - "configurationClass": null, - "useTransformOptionsMethod": false, - "useTransformResultMethod": false, - "generateDtoTypes": true, - "operationGenerationMode": "MultipleClientsFromOperationId", - "markOptionalProperties": true, - "generateCloneMethod": false, - "typeStyle": "Class", - "enumStyle": "Enum", - "useLeafType": false, - "classTypes": [], - "extendedClasses": [], - "extensionCode": null, - "generateDefaultValues": true, - "excludedTypeNames": [], - "excludedParameterNames": [], - "handleReferences": false, - "generateTypeCheckFunctions": false, - "generateConstructorInterface": true, - "convertConstructorInterfaceData": false, - "importRequiredTypes": true, - "useGetBaseUrlMethod": false, - "baseUrlTokenName": "API_BASE_URL", - "queryNullValue": "", - "useAbortSignal": false, - "inlineNamedDictionaries": false, - "inlineNamedAny": false, - "includeHttpContext": false, - "templateDirectory": null, - "serviceHost": null, - "serviceSchemes": null, - "output": "GeneratedClientsTs.gen", - "newLineBehavior": "Auto" - }, - "openApiToCSharpClient": { - "clientBaseClass": null, - "configurationClass": null, - "generateClientClasses": true, - "suppressClientClassesOutput": false, - "generateClientInterfaces": false, - "suppressClientInterfacesOutput": false, - "clientBaseInterface": null, - "injectHttpClient": true, - "disposeHttpClient": true, - "protectedMethods": [], - "generateExceptionClasses": true, - "exceptionClass": "ApiException", - "wrapDtoExceptions": true, - "useHttpClientCreationMethod": false, - "httpClientType": "System.Net.Http.HttpClient", - "useHttpRequestMessageCreationMethod": false, - "useBaseUrl": true, - "generateBaseUrlProperty": true, - "generateSyncMethods": false, - "generatePrepareRequestAndProcessResponseAsAsyncMethods": false, - "exposeJsonSerializerSettings": false, - "clientClassAccessModifier": "public", - "typeAccessModifier": "public", - "propertySetterAccessModifier": "", - "generateNativeRecords": false, - "generateContractsOutput": false, - "contractsNamespace": null, - "contractsOutputFilePath": null, - "parameterDateTimeFormat": "s", - "parameterDateFormat": "yyyy-MM-dd", - "generateUpdateJsonSerializerSettingsMethod": true, - "useRequestAndResponseSerializationSettings": false, - "serializeTypeInformation": false, - "queryNullValue": "", - "className": "{controller}Client", - "operationGenerationMode": "MultipleClientsFromOperationId", - "additionalNamespaceUsages": [], - "additionalContractNamespaceUsages": [], - "generateOptionalParameters": false, - "generateJsonMethods": false, - "enforceFlagEnums": false, - "parameterArrayType": "System.Collections.Generic.IEnumerable", - "parameterDictionaryType": "System.Collections.Generic.IDictionary", - "responseArrayType": "System.Collections.Generic.ICollection", - "responseDictionaryType": "System.Collections.Generic.IDictionary", - "wrapResponses": false, - "wrapResponseMethods": [], - "generateResponseClasses": true, - "responseClass": "SwaggerResponse", - "namespace": "MyNamespace", - "requiredPropertiesMustBeDefined": true, - "dateType": "System.DateTimeOffset", - "jsonConverters": null, - "anyType": "object", - "dateTimeType": "System.DateTimeOffset", - "timeType": "System.TimeSpan", - "timeSpanType": "System.TimeSpan", - "arrayType": "System.Collections.Generic.ICollection", - "arrayInstanceType": "System.Collections.ObjectModel.Collection", - "dictionaryType": "System.Collections.Generic.IDictionary", - "dictionaryInstanceType": "System.Collections.Generic.Dictionary", - "arrayBaseType": "System.Collections.ObjectModel.Collection", - "dictionaryBaseType": "System.Collections.Generic.Dictionary", - "classStyle": "Poco", - "jsonLibrary": "NewtonsoftJson", - "generateDefaultValues": true, - "generateDataAnnotations": true, - "excludedTypeNames": [], - "excludedParameterNames": [], - "handleReferences": false, - "generateImmutableArrayProperties": false, - "generateImmutableDictionaryProperties": false, - "jsonSerializerSettingsTransformationMethod": null, - "inlineNamedArrays": false, - "inlineNamedDictionaries": false, - "inlineNamedTuples": true, - "inlineNamedAny": false, - "generateDtoTypes": true, - "generateOptionalPropertiesAsNullable": false, - "generateNullableReferenceTypes": false, - "templateDirectory": null, - "serviceHost": null, - "serviceSchemes": null, - "output": "GeneratedClientsCs.gen", - "newLineBehavior": "Auto" - }, - "openApiToCSharpController": { - "controllerBaseClass": null, - "controllerStyle": "Partial", - "controllerTarget": "AspNetCore", - "useCancellationToken": false, - "useActionResultType": false, - "generateModelValidationAttributes": false, - "routeNamingStrategy": "None", - "basePath": null, - "className": "{controller}", - "operationGenerationMode": "MultipleClientsFromOperationId", - "additionalNamespaceUsages": [], - "additionalContractNamespaceUsages": [], - "generateOptionalParameters": false, - "generateJsonMethods": false, - "enforceFlagEnums": false, - "parameterArrayType": "System.Collections.Generic.IEnumerable", - "parameterDictionaryType": "System.Collections.Generic.IDictionary", - "responseArrayType": "System.Collections.Generic.ICollection", - "responseDictionaryType": "System.Collections.Generic.IDictionary", - "wrapResponses": false, - "wrapResponseMethods": [], - "generateResponseClasses": true, - "responseClass": "SwaggerResponse", - "namespace": "MyNamespace", - "requiredPropertiesMustBeDefined": true, - "dateType": "System.DateTimeOffset", - "jsonConverters": null, - "anyType": "object", - "dateTimeType": "System.DateTimeOffset", - "timeType": "System.TimeSpan", - "timeSpanType": "System.TimeSpan", - "arrayType": "System.Collections.Generic.List", - "arrayInstanceType": "System.Collections.Generic.List", - "dictionaryType": "System.Collections.Generic.IDictionary", - "dictionaryInstanceType": "System.Collections.Generic.Dictionary", - "arrayBaseType": "System.Collections.ObjectModel.Collection", - "dictionaryBaseType": "System.Collections.Generic.Dictionary", - "classStyle": "Poco", - "jsonLibrary": "NewtonsoftJson", - "generateDefaultValues": true, - "generateDataAnnotations": true, - "excludedTypeNames": [], - "excludedParameterNames": [], - "handleReferences": false, - "generateImmutableArrayProperties": false, - "generateImmutableDictionaryProperties": false, - "jsonSerializerSettingsTransformationMethod": null, - "inlineNamedArrays": false, - "inlineNamedDictionaries": false, - "inlineNamedTuples": true, - "inlineNamedAny": false, - "generateDtoTypes": true, - "generateOptionalPropertiesAsNullable": false, - "generateNullableReferenceTypes": false, - "templateDirectory": null, - "serviceHost": null, - "serviceSchemes": null, - "output": "GeneratedControllersCs.gen", - "newLineBehavior": "Auto" - } - } -} \ No newline at end of file diff --git a/src/NSwag.Sample.NET70Minimal/openapi.json b/src/NSwag.Sample.NET70Minimal/openapi.json deleted file mode 100644 index 75a4b7c1a0..0000000000 --- a/src/NSwag.Sample.NET70Minimal/openapi.json +++ /dev/null @@ -1,162 +0,0 @@ -{ - "x-generator": "NSwag", - "openapi": "3.0.0", - "info": { - "title": "Minimal API", - "version": "v1" - }, - "paths": { - "/": { - "get": { - "tags": [ - "General" - ], - "operationId": "Get", - "responses": { - "200": { - "description": "", - "content": { - "application/json": { - "schema": { - "type": "string" - } - } - } - } - } - } - }, - "/sum/{a}/{b}": { - "get": { - "tags": [ - "Calculator" - ], - "operationId": "CalculateSum", - "parameters": [ - { - "name": "a", - "in": "path", - "required": true, - "schema": { - "type": "integer", - "format": "int32" - }, - "x-position": 1 - }, - { - "name": "b", - "in": "path", - "required": true, - "schema": { - "type": "integer", - "format": "int32" - }, - "x-position": 2 - } - ], - "responses": { - "200": { - "description": "", - "content": { - "application/json": { - "schema": { - "type": "integer", - "format": "int32" - } - } - } - } - } - } - }, - "/abs({a})": { - "get": { - "tags": [ - "Calculator" - ], - "operationId": "AbsoluteValue", - "parameters": [ - { - "name": "a", - "in": "path", - "required": true, - "schema": { - "type": "integer", - "format": "int32" - }, - "x-position": 1 - } - ], - "responses": { - "200": { - "description": "", - "content": { - "application/json": { - "schema": { - "type": "integer", - "format": "int32" - } - } - } - } - } - } - }, - "/id:{id}": { - "get": { - "tags": [ - "Calculator" - ], - "description": "Hello world!", - "operationId": "Identity", - "parameters": [ - { - "name": "id", - "in": "path", - "required": true, - "schema": { - "type": "integer", - "format": "int32" - }, - "x-position": 1 - } - ], - "responses": { - "200": { - "description": "", - "content": { - "application/json": { - "schema": { - "type": "integer", - "format": "int32" - } - } - } - } - } - } - }, - "/examples": { - "get": { - "tags": [ - "Example" - ], - "operationId": "Example_Get", - "responses": { - "200": { - "description": "", - "content": { - "application/octet-stream": { - "schema": { - "type": "string", - "format": "binary" - } - } - } - } - } - } - } - }, - "components": {} -} \ No newline at end of file diff --git a/src/NSwag.Sample.NET80/Properties/launchSettings.json b/src/NSwag.Sample.NET80/Properties/launchSettings.json index b9ab13135c..ffc8f760b0 100644 --- a/src/NSwag.Sample.NET80/Properties/launchSettings.json +++ b/src/NSwag.Sample.NET80/Properties/launchSettings.json @@ -1,7 +1,7 @@ { "$schema": "http://json.schemastore.org/launchsettings.json", "profiles": { - "NSwag.Sample.NET70": { + "NSwag.Sample.NET80": { "commandName": "Project", "launchBrowser": true, "launchUrl": "swagger", diff --git a/src/NSwag.sln b/src/NSwag.sln index 5071d82296..bc33f5f241 100644 --- a/src/NSwag.sln +++ b/src/NSwag.sln @@ -121,10 +121,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NSwag.Sample.NET60", "NSwag EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NSwag.Sample.NET60Minimal", "NSwag.Sample.NET60Minimal\NSwag.Sample.NET60Minimal.csproj", "{24693FBC-445E-4360-A1E8-B6F136C563FB}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NSwag.Sample.NET70", "NSwag.Sample.NET70\NSwag.Sample.NET70.csproj", "{15221E25-4D06-42DB-B3F1-CC9EE721FBAA}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NSwag.Sample.NET70Minimal", "NSwag.Sample.NET70Minimal\NSwag.Sample.NET70Minimal.csproj", "{6AE2AAD7-8093-46F4-88BD-CB7439A84EED}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NSwag.ConsoleCore.Tests", "NSwag.ConsoleCore.Tests\NSwag.ConsoleCore.Tests.csproj", "{CF6112E5-20FD-4B22-A6C0-20AF6B3396F3}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NSwag.Sample.NET80", "NSwag.Sample.NET80\NSwag.Sample.NET80.csproj", "{2A166077-2189-4376-A38B-8E362A319028}" @@ -503,30 +499,6 @@ Global {24693FBC-445E-4360-A1E8-B6F136C563FB}.Release|x64.Build.0 = Release|Any CPU {24693FBC-445E-4360-A1E8-B6F136C563FB}.Release|x86.ActiveCfg = Release|Any CPU {24693FBC-445E-4360-A1E8-B6F136C563FB}.Release|x86.Build.0 = Release|Any CPU - {15221E25-4D06-42DB-B3F1-CC9EE721FBAA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {15221E25-4D06-42DB-B3F1-CC9EE721FBAA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {15221E25-4D06-42DB-B3F1-CC9EE721FBAA}.Debug|x64.ActiveCfg = Debug|Any CPU - {15221E25-4D06-42DB-B3F1-CC9EE721FBAA}.Debug|x64.Build.0 = Debug|Any CPU - {15221E25-4D06-42DB-B3F1-CC9EE721FBAA}.Debug|x86.ActiveCfg = Debug|Any CPU - {15221E25-4D06-42DB-B3F1-CC9EE721FBAA}.Debug|x86.Build.0 = Debug|Any CPU - {15221E25-4D06-42DB-B3F1-CC9EE721FBAA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {15221E25-4D06-42DB-B3F1-CC9EE721FBAA}.Release|Any CPU.Build.0 = Release|Any CPU - {15221E25-4D06-42DB-B3F1-CC9EE721FBAA}.Release|x64.ActiveCfg = Release|Any CPU - {15221E25-4D06-42DB-B3F1-CC9EE721FBAA}.Release|x64.Build.0 = Release|Any CPU - {15221E25-4D06-42DB-B3F1-CC9EE721FBAA}.Release|x86.ActiveCfg = Release|Any CPU - {15221E25-4D06-42DB-B3F1-CC9EE721FBAA}.Release|x86.Build.0 = Release|Any CPU - {6AE2AAD7-8093-46F4-88BD-CB7439A84EED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6AE2AAD7-8093-46F4-88BD-CB7439A84EED}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6AE2AAD7-8093-46F4-88BD-CB7439A84EED}.Debug|x64.ActiveCfg = Debug|Any CPU - {6AE2AAD7-8093-46F4-88BD-CB7439A84EED}.Debug|x64.Build.0 = Debug|Any CPU - {6AE2AAD7-8093-46F4-88BD-CB7439A84EED}.Debug|x86.ActiveCfg = Debug|Any CPU - {6AE2AAD7-8093-46F4-88BD-CB7439A84EED}.Debug|x86.Build.0 = Debug|Any CPU - {6AE2AAD7-8093-46F4-88BD-CB7439A84EED}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6AE2AAD7-8093-46F4-88BD-CB7439A84EED}.Release|Any CPU.Build.0 = Release|Any CPU - {6AE2AAD7-8093-46F4-88BD-CB7439A84EED}.Release|x64.ActiveCfg = Release|Any CPU - {6AE2AAD7-8093-46F4-88BD-CB7439A84EED}.Release|x64.Build.0 = Release|Any CPU - {6AE2AAD7-8093-46F4-88BD-CB7439A84EED}.Release|x86.ActiveCfg = Release|Any CPU - {6AE2AAD7-8093-46F4-88BD-CB7439A84EED}.Release|x86.Build.0 = Release|Any CPU {CF6112E5-20FD-4B22-A6C0-20AF6B3396F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {CF6112E5-20FD-4B22-A6C0-20AF6B3396F3}.Debug|Any CPU.Build.0 = Debug|Any CPU {CF6112E5-20FD-4B22-A6C0-20AF6B3396F3}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -603,8 +575,6 @@ Global {AC3D8125-AE21-49FC-A217-D96C7B585FF9} = {6F5E4FDF-0A82-42D5-94AC-A9CD43CC931D} {DE82965A-6935-43E0-A9A1-F3F35B4487EB} = {D8CC0D1C-8DAC-49FE-AA78-C028DC124DD5} {24693FBC-445E-4360-A1E8-B6F136C563FB} = {D8CC0D1C-8DAC-49FE-AA78-C028DC124DD5} - {15221E25-4D06-42DB-B3F1-CC9EE721FBAA} = {D8CC0D1C-8DAC-49FE-AA78-C028DC124DD5} - {6AE2AAD7-8093-46F4-88BD-CB7439A84EED} = {D8CC0D1C-8DAC-49FE-AA78-C028DC124DD5} {CF6112E5-20FD-4B22-A6C0-20AF6B3396F3} = {F0F26A35-C4B6-42D0-A1DF-98CA46A5C560} {2A166077-2189-4376-A38B-8E362A319028} = {D8CC0D1C-8DAC-49FE-AA78-C028DC124DD5} {F0569608-BD55-4316-94F0-E85A14D7FE14} = {D8CC0D1C-8DAC-49FE-AA78-C028DC124DD5} diff --git a/src/NSwagStudio/nswag.cmd b/src/NSwagStudio/nswag.cmd index 174d06928a..ed4321a24c 100644 --- a/src/NSwagStudio/nswag.cmd +++ b/src/NSwagStudio/nswag.cmd @@ -11,11 +11,6 @@ IF NOT "%args:/runtime:net60=%" == "%args%" ( GOTO end ) -IF NOT "%args:/runtime:net70=%" == "%args%" ( - dotnet "%~dp0/Net70/dotnet-nswag.dll" %* - GOTO end -) - IF NOT "%args:/runtime:net80=%" == "%args%" ( dotnet "%~dp0/Net80/dotnet-nswag.dll" %* GOTO end