Ven*_*nky 5 asp.net-web-api swagger swashbuckle
我为 ASP.NET Web 应用程序启用了 swagger 文档。如何设置basePath?
GlobalConfiguration.Configuration .EnableSwagger(c => {
c.SingleApiVersion("v1", "MyApi") .Description("This is my API.");
c.IncludeXmlComments($@"{AppDomain.CurrentDomain.BaseDirectory}\bin\MyApi.XML");
}) .EnableSwaggerUi(c => {});
Run Code Online (Sandbox Code Playgroud)
目前生成的API说明如下:
"swagger": "2.0",
"host": "localhost:8080",
"basePath": "/",
Run Code Online (Sandbox Code Playgroud)
我想把它改成:
"swagger": "2.0",
"host": "localhost:8080",
"basePath": "/myapi",
Run Code Online (Sandbox Code Playgroud)
您需要将RootUrl添加到您的配置中,例如:
GlobalConfiguration.Configuration .EnableSwagger(c => {
c.SingleApiVersion("v1", "MyApi") .Description("This is my API.");
c.IncludeXmlComments($@"{AppDomain.CurrentDomain.BaseDirectory}\bin\MyApi.XML");
c.RootUrl(req => { return "http://localhost:8080/myapi"; });
}) .EnableSwaggerUi(c => {});
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
4749 次 |
最近记录: |