diff --git a/docs_src/extending_openapi/tutorial002.py b/docs_src/extending_openapi/tutorial002.py index 23ea368f8..f7e132636 100644 --- a/docs_src/extending_openapi/tutorial002.py +++ b/docs_src/extending_openapi/tutorial002.py @@ -2,11 +2,12 @@ from fastapi import FastAPI from fastapi.openapi.docs import ( get_redoc_html, get_swagger_ui_html, + get_stoplight_elements_html, get_swagger_ui_oauth2_redirect_html, ) from fastapi.staticfiles import StaticFiles -app = FastAPI(docs_url=None, redoc_url=None) +app = FastAPI(docs_url=None, redoc_url=None, stoplight_elements_url=None) app.mount("/static", StaticFiles(directory="static"), name="static") @@ -35,7 +36,16 @@ async def redoc_html(): redoc_js_url="/static/redoc.standalone.js", ) +@app.get("/elements", include_in_schema=False) +async def elements_html(): + return get_stoplight_elements_html( + openapi_url=app.openapi_url, + title=app.title + " - Elements", + stoplight_elements_js_url="/static/web-components.min.js", + stoplight_elements_css_url="/static/styles.min.css", + ) + @app.get("/users/{username}") async def read_user(username: str): - return {"message": f"Hello {username}"} + return {"message": f"Hello {username}"} \ No newline at end of file