mirror of
https://github.com/fastapi/fastapi.git
synced 2026-03-24 09:44:01 -04:00
✨ Allow disabling docs UIs by disabling OpenAPI (#1421)
* ✨ Allow disabling docs UIs by disabling openapi_url * 📝 Add docs for disabling OpenAPI and docs in prod or other environments * ✅ Add tests for disabling OpenAPI and docs
This commit is contained in:
committed by
GitHub
parent
cfb72eec5a
commit
409264960e
16
docs_src/conditional_openapi/tutorial001.py
Normal file
16
docs_src/conditional_openapi/tutorial001.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from fastapi import FastAPI
|
||||
from pydantic import BaseSettings
|
||||
|
||||
|
||||
class Settings(BaseSettings):
|
||||
openapi_url: str = "/openapi.json"
|
||||
|
||||
|
||||
settings = Settings()
|
||||
|
||||
app = FastAPI(openapi_url=settings.openapi_url)
|
||||
|
||||
|
||||
@app.get("/")
|
||||
def root():
|
||||
return {"message": "Hello World"}
|
||||
Reference in New Issue
Block a user