ASP.NET Core 5.0 Web API与开放源代码项目 Swashbuckle.AspNetCore 的维护人员合作,ASP.NET Core API 模板包含对 Swashbuckle 的 NuGet 依赖关系。Swashbuckle 是一个常用的开放源代码 NuGet 包,可动态发出 OpenAPI 文档。Swashbuckle 通过 API 控制器进行自检并在运行时或在生成时使用 Swashbuckle CLI 生成 OpenAPI 文档来实现此目的。
<Project Sdk="Microsoft.NET.Sdk.Web"> <PropertyGroup> <TargetFramework>net5.0</TargetFramework> </PropertyGroup> <ItemGroup> <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.0" NoWarn="NU1605" /> <PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="5.0.0" NoWarn="NU1605" /> <PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" /> </ItemGroup></Project>
using Microsoft.AspNetCore.Builder;using Microsoft.AspNetCore.Hosting;using Microsoft.AspNetCore.HttpsPolicy;using Microsoft.AspNetCore.Mvc;using Microsoft.Extensions.Configuration;using Microsoft.Extensions.DependencyInjection;using Microsoft.Extensions.Hosting;using Microsoft.Extensions.Logging;using Microsoft.OpenApi.Models;using System;using System.Collections.Generic;using System.Linq;using System.Threading.Tasks;namespace WebApplication40{ 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.AddControllers(); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "WebApplication40", Version = "v1" }); }); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseSwagger(); app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "WebApplication40 v1")); } app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); } }}
在 ASP.NET Core 5.0 中,Web API 模板默认启用 OpenAPI 支持。 若要禁用 OpenAPI,请执行以下操作:
通过命令行:
.NET Core CLI
dotnet new webapi --no-openapi true
通过 Visual Studio:取消选中"启用 OpenAPI 支持"。
原文转载:http://www.shaoqun.com/a/489784.html
阿里巴巴 批发:https://www.ikjzd.com/w/1084
telegram:https://www.ikjzd.com/w/1734
飞书互动:https://www.ikjzd.com/w/1319.html
ASP.NETCore5.0WebAPI与开放源代码项目Swashbuckle.AspNetCore的维护人员合作,ASP.NETCoreAPI模板包含对Swashbuckle的NuGet依赖关系。Swashbuckle是一个常用的开放源代码NuGet包,可动态发出OpenAPI文档。Swashbuckle通过API控制器进行自检并在运行时或在生成时使用SwashbuckleCLI生成OpenAP
黄劲:https://www.ikjzd.com/w/2426
easy buy:https://www.ikjzd.com/w/2162
Boutiqaat:https://www.ikjzd.com/w/1664
春节马尔代夫旅游必选岛屿-尼亚玛岛:http://tour.shaoqun.com/a/70379.html
香港哪里买手表便宜,香港买手表攻略(地址、品牌及贴士):http://tour.shaoqun.com/a/73751.html
没有评论:
发表评论