mirror of https://github.com/tiangolo/fastapi.git
Merge branch 'master' of https://github.com/fastapi/fastapi
This commit is contained in:
parent
1d8a475b84
commit
d1f7817e8b
|
|
@ -65,25 +65,6 @@ class FastAPI(Starlette):
|
|||
def __init__(
|
||||
self: AppType,
|
||||
*,
|
||||
title: str = "FastAPI",
|
||||
description: str = "",
|
||||
version: str = "0.1.0",
|
||||
openapi_url: Optional[str] = "/openapi.json",
|
||||
openapi_tags: Optional[List[Dict[str, Any]]] = None,
|
||||
servers: Optional[List[Dict[str, Union[str, Any]]]] = None,
|
||||
dependencies: Optional[Sequence[Depends]] = None,
|
||||
default_response_class: Type[Response] = Default(JSONResponse),
|
||||
docs_url: Optional[str] = "/docs",
|
||||
redoc_url: Optional[str] = "/redoc",
|
||||
stoplight_elements_url: Optional[str] = "/elements",
|
||||
swagger_ui_oauth2_redirect_url: Optional[str] = "/docs/oauth2-redirect",
|
||||
swagger_ui_init_oauth: Optional[Dict[str, Any]] = None,
|
||||
middleware: Optional[Sequence[Middleware]] = None,
|
||||
exception_handlers: Optional[
|
||||
Dict[
|
||||
Union[int, Type[Exception]],
|
||||
Callable[[Request, Any], Coroutine[Any, Any, Response]],
|
||||
]
|
||||
debug: Annotated[
|
||||
bool,
|
||||
Doc(
|
||||
|
|
@ -341,10 +322,8 @@ class FastAPI(Starlette):
|
|||
|
||||
app = FastAPI(
|
||||
servers=[
|
||||
{"url": "https://stag.example.com",
|
||||
"description": "Staging environment"},
|
||||
{"url": "https://prod.example.com",
|
||||
"description": "Production environment"},
|
||||
{"url": "https://stag.example.com", "description": "Staging environment"},
|
||||
{"url": "https://prod.example.com", "description": "Production environment"},
|
||||
]
|
||||
)
|
||||
```
|
||||
|
|
@ -368,8 +347,7 @@ class FastAPI(Starlette):
|
|||
|
||||
from .dependencies import func_dep_1, func_dep_2
|
||||
|
||||
app = FastAPI(dependencies=[Depends(
|
||||
func_dep_1), Depends(func_dep_2)])
|
||||
app = FastAPI(dependencies=[Depends(func_dep_1), Depends(func_dep_2)])
|
||||
```
|
||||
"""
|
||||
),
|
||||
|
|
@ -462,8 +440,7 @@ class FastAPI(Starlette):
|
|||
```python
|
||||
from fastapi import FastAPI
|
||||
|
||||
app = FastAPI(docs_url="/documentation",
|
||||
redoc_url="redocumentation")
|
||||
app = FastAPI(docs_url="/documentation", redoc_url="redocumentation")
|
||||
```
|
||||
"""
|
||||
),
|
||||
|
|
@ -481,6 +458,30 @@ class FastAPI(Starlette):
|
|||
"""
|
||||
),
|
||||
] = "/docs/oauth2-redirect",
|
||||
stoplight_elements_url: Annotated[
|
||||
Optional[str],
|
||||
Doc(
|
||||
"""
|
||||
The path to the alternative automatic interactive API documentation
|
||||
provided by Stoplight Elements.
|
||||
|
||||
The default URL is `/elements`. You can disable it by setting it to `None`.
|
||||
|
||||
If `openapi_url` is set to `None`, this will be automatically disabled.
|
||||
|
||||
Read more in the
|
||||
[FastAPI docs for Metadata and Docs URLs](https://fastapi.tiangolo.com/tutorial/metadata/#docs-urls).
|
||||
|
||||
**Example**
|
||||
|
||||
```python
|
||||
from fastapi import FastAPI
|
||||
|
||||
app = FastAPI(docs_url="/documentation", stoplight_elements_url="elementsdocs")
|
||||
```
|
||||
"""
|
||||
),
|
||||
] = "/elements",
|
||||
swagger_ui_init_oauth: Annotated[
|
||||
Optional[Dict[str, Any]],
|
||||
Doc(
|
||||
|
|
@ -857,8 +858,8 @@ class FastAPI(Starlette):
|
|||
self.root_path_in_servers = root_path_in_servers
|
||||
self.docs_url = docs_url
|
||||
self.redoc_url = redoc_url
|
||||
self.stoplight_elements_url = stoplight_elements_url
|
||||
self.swagger_ui_oauth2_redirect_url = swagger_ui_oauth2_redirect_url
|
||||
self.stoplight_elements_url = stoplight_elements_url
|
||||
self.swagger_ui_init_oauth = swagger_ui_init_oauth
|
||||
self.swagger_ui_parameters = swagger_ui_parameters
|
||||
self.servers = servers or []
|
||||
|
|
@ -4619,8 +4620,7 @@ class FastAPI(Starlette):
|
|||
async def unicorn_exception_handler(request: Request, exc: UnicornException):
|
||||
return JSONResponse(
|
||||
status_code=418,
|
||||
content={
|
||||
"message": f"Oops! {exc.name} did something. There goes a rainbow..."},
|
||||
content={"message": f"Oops! {exc.name} did something. There goes a rainbow..."},
|
||||
)
|
||||
```
|
||||
"""
|
||||
|
|
|
|||
Loading…
Reference in New Issue