Browse Source

Add prefix parameter for get_openapi function

pull/4657/head
Lorhan Sohaky 3 years ago
parent
commit
c71016a19b
  1. 3
      fastapi/openapi/utils.py

3
fastapi/openapi/utils.py

@ -393,6 +393,7 @@ def get_openapi(
terms_of_service: Optional[str] = None, terms_of_service: Optional[str] = None,
contact: Optional[Dict[str, Union[str, Any]]] = None, contact: Optional[Dict[str, Union[str, Any]]] = None,
license_info: Optional[Dict[str, Union[str, Any]]] = None, license_info: Optional[Dict[str, Union[str, Any]]] = None,
prefix: Optional[str] = None,
) -> Dict[str, Any]: ) -> Dict[str, Any]:
info: Dict[str, Any] = {"title": title, "version": version} info: Dict[str, Any] = {"title": title, "version": version}
if description: if description:
@ -421,6 +422,8 @@ def get_openapi(
) )
if result: if result:
path, security_schemes, path_definitions = result path, security_schemes, path_definitions = result
if prefix:
route.path_format= prefix + route.path_format
if path: if path:
paths.setdefault(route.path_format, {}).update(path) paths.setdefault(route.path_format, {}).update(path)
if security_schemes: if security_schemes:

Loading…
Cancel
Save