Browse Source

swagger控制

master
wxd 1 year ago
parent
commit
b4df1f3447
  1. 30
      src/Shentun.WebPeis.HttpApi.Host/WebPeisHttpApiHostModule.cs
  2. 3
      src/Shentun.WebPeis.HttpApi.Host/appsettings.json

30
src/Shentun.WebPeis.HttpApi.Host/WebPeisHttpApiHostModule.cs

@ -459,20 +459,24 @@ public class WebPeisHttpApiHostModule : AbpModule
app.UseDynamicClaims(); app.UseDynamicClaims();
app.UseAuthorization(); app.UseAuthorization();
app.UseSwagger();
app.UseAbpSwaggerUI(c =>
//配置是否启用swagger
var IsSwagger = Convert.ToBoolean(configuration["Swagger:IsEnabled"]);
if (IsSwagger)
{ {
c.SwaggerEndpoint($"/swagger/Work/swagger.json", "业务API"); //分组显示
c.SwaggerEndpoint($"/swagger/Sys/swagger.json", "底层API"); //分组显示
//c.SwaggerEndpoint("/swagger/v1/swagger.json", "WebPeis API");
var configuration = context.ServiceProvider.GetRequiredService<IConfiguration>();
c.OAuthClientId(configuration["AuthServer:SwaggerClientId"]);
c.OAuthClientSecret(configuration["AuthServer:ClientSecret"]);
c.OAuthScopes("WebPeis");
c.DefaultModelExpandDepth(-1);
});
app.UseSwagger();
app.UseAbpSwaggerUI(c =>
{
c.SwaggerEndpoint($"/swagger/Work/swagger.json", "业务API"); //分组显示
c.SwaggerEndpoint($"/swagger/Sys/swagger.json", "底层API"); //分组显示
//c.SwaggerEndpoint("/swagger/v1/swagger.json", "WebPeis API");
var configuration = context.ServiceProvider.GetRequiredService<IConfiguration>();
c.OAuthClientId(configuration["AuthServer:SwaggerClientId"]);
c.OAuthClientSecret(configuration["AuthServer:ClientSecret"]);
c.OAuthScopes("WebPeis");
c.DefaultModelExpandDepth(-1);
});
}
app.UseAuditing(); app.UseAuditing();
app.UseAbpSerilogEnrichers(); app.UseAbpSerilogEnrichers();
app.UseConfiguredEndpoints(); app.UseConfiguredEndpoints();

3
src/Shentun.WebPeis.HttpApi.Host/appsettings.json

@ -64,5 +64,8 @@
"BaseAddress": "http://10.1.13.31", "BaseAddress": "http://10.1.13.31",
"ReportListApiUrl": "http://10.1.13.31/api/report/page", "ReportListApiUrl": "http://10.1.13.31/api/report/page",
"ReportApiUrl": "http://10.1.13.31/api/report/download" "ReportApiUrl": "http://10.1.13.31/api/report/download"
},
"Swagger": {
"IsEnabled": true
} }
} }
Loading…
Cancel
Save