我正在将 .net API 升级到 .net Core 3.1 并使用 Swashbuckle.AspNetcore 5.4.1。API 在 ServiceFabric 应用程序中运行。我找到了这个https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/1173并尝试遵循它并生成 swagger 但如果我尝试使用 Swagger UI 发送请求请求 URL 使用错误的 IP 所以请求失败。在旧的 Swashbuckle 4.0.1 设置中,我们没有指定主机,只指定相对 basePath。我怎样才能达到同样的目标?
启动文件
var swaggerBasePath = "/MySfApp/SfApp.ClientApi/";
app.UseSwagger(c =>
{
c.SerializeAsV2 = serializeAsSwaggerV2;
c.RouteTemplate = "swagger/{documentName}/swagger.json";
c.PreSerializeFilters.Add((swaggerDoc, httpReq) =>
{
swaggerDoc.Servers = new List<OpenApiServer> { new OpenApiServer { Url = $"{httpReq.Scheme}://{httpReq.Host.Value}{swaggerBasePath}" } };
});
});
app.UseSwaggerUI(options =>
{
options.SwaggerEndpoint("api/swagger.json", "My API V1");
});
Run Code Online (Sandbox Code Playgroud)
结果是 Swagger UI 在 URL 上正确加载:
http://145.12.23.1:54000/MySfApp/SfApp.ClientApi/swagger/index.html
Run Code Online (Sandbox Code Playgroud)
它在名称下说 BaseUrl 是:
[ …Run Code Online (Sandbox Code Playgroud) 我可以将style.css或anyscript.js托管在Google云端硬盘上的文件夹中,然后在脚本中添加指向云端硬盘文件的链接吗?如果是这样..怎么样?
在这里,我的意思是GAS可以在Google协作平台上使用...因此该脚本不在Google云端硬盘中
javascript css google-sites google-apps-script google-drive-api