question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[FEATURE] Make swagger-ui and redoc favicon configurable

See original GitHub issue

Is your feature request related to a problem? Please describe. Both documentation viewers loaded by FastAPI currently use https://fastapi.tiangolo.com/img/favicon.png as their favicon with no way to change it. It’s a nice enough favicon and does the job as a default, but it appears to currently be hardcoded in fastapi/openapi/docs.py, which makes it tricky to change.

Describe the solution you’d like Let the user pass a doc_favicon argument to FastAPI on initialization and fallback on the default if none is provided.

Describe alternatives you’ve considered

  • Having all static assets served by FastAPI moved to an internal folder (the HTML templates for the doc pages and possibly the JS bundles for Redoc and Swagger UI), with the option to let the user specify a custom path instead. That one would represent more work and would make custom assets into an all-or-nothing deal, though that isn’t to say that having an internal static folder wouldn’t have its benefits.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:4
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
Kilo59commented, Apr 18, 2020

The swagger_favicon_url argument isn’t featured anywhere in the provided example, and would still lead one to think this isn’t possible unless you pulled up the source code.

A minimal example would be even better. Once/if I figure it out, I’ll submit a PR.

https://github.com/tiangolo/fastapi/blob/4e77737a3f7bf2608132ea170e9ff013b5af6732/fastapi/openapi/docs.py#L14

0reactions
tiangolocommented, Feb 10, 2020

Using static assets is documented at https://fastapi.tiangolo.com/advanced/extending-openapi/#self-hosting-javascript-and-css-for-docs

It was added a while ago but I hadn’t commented about it here. 😬

I think that should solve the original problem 🚀 So I’ll close this issue now. But feel free to add more comments or issues.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do you change the Swagger favicon? - Stack Overflow
I am building a ASP.NET CORE Web API and using Swagger for the documentation. I have not been able to change the favicon....
Read more >
Customizing Swagger UI in ASP.NET Core - Chris Pratt
The one minor issue is that the Swagger UI comes branded with Swagger logos and such, and it's not easy or intuitive to...
Read more >
Extending OpenAPI - FastAPI - tiangolo
FastAPI converts the configurations to JSON to make them compatible with JavaScript, as that's what Swagger UI needs. Disable Syntax Highlighting¶. For example, ......
Read more >
Swagger UI tutorial | Documenting APIs - Idratherbewriting.com
Swagger UI provides a display framework that reads an OpenAPI specification document and generates an interactive documentation website.
Read more >
Top 5 swagger-ui-express Code Examples - Snyk
To help you get started, we've selected a few swagger-ui-express examples, ... 开放 swagger 相关接口, app.get('/swagger.json', function(req, res) { res.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found