【发布时间】:2016-12-07 16:43:12
【问题描述】:
我正在尝试配置 Swashbuckle,以便可以使用 URL {root}/swagger.json 访问生成的 JSON 文件。
我已经操作了许多设置,但无法使其正常工作。以下是一些示例:
// This works! JSON file is located at http://{root}/swagger/docs/v1
this.EnableSwagger(c =>
{
c.RootUrl(x => baseUrl);
c.SingleApiVersion("v1", title);
}).EnableSwaggerUi();
This works! JSON file is located at http://{root}/swagger/docs/swagger
this.EnableSwagger(c =>
{
c.RootUrl(x => baseUrl);
c.SingleApiVersion("swagger", title);
}).EnableSwaggerUi();
// This does not work. JSON file is located at http://{root}/swagger
this.EnableSwagger("{apiVersion}", c =>
{
c.RootUrl(x => baseUrl);
c.SingleApiVersion("swagger", title);
}).EnableSwaggerUi();
// This does not work. JSON file is located at http://{root}/foo/swagger
this.EnableSwagger("foo/{apiVersion}", c =>
{
c.RootUrl(x => baseUrl);
c.SingleApiVersion("swagger", title);
}).EnableSwaggerUi();
我们如何配置 Swashbuckle,使文件命名为“swagger.json”,并从与“/swagger/docs”不同的路径访问它 - 最好是应用程序的根目录?
【问题讨论】:
-
你找到答案了吗?
标签: swagger swagger-ui swashbuckle