Skip to content

Swashbuckle vs. NSwag in ASP.NET Core: .NET 10, built-in OpenAPI baseline, benchmark fixes - #2280

Open
vladimir-pecanac-main wants to merge 1 commit into
CodeMazeBlog:mainfrom
vladimir-pecanac-main:seo/89433-aspnetcore-swashbuckle-vs-nswag
Open

vladimir-pecanac-main wants to merge 1 commit into
CodeMazeBlog:mainfrom
vladimir-pecanac-main:seo/89433-aspnetcore-swashbuckle-vs-nswag

Conversation

@vladimir-pecanac-main

Copy link
Copy Markdown
Collaborator

Sample update for the article "Swashbuckle vs. NSwag in ASP.NET Core" (https://code-maze.com/aspnetcore-swashbuckle-vs-nswag/).

Changes, all inside dotnet-client-libraries/SwashbuckleVsNSwag:

  • Every project moves from net7.0 to net10.0.
  • New SwashbuckleVsNSwag.BuiltIn project: the built-in generator (AddOpenApi(), MapOpenApi() for JSON and MapOpenApi("/openapi/{documentName}.yaml") for YAML) with Swagger UI from Swashbuckle.AspNetCore.SwaggerUi pointed at /openapi/v1.json, reusing the Models and Repositories projects and the same three controllers.
  • Swashbuckle project: Swashbuckle.AspNetCore 6.4.0 to 10.3.0. Microsoft.OpenApi 2.x moved OpenApiInfo, so using Microsoft.OpenApi.Models; becomes using Microsoft.OpenApi; (without it the build fails with CS0234).
  • NSwag project: NSwag.AspNetCore 13.19.0 to 14.7.1. Adds UseSwaggerUi (the NSwag 14 name; UseSwaggerUi3 was removed) at /swagger; ReDoc moves to /redoc because both default to /swagger.
  • Benchmark: the URLs are fixed first. GET asked for /customer/{id} while the controller takes customerId as a query parameter, and the host's trailing slash plus "/customer" produced //customer, which also returns 404 for POST. Then the missing await on NSwag_GetResponse is added, and POST calls EnsureSuccessStatusCode so a failing request can no longer be timed. Console.ReadKey removed so the runner exits on its own.
  • Test projects: SwashbuckleVsNSwag.Swachbuckle.Tests renamed to SwashbuckleVsNSwag.Swashbuckle.Tests, the six *ConsollerTest files and classes renamed to *ControllerTest, and the Swashbuckle tests use their own namespace instead of the NSwag one.
  • SwashbuckleVsNSwagTests did not compile (a field declaration with no name) and was not in the solution. It is repaired, joins the solution and now tests the BuiltIn project with WebApplicationFactory: JSON document 200, YAML document 200, Swagger UI 200.
  • The bare SwashbuckleVsNSwag template project (WeatherForecast, no OpenAPI code, referenced by nothing, not in the solution) is removed.
  • README added: what each project shows and how to run the benchmark (both apps must be running on their https profiles).

Package versions, re-queried on NuGet on 2026-10-10 (latest listed stable):

  • Microsoft.AspNetCore.OpenApi 10.0.12
  • Swashbuckle.AspNetCore 10.3.0
  • Swashbuckle.AspNetCore.SwaggerUi 10.3.0
  • NSwag.AspNetCore 14.7.1
  • BenchmarkDotNet 0.15.8
  • Microsoft.NET.Test.Sdk 18.10.1
  • NUnit 5.0.0
  • NUnit3TestAdapter 6.3.1
  • NUnit.Analyzers 4.15.0
  • coverlet.collector 10.1.0
  • Microsoft.AspNetCore.Mvc.Testing 10.0.12
  • Moq 4.18.4 (held at or below 4.18.4 by policy)

Local results on SDK 10.0.302 / runtime 10.0.10: dotnet build -c Release 0 errors, 2 warnings (pre-existing CS8618 in the Models project); dotnet test 15 passed, 0 failed (6 + 6 + 3); dotnet list package --vulnerable --include-transitive reports no vulnerable packages in any project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant