docs_src/conditional_openapi/tutorial001_py310.py
raw| 1 | from fastapi import FastAPI |
| 2 | from pydantic_settings import BaseSettings |
| 3 | |
| 4 | |
| 5 | class Settings(BaseSettings): |
| 6 | openapi_url: str = "/openapi.json" |
| 7 | |
| 8 | |
| 9 | settings = Settings() |
| 10 | |
| 11 | app = FastAPI(openapi_url=settings.openapi_url) |
| 12 | |
| 13 | |
| 14 | @app.get("/") |
| 15 | def root(): |
| 16 | return {"message": "Hello World"} |