DrArqon
DrArqon

Reputation: 153

Swagger (Swashbuckle) on ASP.NET Core MVC targeting .Net Framework 4.6.1

I am migrating WebApi2 project to MVC6. As we have other dependencies written in .NET 4.6.1 we need to target same version.

"frameworks": {
"net461": {}}

I have added dependencies:

"Swashbuckle": "5.3.2",

But the problem is that there is no way to hook up/register it to the ASP.NET Core MVC.

Is there any way to do it?

Upvotes: 0

Views: 4463

Answers (3)

Praveen P K
Praveen P K

Reputation: 79

The Swashbuckle version that is compatible with .Net Framework 4.6. is 5.6.0

Upvotes: 0

Set
Set

Reputation: 49789

With ASP.NET Core you should use the this port of Swashbuckle https://github.com/domaindrivendev/Ahoy

Than you will Add/Use extensions methods:

public void ConfigureServices(IServiceCollection services)
{
    ... Configure MVC services ...

    // Inject an implementation of ISwaggerProvider with defaulted   settings applied
    services.AddSwaggerGen();
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
    ... Enable MVC middleware ...

    // Enable middleware to serve generated Swagger as a JSON endpoint
    app.UseSwagger();

    // Enable middleware to serve swagger-ui assets (HTML, JS, CSS etc.)
    app.UseSwaggerUi();
}

Upvotes: 5

Tseng
Tseng

Reputation: 64229

The 5.x version of Swashbuckle do not support ASP.NET Core MVC. You have to use the new Swashbuckle 6.x version which has support for ASP.NET Core.

The only version which supports ASP.NET Core 1.0 RTM is 6.0.0-beta901.

So you need to add this to your project.json file

"Swashbuckle": "6.0.0-beta901"

Upvotes: 2

Related Questions