I want to add swagger on a new web application created with .Net Core 3.1. I receive an error on the following line:
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
});
'IApplicationBuilder' does not contain a definition for 'UseSwaggerUI' and no accessible extension method 'UseSwaggerUI' accepting a first argument of type 'IApplicationBuilder' could be found (are you missing a using directive or an assembly reference?)
even though I have installed Swagger as in the MSDN example.
This is the content of swagger package that came from NuGet:
I have the following usings:
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.AspNetCore.SpaServices.ReactDevelopmentServer;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Options;
using Microsoft.OpenApi.Models;
What am I missing?
The NuGeT-package Swashbuckle.AspNetCore.Swagger only provides the JSON-endpoints of the documentation.
To actually have the UI as well, you must also install the corresponding package Swashbuckle.AspNetCore.SwaggerUi
Install-Package Swashbuckle.AspNetCore.SwaggerUi -Version 5.6.3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With