我正在尝试配置Swashbuckle,因此可以使用URL /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”的不同路径访问 - 最好是应用程序的根目录?
1 回答
万一有人还在寻找:
this approach为我工作: