Coverage for docs_src/custom_docs_ui/tutorial001.py: 100%
15 statements
« prev ^ index » next coverage.py v7.6.1, created at 2025-05-05 00:03 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2025-05-05 00:03 +0000
1from fastapi import FastAPI 1abcdef
2from fastapi.openapi.docs import ( 1abcdef
3 get_redoc_html,
4 get_swagger_ui_html,
5 get_swagger_ui_oauth2_redirect_html,
6)
8app = FastAPI(docs_url=None, redoc_url=None) 1abcdef
11@app.get("/docs", include_in_schema=False) 1abcdef
12async def custom_swagger_ui_html(): 1abcdef
13 return get_swagger_ui_html( 1ghijkl
14 openapi_url=app.openapi_url,
15 title=app.title + " - Swagger UI",
16 oauth2_redirect_url=app.swagger_ui_oauth2_redirect_url,
17 swagger_js_url="https://unpkg.com/swagger-ui-dist@5/swagger-ui-bundle.js",
18 swagger_css_url="https://unpkg.com/swagger-ui-dist@5/swagger-ui.css",
19 )
22@app.get(app.swagger_ui_oauth2_redirect_url, include_in_schema=False) 1abcdef
23async def swagger_ui_redirect(): 1abcdef
24 return get_swagger_ui_oauth2_redirect_html() 1mnopqr
27@app.get("/redoc", include_in_schema=False) 1abcdef
28async def redoc_html(): 1abcdef
29 return get_redoc_html( 1stuvwx
30 openapi_url=app.openapi_url,
31 title=app.title + " - ReDoc",
32 redoc_js_url="https://unpkg.com/redoc@2/bundles/redoc.standalone.js",
33 )
36@app.get("/users/{username}") 1abcdef
37async def read_user(username: str): 1abcdef
38 return {"message": f"Hello {username}"} 1yzABCD