This is what worked for me:
First, you have to create the wwwroot folder, and place there a folder called swagger. Edit your csproj to include this line:
<ItemGroup>
<None Include="wwwroot\*" />
</ItemGroup>
Files under this directory must be Content
, Do not copy
. That's default option anyway.
Then, you have to place two png files called favicon-16x16.png
and favicon-32x32.png
in swagger folder.
Last thig to do, add app.UseStaticFiles();
before app.UseSwaggerUI();
to get it to work.
You can also add a favicon.ico under wwwroot folder.
** NOTE: In case you had modified endpoint url, using app.UseSwaggerUI(config => config.SwaggerEndpoint("my/swagger/doc/file.json", "Rest API"));
, directory tree under wwwroot must match the url. i.e., wwwroot/my/swagger/doc/favicon-16x16.png
and wwwroot/my/swagger/doc/favicon-32x32.png
.