Wat*_*ont 5 c# swagger swagger-ui swashbuckle asp.net-core
我使用Swashbuckle.AspNetCore (4.0.1),以产生像它描述测试一个简单的SwaggerUI 这里。我的ApiController有两条路线:
[Route("api/values")]
[Route("api/{systemId}/values")]
Run Code Online (Sandbox Code Playgroud)
SwaggerUI两次显示所有控制器端点(一次使用systemId,一次不使用systemId)。这很好,但是问题是,当我单击例如/api/values/exampleSwaggerUI 时,它也会扩展api/{systemId}/values/example。两个端点都将在控制器内部使用相同的公共C#方法,因此SwaggerUI会同时打开两个端点是很有意义的。但这很烦人和令人困惑。
是否可以停止这种行为?
Add the Name property to the Route.
[Route("api/values", Name = "values1")]
[Route("api/{systemId}/values", Name = "values2")]
Run Code Online (Sandbox Code Playgroud)
This will create different ids in the div containing the endpoint specifications so it will expand only the one you need.
| 归档时间: |
|
| 查看次数: |
165 次 |
| 最近记录: |