コード例 #1
0
ファイル: app.py プロジェクト: marirs/fastApiSimple
 async def get_redoc(
         api_key: str,
         user: User = Depends(get_current_user)
 ):
     if api_key:
         return get_redoc_html(openapi_url=f"/api/{api_key}/openapi.json", title="fastAPI Docs")
     else:
         return get_redoc_html(openapi_url=f"/api/openapi.json", title="fastAPI Docs")
コード例 #2
0
def test_google_fonts_in_generated_redoc():
    body_with_google_fonts = get_redoc_html(openapi_url="/docs",
                                            title="title").body.decode()
    assert "fonts.googleapis.com" in body_with_google_fonts
    body_without_google_fonts = get_redoc_html(
        openapi_url="/docs", title="title",
        with_google_fonts=False).body.decode()
    assert "fonts.googleapis.com" not in body_without_google_fonts
コード例 #3
0
ファイル: app.py プロジェクト: OscartGiles/fastapimsal
async def get_redocumentation(
    _: fastapimsal.UserIdentity = Depends(user_authenticated),
) -> HTMLResponse:
    """
    Serves redoc API docs
    """
    return get_redoc_html(openapi_url="/openapi.json", title="docs")
コード例 #4
0
def main():
    if len(sys.argv) > 1:
        build = sys.argv[1]
    else:
        build = settings.BUILD

    if len(sys.argv) > 2:
        custom_url = sys.argv[2]
    else:
        custom_url = None

    base_path = Path("docs/api")

    if not base_path.exists() and Path("backend").exists():
        os.makedirs(base_path)

    with open(base_path.joinpath("index.html"), "w") as html:
        html.write(
            get_redoc_html(
                openapi_url=custom_url if custom_url else app.openapi_url,
                title=app.title,
            ).body.decode("utf-8"))
    with open(base_path.joinpath("openapi.json"), "w") as j:
        j.write(
            json.dumps(
                get_openapi(
                    title=settings.SERVER_NAME,
                    version=f"{settings.VERSION}:{build}",
                    description="PartyFiller API Specification",
                    routes=app.routes,
                )))
コード例 #5
0
ファイル: main.py プロジェクト: acutaia/goeasy-serengeti
async def custom_redoc_ui_html():
    return get_redoc_html(
        openapi_url=f"/serengeti{app.openapi_url}",
        title="Serengeti",
        redoc_js_url="/serengeti/static/redoc.standalone.js",
        redoc_favicon_url="/serengeti/static/satellite.png",
    )
コード例 #6
0
async def redoc_html():
    return get_redoc_html(
        openapi_url=str(app.openapi_url),
        title=app.title + " - ReDoc",
        redoc_js_url="/static/redoc.standalone.js",
        redoc_favicon_url="/static/logo/trident_neptune_logo.ico",
    )
コード例 #7
0
ファイル: applications.py プロジェクト: yihuang/fastapi
 def setup(self) -> None:
     if self.openapi_url:
         self.add_route(
             self.openapi_url,
             lambda req: JSONResponse(self.openapi()),
             include_in_schema=False,
         )
     if self.openapi_url and self.docs_url:
         self.add_route(
             self.docs_url,
             lambda r: get_swagger_ui_html(
                 openapi_url=self.openapi_prefix + self.openapi_url,
                 title=self.title + " - Swagger UI",
             ),
             include_in_schema=False,
         )
     if self.openapi_url and self.redoc_url:
         self.add_route(
             self.redoc_url,
             lambda r: get_redoc_html(
                 openapi_url=self.openapi_prefix + self.openapi_url,
                 title=self.title + " - ReDoc",
             ),
             include_in_schema=False,
         )
     self.add_exception_handler(HTTPException, http_exception)
コード例 #8
0
    async def redoc_ui_html(req: Request) -> HTMLResponse:
        assert app.openapi_url is not None
        redoc_ui = get_redoc_html(
            openapi_url="./" + app.openapi_url.lstrip("/"),
            title=app.title + " - Redoc UI",
        )

        return HTMLResponse(redoc_ui.body.decode("utf-8"))
コード例 #9
0
def test_strings_in_generated_redoc():
    sig = inspect.signature(get_redoc_html)
    redoc_js_url = sig.parameters.get("redoc_js_url").default
    redoc_favicon_url = sig.parameters.get("redoc_favicon_url").default
    html = get_redoc_html(openapi_url="/docs", title="title")
    body_content = html.body.decode()
    assert redoc_js_url in body_content
    assert redoc_favicon_url in body_content
コード例 #10
0
ファイル: main.py プロジェクト: IamShobe/vscode-ex-server
async def redoc_html(req: Request) -> HTMLResponse:
    openapi_url = app.openapi_prefix + app.openapi_url
    return get_redoc_html(
        openapi_url=openapi_url,
        title=app.title + " - Redoc",
        redoc_js_url="/static/redoc.standalone.js",
        redoc_favicon_url="/static/favicon.png",
        with_google_fonts=False
    )
コード例 #11
0
ファイル: main.py プロジェクト: odgon/monitoring-vertica
async def redoc_html():
    return get_redoc_html(
        openapi_url=app.openapi_url,
        title=app.title + " - ReDoc",
        redoc_js_url=
        "https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js",
        redoc_favicon_url=
        "https://cdn.jsdelivr.net/npm/swagger-ui-dist@3/favicon-32x32.png",
    )
コード例 #12
0
ファイル: docs.py プロジェクト: techiev2/meterite
async def get_redocumentation(api_key: APIKey = Depends(get_api_key)):
    response = get_redoc_html(openapi_url="/openapi.json",
                              title="API:" + app.title)
    response.set_cookie(
        config.Settings().api_key_name,
        value=api_key,
        domain=config.Settings().cookie_domain,
        httponly=True,
        max_age=1800,
        expires=1800,
    )
    return response
コード例 #13
0
def test_strings_in_custom_redoc():
    redoc_js_url = "fake_redoc_file.js"
    redoc_favicon_url = "fake_redoc_file.png"
    html = get_redoc_html(
        openapi_url="/docs",
        title="title",
        redoc_js_url=redoc_js_url,
        redoc_favicon_url=redoc_favicon_url,
    )
    body_content = html.body.decode()
    assert redoc_js_url in body_content
    assert redoc_favicon_url in body_content
コード例 #14
0
ファイル: main.py プロジェクト: KaranTrivedi/dirlist-api
async def redoc_html():
    """
    Trying to load in custom CSS file for docs pages.

    Returns:
        [type]: [description]
    """
    return get_redoc_html(
        openapi_url=app.openapi_url,
        title=app.title + " - ReDoc",
        redoc_js_url="/static/redoc.standalone.js",
    )
コード例 #15
0
def overridden_redoc():
    return get_redoc_html(openapi_url='/openapi.json',
                          title='The StorageLeaf API',
                          redoc_favicon_url=app.url_path_for('favicon'))
コード例 #16
0
async def redoc_html():
    return get_redoc_html(
        openapi_url=app.openapi_url,
        title=app.title + " - ReDoc",
        redoc_js_url="/static/redoc.standalone.js",
    )
コード例 #17
0
async def redoc_html():
    return get_redoc_html(
        openapi_url=OPENAPI_URL,
        title=APP_TITLE + " - ReDoc",
        redoc_js_url="/static/redoc.standalone.js",
    )
コード例 #18
0
ファイル: api.py プロジェクト: PyFunceble/web-worker
def custom_redoc() -> HTMLResponse:
    return get_redoc_html(
        openapi_url="/openapi.json",
        title=assets_defaults.PROJECT_NAME,
        redoc_favicon_url=assets_defaults.FAVICON_URL,
    )
コード例 #19
0
ファイル: api.py プロジェクト: shanmugharajk/sturdy-chainsaw
async def get_documentation():
    return get_redoc_html(openapi_url="/api/v1/docs/openapi.json",
                          title="Qanet Docs")
コード例 #20
0
ファイル: main.py プロジェクト: dnjswnsthd/Sma-IT
async def get_redoc_documentation():
    return get_redoc_html(openapi_url="/api/openapi.json", title="docs")
コード例 #21
0
ファイル: docs.py プロジェクト: whatsup1088/stt-recognize-api
async def redoc_html():
    return get_redoc_html(redoc_js_url="/static/js/redoc.standalone.js", )
コード例 #22
0
ファイル: applications.py プロジェクト: Dustyposa/fastapi
 async def redoc_html(req: Request) -> HTMLResponse:
     return get_redoc_html(openapi_url=openapi_url,
                           title=self.title + " - ReDoc")
コード例 #23
0
async def get_redoc():
    return get_redoc_html(openapi_url="/openapi.json", title="redoc")
コード例 #24
0
ファイル: app.py プロジェクト: oysteoh/ert
async def get_redoc(req: Request) -> HTMLResponse:
    return get_redoc_html(openapi_url="/openapi.json", title=f"{app.title} - Redoc")
コード例 #25
0
 async def redoc_html(_req: Request) -> HTMLResponse:
     return get_redoc_html(
         openapi_url=app.openapi_url,
         title=app.title + " - redoc",
         redoc_favicon_url=FAVICON,
     )
コード例 #26
0
 async def redoc_html():
     return get_redoc_html(
         openapi_url=app.openapi_url,
         title=app.title + " - ReDoc",
         redoc_favicon_url=icon
     )
コード例 #27
0
def overridden_redoc():
    return get_redoc_html(openapi_url="/openapi.json",
                          title="Cast-MyVote API",
                          redoc_favicon_url="https://i.imgur.com/5X2efLp.png")
コード例 #28
0
async def redoc_html():
    return get_redoc_html(
        openapi_url=f"{settings.API_V1_STR}/openapi.json",
        title=webapp.title + " - ReDoc",
        redoc_js_url="/static/redoc.standalone.js",
    )
コード例 #29
0
 async def redoc_html(req: Request) -> HTMLResponse:
     root_path = req.scope.get("root_path", "").rstrip("/")
     openapi_url = root_path + self.openapi_url
     return get_redoc_html(openapi_url=openapi_url,
                           title=self.title + " - ReDoc")
コード例 #30
0
async def redoc_html(request: Request):
    return get_redoc_html(
        openapi_url=FastAPI().openapi_url,
        title=FastAPI().title + " - ReDoc",
    )