Skip to content
标签
欢迎扫码关注公众号

在 .NET Core 2.2 中使用 NSwag

参考 Get started with NSwag and ASP.NET Core 使用 NSwag 时,发现在 .NET Core 2.2.0NSwag.AspNetCore 12.0.5services.AddSwagger()app.UseSwaggerUi3WithApiExplorer() 方法已经被弃用了,需要改用对应的 AddSwaggerDocument()UseSwagger()UseSwaggerUi3() 方法。

安装 NSwag.AspNetCore NuGet 包

batch
Install-Package NSwag.AspNetCore

Startup.cs

csharp
using NSwag.AspNetCore;

Startup.ConfigureServices 中注册 Swagger Document 服务。

csharp
// Register the Swagger services
services.AddSwaggerDocument();

Startup.Configure 启用 Swagger UI。

csharp
// Register the Swagger generator and the Swagger UI middlewares
app.UseSwagger().UseSwaggerUi3();

默认开启了属性首字母小写。

启动后打开 http://localhost:5000/swagger/ 访问 Swagger UI 页面。

Page Layout Max Width

Adjust the exact value of the page width of VitePress layout to adapt to different reading needs and screens.

Adjust the maximum width of the page layout
A ranged slider for user to choose and customize their desired width of the maximum width of the page layout can go.

Content Layout Max Width

Adjust the exact value of the document content width of VitePress layout to adapt to different reading needs and screens.

Adjust the maximum width of the content layout
A ranged slider for user to choose and customize their desired width of the maximum width of the content layout can go.