Asp.net core RouteTemplate配置中{documentname}的用途是什么?
默认情况下,Swagger JSON将在以下路由中公开- “/swagger/{documentName}/swagger.json”。如有必要,您可以更改 这是在启用Swagger中间件时发生的。自定义路线必须包括 {documentName}参数 为什么模板配置需要此占位符,而UI配置不需要Asp.net core RouteTemplate配置中{documentname}的用途是什么?,asp.net-core,swagger,swashbuckle,Asp.net Core,Swagger,Swashbuckle,默认情况下,Swagger JSON将在以下路由中公开- “/swagger/{documentName}/swagger.json”。如有必要,您可以更改 这是在启用Swagger中间件时发生的。自定义路线必须包括 {documentName}参数 为什么模板配置需要此占位符,而UI配置不需要 app.UseSwagger(c => { c.RouteTemplate = "api-docs/{documentName}/swagger.json"; }) N
app.UseSwagger(c =>
{
c.RouteTemplate = "api-docs/{documentName}/swagger.json";
})
NOTE: If you're using the SwaggerUI middleware, you'll also need to update its configuration to reflect the new endpoints:
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/api-docs/v1/swagger.json", "My API V1");
})
{documentName}
的作用是什么?是否有一个功能可以动态地将其交换出去?因为示例中的UI配置是静态配置的。为什么不在RouteTemplate配置中也使用“/api docs/v1/swagger.json”
?您能够理解对{documentName}的需求吗?您找到了吗?文档完全忽略了这一点。。。