Azure / Azure/azure-functions-openapi-extension

Generated Favicon references not found

Open
#147 2 comments 1 reaction 0 assignees View on GitHub
enhancement
Dominant language
C#
Stars
388
Forks
202
PR merge metrics
No merged PRs in 30d

Description

The swagger documentation of a function app for the most part working for me except for an issue where the browser cannot find the favicon files generated by SwaggerUI. Chrome developer tools indicate that favicon-32x32.png and favicon-16x16.png cannot be found. Error is 'GET http://localhost:7071/api/swagger/favicon-32x32.png 404 (Not Found)'

The generated html code from the ISwaggerUI abstraction has these two lines in it -


Since this is an Azure Function App, the images would not be downloadable as in a normal web app and I would imagine that the images would need their own endpoint. I noticed in your example endpoint files you do not have endpoints for these images. How is the browser supposed to find these files if they are not hosted?

Version: Core 3.1.1

Swagger UI Endpoint -

[FunctionName(nameof(RenderSwaggerUI))]
[OpenApiIgnore]
public static async Task RenderSwaggerUI(
[HttpTrigger(AuthorizationLevel.Admin, "GET", Route = "swagger/ui")] HttpRequest req,
ILogger logger, ExecutionContext executionContext)
{
var result = await context.SwaggerUI
.AddMetadata(context.OpenApiInfo)
.AddServer(req, context.HttpSettings.RoutePrefix)
.BuildAsync()
.RenderAsync(swaggerEndpoint, context.GetSwaggerAuthKey())
.ConfigureAwait(false);

var content = new ContentResult()
{
Content = result,
ContentType = "text/html",
StatusCode = (int)HttpStatusCode.OK
};

return content;
}

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.