Browse Source

🎨 Update param names for main FastAPI app and types

pull/11/head
Sebastián Ramírez 7 years ago
parent
commit
f9c876802f
  1. 14
      fastapi/applications.py

14
fastapi/applications.py

@ -24,9 +24,9 @@ class FastAPI(Starlette):
title: str = "Fast API", title: str = "Fast API",
description: str = "", description: str = "",
version: str = "0.1.0", version: str = "0.1.0",
openapi_url: str = "/openapi.json", openapi_url: Optional[str] = "/openapi.json",
swagger_ui_url: str = "/docs", docs_url: Optional[str] = "/docs",
redoc_url: str = "/redoc", redoc_url: Optional[str] = "/redoc",
**extra: Dict[str, Any], **extra: Dict[str, Any],
) -> None: ) -> None:
self._debug = debug self._debug = debug
@ -43,7 +43,7 @@ class FastAPI(Starlette):
self.description = description self.description = description
self.version = version self.version = version
self.openapi_url = openapi_url self.openapi_url = openapi_url
self.swagger_ui_url = swagger_ui_url self.docs_url = docs_url
self.redoc_url = redoc_url self.redoc_url = redoc_url
self.extra = extra self.extra = extra
@ -53,7 +53,7 @@ class FastAPI(Starlette):
assert self.title, "A title must be provided for OpenAPI, e.g.: 'My API'" assert self.title, "A title must be provided for OpenAPI, e.g.: 'My API'"
assert self.version, "A version must be provided for OpenAPI, e.g.: '2.1.0'" assert self.version, "A version must be provided for OpenAPI, e.g.: '2.1.0'"
if self.swagger_ui_url or self.redoc_url: if self.docs_url or self.redoc_url:
assert self.openapi_url, "The openapi_url is required for the docs" assert self.openapi_url, "The openapi_url is required for the docs"
self.openapi_schema: Optional[Dict[str, Any]] = None self.openapi_schema: Optional[Dict[str, Any]] = None
self.setup() self.setup()
@ -76,9 +76,9 @@ class FastAPI(Starlette):
lambda req: JSONResponse(self.openapi()), lambda req: JSONResponse(self.openapi()),
include_in_schema=False, include_in_schema=False,
) )
if self.swagger_ui_url: if self.docs_url:
self.add_route( self.add_route(
self.swagger_ui_url, self.docs_url,
lambda r: get_swagger_ui_html( lambda r: get_swagger_ui_html(
openapi_url=self.openapi_url, title=self.title + " - Swagger UI" openapi_url=self.openapi_url, title=self.title + " - Swagger UI"
), ),

Loading…
Cancel
Save