2019-11-23 22:50:58 +01:00
|
|
|
from fastapi import FastAPI
|
|
|
|
|
from fastapi.openapi.docs import (
|
|
|
|
|
get_redoc_html,
|
|
|
|
|
get_swagger_ui_html,
|
|
|
|
|
get_swagger_ui_oauth2_redirect_html,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
app = FastAPI(docs_url=None, redoc_url=None)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.get("/docs", include_in_schema=False)
|
|
|
|
|
async def custom_swagger_ui_html():
|
|
|
|
|
return get_swagger_ui_html(
|
|
|
|
|
openapi_url=app.openapi_url,
|
|
|
|
|
title=app.title + " - Swagger UI",
|
|
|
|
|
oauth2_redirect_url=app.swagger_ui_oauth2_redirect_url,
|
2023-10-30 06:58:58 -03:00
|
|
|
swagger_js_url="https://unpkg.com/swagger-ui-dist@5.9.0/swagger-ui-bundle.js",
|
|
|
|
|
swagger_css_url="https://unpkg.com/swagger-ui-dist@5.9.0/swagger-ui.css",
|
2019-11-23 22:50:58 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.get(app.swagger_ui_oauth2_redirect_url, include_in_schema=False)
|
|
|
|
|
async def swagger_ui_redirect():
|
|
|
|
|
return get_swagger_ui_oauth2_redirect_html()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.get("/redoc", include_in_schema=False)
|
|
|
|
|
async def redoc_html():
|
|
|
|
|
return get_redoc_html(
|
|
|
|
|
openapi_url=app.openapi_url,
|
|
|
|
|
title=app.title + " - ReDoc",
|
2023-08-19 21:54:04 +02:00
|
|
|
redoc_js_url="https://unpkg.com/redoc@next/bundles/redoc.standalone.js",
|
2019-11-23 22:50:58 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.get("/users/{username}")
|
|
|
|
|
async def read_user(username: str):
|
|
|
|
|
return {"message": f"Hello {username}"}
|