2017-07-21 19 views
0

闊歩UIのエンドポイントは(ドメイン名を除く)ステージングでDEVと同じではありませんIISサイトが仮想ディレクトリ闊歩UIのエンドポイント内

IISの設定

enter image description here

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) 

app.UseSwagger(c=> 
     { 
      //Change the path of the end point , should also update UI middle ware for this change     
      c.RouteTemplate = "api-docs/{documentName}/swagger.json";     
     });   

     app.UseSwaggerUI(c => 
     { 
      //Include virtual directory if site is configured so 
      c.SwaggerEndpoint(Configuration["Appsettings:VirtualDirectory"]+"api-docs/v1/swagger.json", "Api v1");     
     }); 

services.AddSwaggerGen(c => 
     { 
var xmlDocPath = Path.Combine(PlatformServices.Default.Application.ApplicationBasePath, "Api.xml"); 
      c.IncludeXmlComments(xmlDocPath); 
      c.DescribeAllEnumsAsStrings(); 

開発

"AppSettings": { 
"VirtualDirectory": "/" 

}

ステージング

"AppSettings": { 
"VirtualDirectory": "/Api/" 

}

http://localhost:5001/api-docs/v1/swagger.json 

が、ステージングサーバ上の同一の一方のステージングとDEVマシン上でUIのエンドポイント

http://xxxx:5002/swagger/Api/api-docs/v1/swagger.json 

の代わりに、(それがどうあるべきか)

http://xxxx:5002/Api/api-docs/v1/swagger.json 
+0

あなたが間違っているように見えるように、envをステージングの開発マシンとして設定する方法を示します。あなたは 'ASPNETCORE_ENVIRONMENT'変数を' Staging'か、あなたが使ったものに設定しましたか? – Set

+0

正確には、ASPNETCORE_ENVIRONMENT変数。 – Jay

答えて

1

問題は、環境変数よりも闊歩に、より関連性があります。スワッガーは仮想ディレクトリをサポートしていますが、その構成は以下のようになります。仮想ディレクトリはUIエンドポイントに影響しないことに注意してください。

app.UseSwagger(c => 
      { 
       //Change the path of the end point , should also update UI middle ware for this change     
       c.RouteTemplate = "api-docs/{documentName}/swagger.json"; 
      }); 
app.UseSwaggerUI(c => 
      { 
       //Include virtual directory if site is configured so 
       c.RoutePrefix = "api-docs"; 
       c.SwaggerEndpoint("v1/swagger.json", "Api v1"); 
      });