Auto-generate OpenAPI servers from root_path (#1596)

* root_path included in servers object instead of path prefix

* ♻️ Refactor implementation of auto-including root_path in OpenAPI servers

* 📝 Update docs and examples for Behind a Proxy, including servers

* 📝 Update Extending OpenAPI as openapi_prefix is no longer needed

*  Add extra tests for root_path in servers and root_path_in_servers=False

* 🍱 Update security docs images with relative token URL

* 📝 Update security docs with relative token URL

* 📝 Update example sources with relative token URLs

*  Update tests with relative tokens

Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
This commit is contained in:
Rupsi Kaushik
2020-07-10 13:28:18 -04:00
committed by GitHub
parent 340a582be7
commit 70a51b3aff
35 changed files with 241 additions and 57 deletions

View File

@@ -9,7 +9,7 @@ async def read_items():
return [{"name": "Foo"}]
def custom_openapi(openapi_prefix: str):
def custom_openapi():
if app.openapi_schema:
return app.openapi_schema
openapi_schema = get_openapi(
@@ -17,7 +17,6 @@ def custom_openapi(openapi_prefix: str):
version="2.5.0",
description="This is a very custom OpenAPI schema",
routes=app.routes,
openapi_prefix=openapi_prefix,
)
openapi_schema["info"]["x-logo"] = {
"url": "https://fastapi.tiangolo.com/img/logo-margin/logo-teal.png"