ASP. NET Проект Core Web API настроен с помощью Swagger. Когда я запускаю проект на моей локальной машине, launchUrl работает правильно и автоматически перенаправляет в мое расположение Apidocs Swagger (https://localhost: 44373 / apidocs / index. html)
Но как как только я публикую sh проект на Azure, launchUrl больше не работает правильно. (https://myapiurl.com) => Следует ли автоматически перенаправить на (https://myapiurl.com/apidocs/index.html) ?
Чего мне не хватает в опубликованной среде?
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:60837",
"sslPort": 44373
}
},
"$schema": "http://json.schemastore.org/launchsettings.json",
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "apidocs",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Production"
}
},
"Web.Apis.Organization": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "apidocs",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:5001;http://localhost:5000"
}
}
}
Мой метод настройки
app.UseStaticFiles();
// Enable middle-ware to serve generated Swagger as a JSON endpoint. https://github.com/domaindrivendev/Swashbuckle.AspNetCore#generate-multiple-swagger-documents
app.UseSwagger(options =>
{
options.RouteTemplate = "apidocs/{documentName}/apispec.json";
});
//Enable middle-ware to serve swagger - ui(HTML, JS, CSS, etc.), specifying the Swagger JSON endpoint.
// https://dejanstojanovic.net/aspnet/2018/november/setting-up-swagger-to-support-versioned-api-endpoints-in-aspnet-core/
// https://github.com/microsoft/aspnet-api-versioning/issues/516
app.UseSwaggerUI(c =>
{
c.RoutePrefix = "apidocs";
//Build a swagger endpoint for each discovered API version
foreach (var apiDescription in apiVersionProvider.ApiVersionDescriptions)
{
c.SwaggerEndpoint($"/{c.RoutePrefix}/{apiDescription.GroupName}/apispec.json", $"Version { apiDescription.ApiVersion.ToString()}");
}
c.DisplayRequestDuration();
c.DocumentTitle = GlobalConstants.OrganizationFullName;
// Custom Index
c.IndexStream = () => GetType().Assembly.GetManifestResourceStream("Web.Apis.Organization.wwwroot.swagger_ui.index.html");
// Custom style
//c.InjectStylesheet("/swagger-ui/custom.css");
//c.InjectJavascript("/swagger-ui/custom.js");
});