Skip to content

Multiple Swaggers #6768

Answered by Kludex
Exzentttt asked this question in Questions
Apr 6, 2021 · 7 comments · 1 reply
Discussion options

You must be logged in to vote

Well... In case you already have the whole setup ready...

This function is probably more helpful:

from typing import Dict, List, Optional

from fastapi import FastAPI, Request
from fastapi.openapi.docs import get_redoc_html, get_swagger_ui_html
from fastapi.responses import HTMLResponse

app = FastAPI()
app.router.tags = ["Potato"]


@app.get("/")
def home():
    return "Hi"


def build_docs(
    app: FastAPI,
    prefix: str,
    tags: List[str],
    custom_openapi: Optional[Dict[str, str]] = {},
) -> None:
    async def get_openapi(request: Request):
        nonlocal custom_openapi
        if prefix not in custom_openapi:
            custom_openapi[prefix] = request.app.openapi()

     …

Replies: 7 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by Kludex
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@LorerVitaly
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question or problem question-migrate
5 participants
Converted from issue

This discussion was converted from issue #3047 on February 27, 2023 23:00.