.net 6.0 : How to generate Swagger.json file on build in .net 6.0?

Viewed 80

I want to generate Swagger.Json file on build and use it in API gateway to configure the endpoints.

I have tried following steps but its not working.

Create a tool manifest:

dotnet new tool-manifest

Install the Swashbuckle CLI tool and add it to the local manifest file: But this step fails

dotnet tool install --version 6.4.0 Swashbuckle.AspNetCore.Cli

Error :

 NU1202: Package Swashbuckle.AspNetCore.Cli 6.4.0 is not compatible with net6.0 (.NETCoreApp,Version=v6.0). Package Swashbuckle.AspNetCore.Cli 6.4.0 supports:
  - net5.0 (.NETCoreApp,Version=v5.0) / any
  - net6.0 (.NETCoreApp,Version=v6.0) / any
  - netcoreapp2.1 (.NETCoreApp,Version=v2.1) / any
  - netcoreapp3.0 (.NETCoreApp,Version=v3.0) / any
NU1212: Invalid project-package combination for Swashbuckle.AspNetCore.Cli 6.4.0. DotnetToolReference project style can only contain references of the DotnetTool type 
NU1212: Invalid project-package combination for Swashbuckle.AspNetCore.Cli 6.4.0. DotnetToolReference project style can only contain references of the DotnetTool type 
Package 'Swashbuckle.AspNetCore.Cli 6.4.0' has a package type 'DotnetTool' that is not supported by project 'WebApi'.
0 Answers
Related