Swagger and .Net Core 3 integration

swagger net core 3
ioperationfilter swagger .net core 3
asp.net core swagger not working
swaggerresponse .net core
swashbuckle.aspnetcore.swagger.info not found
swashbuckle openapi 3
swashbuckle vs nswag
swashbuckle nuget

I'm documenting my web api using swagger. However when I run my Project, it throws an error "Method not found: 'Void Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware...".

I only followed the tutorials from youtube. Not sure what is the cause of error.

My project is .Net Core 3.

 internal class SwaggerConfiguration
{
    public static void Configure(IServiceCollection services)
    {
        services.AddSwaggerGen(c =>
        {
            c.SwaggerDoc("v1", new Info() { Title = "Sample Portal API", Version = "1.0.0.0" });
        });
    }

    public static void Configure(IConfiguration configuration, IApplicationBuilder app)
    {
        var swaggerOptions = new SwaggerOptions(configuration).Bind();

        app.UseSwagger(options =>
        {
            options.RouteTemplate = swaggerOptions.Route;
        });


        app.UseSwaggerUI(options =>
        {
            options.SwaggerEndpoint(swaggerOptions.UIEndpoint, swaggerOptions.Description);
        });
    }
    private class SwaggerOptions
    {
        IConfiguration _configuration;
        public SwaggerOptions(IConfiguration configuration)
        {
            _configuration = configuration;
        }
        public string Route { get; set; }
        public string Description { get; set; }
        public string UIEndpoint { get; set; }

        public SwaggerOptions Bind()
        {
            _configuration.GetSection(nameof(SwaggerOptions)).Bind(this);
            return this;
        }
    }
}

this is my startup class

public void ConfigureServices(IServiceCollection services)
    {
        services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_3_0);

        SwaggerConfiguration.Configure(services);
    }

    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
        }

        SwaggerConfiguration.Configure(Configuration, app);

        app.UseHttpsRedirection();

        app.UseRouting();
        app.UseAuthorization();


        app.UseEndpoints(endpoints =>
        {
            endpoints.MapControllers();
        });

    }

Can someone shed a light, thanks in advance

I was able to get it going by following this link (updated 8/20/2019 as of this writing):

Get started with Swashbuckle and ASP.NET Core

Take a look at their GitHub link too:

AspNetCore.Docs

ASP.NET Core Web API help pages with Swagger / OpenAPI , NET Core web API help pages with Swagger / OpenAPI is another open source project for generating Swagger documents and integrating Swagger UI or ReDoc into ASP. For a version 3 example, see Petstore example. Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information. Learn more Swagger and .Net Core 3 integration

Here is the least amount of step in order to add the swagger to your project.

  1. Run below command at PowerShell
Install-Package Swashbuckle.AspNetCore -Version 5.0.0-rc4
  1. In the Startup class, add this reference ''' using Microsoft.OpenApi.Models; '''
  2. Add below to ConfigureService method in the startup class:
services.AddSwaggerGen(c =>
    {
        c.SwaggerDoc("v1", new OpenApiInfo { Title = "My API", Version = "v1" });
    });
  1. Add below to the Configure method in the startup.cs
// Enable middleware to serve generated Swagger as a JSON endpoint.
    app.UseSwagger();

    // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
    // specifying the Swagger JSON endpoint.
    app.UseSwaggerUI(c =>
    {
        c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
    })
  1. You can access the swagger page at http://localhost:port/swagger

Swagger and .Net Core 3 integration, I was able to get it going by following this link (updated 8/20/2019 as of this writing):. Get started with Swashbuckle and ASP.NET Core. Take a  Swagger UI also helps in maintaining well up-to-date documentation of the APIs. For this post, I have used Visual Studio 2019 and ASP.NET Core 3.1 Web API project template. Step 1: Create an ASP.NET Core Web API project in Visual Studio 2019. Step 2: Select the API as the project template. Step 3: Install the NuGet Package -Swashbuckle.AspNetCore. We may also run below command to install this NuGet package from the Package Manager Console.

I had this issue and all I needed to do is to update Nuget Package Swashbuckle.AspNetCore to version 5.4.1 or install it if you don't have it.

Add Swagger to ASP.NET Core 3.0 Web API, Add Swagger to Web Api Core 3 project. From the Package Manager Console window click on View > Other Windows > Package Manager  In this tutorial, we are going to cover how to add swagger to ASP.NET Core 3.0 Web API. Swagger is an api testing tool and it is very easy to use swagger with ASP.NET Core 3.0 Web API. We can test our APIs using swagger. Swagger is an Unordered List of representation of RESTful API.

ASP.NET Core 3.1 Web API and Swagger, NET Core and the use of Swagger. Swagger is a GUI interface to communicate with a Web API. SQLExpress;Initial Catalog=YourDB;Integrated Security=True";​; SqlConnection conn = null; Section 3 is the Swagger part. Add Swagger (OpenAPI) API Documentation in ASP.NET Core 3.1 Swagger or OpenAPI describes the standards and specifications for the RESTFul API description. These specifications are an attempt to create a universal and language agnostic description for describing the REST API.

How To Integrate Swagger In an .NET Core Web API, Swagger helps developers design, build, document, and consume RESTful Web API. This blog shows how you can integrate Swagger in your . A step by step guide to add swashbuckle to the ASP.NET Core Web API to generate the Swagger UI. This blog helps to create swagger in Web API.

Configuring and Using Swagger UI in ASP.NET Core Web API , In this article, we are going to learn how to integrate the Swagger UI in NET Core 3 Web API. Integrating Swagger UI into our Applications. .net core 2.* has swagger support. one of the goals of asp.net core 3.0, is to allow better swagger integration. but asp.net core 3.0 is still pre-release, the should come in later releases.

Comments
  • great thanks! it works! so swagger for .Net Core 3 is still on prebuild.