Fix Swagger UI configuration to use NSwag instead of Swashbuckle#36929
Fix Swagger UI configuration to use NSwag instead of Swashbuckle#36929wadepickett merged 2 commits intodotnet:mainfrom
Conversation
The tutorial code used Swashbuckle's UseSwaggerUI() method, but the project already has NSwag.AspNetCore installed. This caused a compilation error since the method wasn't available.
hooseinsaid
left a comment
There was a problem hiding this comment.
Great fix. The changes correctly replace the Swashbuckle-specific configuration with NSwag equivalents, resolving the compilation issue and aligning with the project’s existing setup.
The implementation is clean and consistent, and the Swagger UI is now working as expected.
|
@copilot
|
|
@Astroa7m, thanks so much for pointing out this issue and correcting it. Greatly appreciated! |
There was a problem hiding this comment.
Pull request overview
Updates the ASP.NET Core 9.x first-mongo-app tutorial sample to use NSwag’s Swagger UI middleware (already referenced by the sample) instead of Swashbuckle’s UseSwaggerUI, resolving the reported compilation error and aligning with the repo’s modern OpenAPI pattern.
Changes:
- Replace
UseSwaggerUIwith NSwagUseSwaggerUi. - Update UI configuration from
SwaggerEndpoint(...)toDocumentPath = "/openapi/v1.json"to matchMapOpenApi()output.
Removed Swashbuckle.AspNetCore package reference since it is not used for the 9.x version of this sample.
|
@Astroa7m , I can approve and merge after policy agreement addressed above. Thanks again for the fix! |
wadepickett
left a comment
There was a problem hiding this comment.
Approved and will be merged when Contributor License Agreement(CLA) is signed off.
|
@dotnet-policy-service agree
@dotnet-policy-service agree |
|
Great work, thanks!!! Will merge to live today. |
The tutorial code used Swashbuckle's UseSwaggerUI() method, but the project already has NSwag.AspNetCore installed.
This causes a compilation error: "'WebApplication' does not contain a definition for 'UseSwaggerUI'". The code should use NSwag's UseSwaggerUi() instead.