From 603d3c81cab7bc1774b1d991ae619b9af45b932e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Grb=C3=A1lik?= Date: Fri, 1 Dec 2023 21:48:52 +0100 Subject: [PATCH 1/6] Preview package of nswag 14 --- samples/NSwagWithExamples/Startup.cs | 2 +- src/NSwag.Examples/ExamplesConverter.cs | 10 +++++++--- src/NSwag.Examples/NSwag.Examples.csproj | 6 +++--- src/NSwag.Examples/RequestBodyExampleProcessor.cs | 3 ++- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/samples/NSwagWithExamples/Startup.cs b/samples/NSwagWithExamples/Startup.cs index f454274..46919c8 100644 --- a/samples/NSwagWithExamples/Startup.cs +++ b/samples/NSwagWithExamples/Startup.cs @@ -42,7 +42,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { app.UseAuthorization(); app.UseOpenApi(); - app.UseSwaggerUi3(); + app.UseSwaggerUi(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); } diff --git a/src/NSwag.Examples/ExamplesConverter.cs b/src/NSwag.Examples/ExamplesConverter.cs index 90e7cc0..6b52010 100644 --- a/src/NSwag.Examples/ExamplesConverter.cs +++ b/src/NSwag.Examples/ExamplesConverter.cs @@ -1,21 +1,25 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Text.Json; using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using JsonSerializer = System.Text.Json.JsonSerializer; namespace NSwag.Examples; internal class ExamplesConverter { - private readonly JsonSerializerSettings _jsonSerializerSettings; + private readonly JsonSerializerSettings? _jsonSerializerSettings; + private readonly JsonSerializerOptions? _systemTextJsonSettings; - internal ExamplesConverter(JsonSerializerSettings jsonSerializerSettings) { + internal ExamplesConverter(JsonSerializerSettings? jsonSerializerSettings, JsonSerializerOptions? systemTextJsonSettings) { _jsonSerializerSettings = jsonSerializerSettings; + _systemTextJsonSettings = systemTextJsonSettings; } private object SerializeExampleJson(object value) { - var serializeObject = JsonConvert.SerializeObject(value, _jsonSerializerSettings); + var serializeObject = _jsonSerializerSettings is not null ? JsonConvert.SerializeObject(value, _jsonSerializerSettings) : JsonSerializer.Serialize(value, _systemTextJsonSettings); return JToken.Parse(serializeObject); } diff --git a/src/NSwag.Examples/NSwag.Examples.csproj b/src/NSwag.Examples/NSwag.Examples.csproj index c3e8578..a4abb1d 100644 --- a/src/NSwag.Examples/NSwag.Examples.csproj +++ b/src/NSwag.Examples/NSwag.Examples.csproj @@ -1,8 +1,8 @@  - netstandard2.0;net5.0;net6.0;net7.0 - 1.0.11 + netstandard2.0;net5.0;net6.0;net7.0;net8.0 + 1.0.12-preview-01 Vaclav Novotny https://github.com/vaclavnovotny/NSwag.Examples https://github.com/vaclavnovotny/NSwag.Examples @@ -16,6 +16,6 @@ - + \ No newline at end of file diff --git a/src/NSwag.Examples/RequestBodyExampleProcessor.cs b/src/NSwag.Examples/RequestBodyExampleProcessor.cs index 4d68968..3b2b22a 100644 --- a/src/NSwag.Examples/RequestBodyExampleProcessor.cs +++ b/src/NSwag.Examples/RequestBodyExampleProcessor.cs @@ -5,6 +5,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; +using NSwag.Generation.AspNetCore; using NSwag.Generation.Processors; using NSwag.Generation.Processors.Contexts; @@ -23,7 +24,7 @@ public RequestBodyExampleProcessor(IServiceProvider serviceProvider) { } public bool Process(OperationProcessorContext context) { - _examplesConverter = new ExamplesConverter(context.Settings.SerializerSettings); + _examplesConverter = new ExamplesConverter(AspNetCoreOpenApiDocumentGenerator.GetJsonSerializerSettings(_serviceProvider), AspNetCoreOpenApiDocumentGenerator.GetSystemTextJsonSettings(_serviceProvider)); var exampleProvider = _serviceProvider.GetRequiredService(); SetRequestExamples(context, exampleProvider); SetResponseExamples(context, exampleProvider); From ac0df64bdedbb3fdc5d32a91535c33b9ee80815a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Grb=C3=A1lik?= Date: Fri, 1 Dec 2023 21:59:32 +0100 Subject: [PATCH 2/6] update github actions to support dotnet 8 --- .github/workflows/build-publish.yml | 2 +- .github/workflows/build-samples.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-publish.yml b/.github/workflows/build-publish.yml index 3fb14fa..5f3facd 100644 --- a/.github/workflows/build-publish.yml +++ b/.github/workflows/build-publish.yml @@ -18,7 +18,7 @@ jobs: - name: Setup .NET Core uses: actions/setup-dotnet@v1 with: - dotnet-version: 7.0.x + dotnet-version: 8.0.x - name: Install dependencies run: dotnet restore - name: Build diff --git a/.github/workflows/build-samples.yml b/.github/workflows/build-samples.yml index 385c320..a5c5578 100644 --- a/.github/workflows/build-samples.yml +++ b/.github/workflows/build-samples.yml @@ -20,7 +20,7 @@ jobs: - name: Setup .NET Core uses: actions/setup-dotnet@v1 with: - dotnet-version: 7.0.x + dotnet-version: 8.0.x - name: Install dependencies run: dotnet restore - name: Build From 6118ee88977da04b510baf190a199f8e0b403723 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Novotn=C3=BD=20V=C3=A1clav?= Date: Fri, 1 Dec 2023 22:21:39 +0100 Subject: [PATCH 3/6] empty From afac4dcb368e534ed99faa18d864ce6843a25400 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Novotn=C3=BD=20V=C3=A1clav?= Date: Fri, 1 Dec 2023 22:22:57 +0100 Subject: [PATCH 4/6] Fix --- .github/workflows/build-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-publish.yml b/.github/workflows/build-publish.yml index a085dc9..9bbbbfb 100644 --- a/.github/workflows/build-publish.yml +++ b/.github/workflows/build-publish.yml @@ -2,7 +2,7 @@ name: Build and Publish on: push: - branches: [ main, prelease ] + branches: [ main, prerelease ] defaults: run: From 5f04eec78a8c9e84b0db6c9acaf7b1ef7c405860 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Novotn=C3=BD=20V=C3=A1clav?= Date: Mon, 19 Feb 2024 15:54:55 +0100 Subject: [PATCH 5/6] Updated NSwag to production version --- src/NSwag.Examples/NSwag.Examples.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NSwag.Examples/NSwag.Examples.csproj b/src/NSwag.Examples/NSwag.Examples.csproj index a4abb1d..598a35e 100644 --- a/src/NSwag.Examples/NSwag.Examples.csproj +++ b/src/NSwag.Examples/NSwag.Examples.csproj @@ -16,6 +16,6 @@ - + \ No newline at end of file From e9f0cc380612c4f1d4d208304e4bffcf0927242c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Novotn=C3=BD=20V=C3=A1clav?= Date: Mon, 19 Feb 2024 15:56:13 +0100 Subject: [PATCH 6/6] Update .gitignore Updated gitignore to ignore Rider properties --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index dfcfd56..c95cf42 100644 --- a/.gitignore +++ b/.gitignore @@ -33,6 +33,7 @@ bld/ # Visual Studio 2015/2017 cache/options directory .vs/ +.idea/ # Uncomment if you have tasks that create the project's static files in wwwroot #wwwroot/