asp.net core webapi集成swagger

工具为:vs2019

依赖项:通过NuGet 安装:Swashbuckle.AspNetCore 4.0.1

StartUp配置项如下:

using aspnetcorehellowould.Filter;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Swashbuckle.AspNetCore.Swagger;
using System.IO;

namespace aspnetcorehellowould
{
    public class Startup
    {
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        public IConfiguration Configuration { get; }

        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc(Options =>
            {
                Options.Filters.Add();
            }).SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

            //注册Swagger生成器,定义一个和多个Swagger 文档
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new Info
                {
                    Version = "v1",
                    Title = "chenchangzhu's API",
                    Description = "学生管理学系统 web api",
                    TermsOfService = "大神在此,全给我站住唱征服",
                    Contact = new Contact
                    {
                        Name = "dashen",
                        Email = "[email protected]",
                        Url = "http://www.baid

你可能感兴趣的:(c#,asp.net,core,swagger)