Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to custom favicon docs? #2581

Closed
4 of 9 tasks
letanloc1998 opened this issue Dec 30, 2020 · 3 comments
Closed
4 of 9 tasks

How to custom favicon docs? #2581

letanloc1998 opened this issue Dec 30, 2020 · 3 comments
Labels
question Question or problem question-migrate

Comments

@letanloc1998
Copy link

letanloc1998 commented Dec 30, 2020

First check

  • I added a very descriptive title to this issue.
  • I used the GitHub search to find a similar issue and didn't find it.
  • I searched the FastAPI documentation, with the integrated search.
  • I already searched in Google "How to X in FastAPI" and didn't find any information.
  • I already read and followed all the tutorial in the docs and didn't find an answer.
  • I already checked if it is not related to FastAPI but to Pydantic.
  • I already checked if it is not related to FastAPI but to Swagger UI.
  • I already checked if it is not related to FastAPI but to ReDoc.
  • After submitting this, I commit to one of:
    • Read open issues with questions until I find 2 issues where I can help someone and add a comment to help there.
    • I already hit the "watch" button in this repository to receive notifications and I commit to help at least 2 people that ask questions in the future.
    • Implement a Pull Request for a confirmed bug.

Example

I want to self-host all resource but I can't find any document change logo swagger
I only see https://fastapi.tiangolo.com/advanced/extending-openapi/ to host js and css

I want to change <link rel="shortcut icon" href="https://fastapi.tiangolo.com/img/favicon.png"> store in my host

Moreover, does anyone help me link to custom template,... swagger and redoc? Thanks

Description

Environment

Additional context

http://localhost:8000/docs

@letanloc1998 letanloc1998 added the question Question or problem label Dec 30, 2020
@ycd
Copy link
Contributor

ycd commented Dec 30, 2020

You can override the default redoc_url and docs_url, then you can create your own endpoint. Which you can customize however if you want.

from fastapi import FastAPI
from fastapi.openapi.docs import get_swagger_ui_html, get_redoc_html


app = FastAPI(docs_url=None, redoc_url=None)


@app.get("/docs", include_in_schema=False)
def overridden_swagger():
	return get_swagger_ui_html(openapi_url="/openapi.json", title="FastAPI", swagger_favicon_url="https://placekitten.com/200/300")

@app.get("/redoc", include_in_schema=False)
def overridden_redoc():
	return get_redoc_html(openapi_url="/openapi.json", title="FastAPI", redoc_favicon_url="https://placekitten.com/200/300")

@letanloc1998
Copy link
Author

Thank you a lot
I has been override but I didn't know "redoc_favicon_url" before. I will do it

@tiangolo
Copy link
Owner

tiangolo commented Nov 9, 2022

Thanks for the help here @ycd ! 👏 🙇

Thanks for reporting back and closing the issue @letanloc1998 👍

Sorry for the long delay! 🙈 I wanted to personally address each issue/PR and they piled up through time, but now I'm checking each one in order.

@tiangolo tiangolo changed the title [Swagger] How to custom favicon docs? How to custom favicon docs? Feb 24, 2023
@tiangolo tiangolo reopened this Feb 27, 2023
Repository owner locked and limited conversation to collaborators Feb 27, 2023
@tiangolo tiangolo converted this issue into discussion #6936 Feb 27, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
question Question or problem question-migrate
Projects
None yet
Development

No branches or pull requests

3 participants