Skip to content

Commit d3b3daa

Browse files
Adding constants
1 parent 0773bcc commit d3b3daa

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

aws_lambda_powertools/event_handler/api_gateway.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@
1919
from aws_lambda_powertools.event_handler import content_types
2020
from aws_lambda_powertools.event_handler.exceptions import NotFoundError, ServiceError
2121
from aws_lambda_powertools.event_handler.openapi.config import OpenAPIConfig
22-
from aws_lambda_powertools.event_handler.openapi.constants import DEFAULT_API_VERSION, DEFAULT_OPENAPI_VERSION
22+
from aws_lambda_powertools.event_handler.openapi.constants import (
23+
DEFAULT_API_VERSION,
24+
DEFAULT_OPENAPI_TITLE,
25+
DEFAULT_OPENAPI_VERSION,
26+
)
2327
from aws_lambda_powertools.event_handler.openapi.exceptions import RequestValidationError, SchemaValidationError
2428
from aws_lambda_powertools.event_handler.openapi.types import (
2529
COMPONENT_REF_PREFIX,
@@ -1546,7 +1550,7 @@ def __init__(
15461550
def get_openapi_schema(
15471551
self,
15481552
*,
1549-
title: str = "Powertools for AWS Lambda (Python) API",
1553+
title: str = DEFAULT_OPENAPI_TITLE,
15501554
version: str = DEFAULT_API_VERSION,
15511555
openapi_version: str = DEFAULT_OPENAPI_VERSION,
15521556
summary: str | None = None,
@@ -1601,7 +1605,7 @@ def get_openapi_schema(
16011605
# DEPRECATION: Will be removed in v4.0.0. Use configure_api() instead.
16021606
# Maintained for backwards compatibility.
16031607
# See: https://github.com/aws-powertools/powertools-lambda-python/issues/6122
1604-
if title == "Powertools for AWS Lambda (Python) API" and self.openapi_config.title:
1608+
if title == DEFAULT_OPENAPI_TITLE and self.openapi_config.title:
16051609
title = self.openapi_config.title
16061610

16071611
if version == DEFAULT_API_VERSION and self.openapi_config.version:
@@ -1751,7 +1755,7 @@ def _determine_openapi_version(openapi_version: str):
17511755
def get_openapi_json_schema(
17521756
self,
17531757
*,
1754-
title: str = "Powertools for AWS Lambda (Python) API",
1758+
title: str = DEFAULT_OPENAPI_TITLE,
17551759
version: str = DEFAULT_API_VERSION,
17561760
openapi_version: str = DEFAULT_OPENAPI_VERSION,
17571761
summary: str | None = None,
@@ -1828,7 +1832,7 @@ def get_openapi_json_schema(
18281832

18291833
def configure_openapi(
18301834
self,
1831-
title: str = "Powertools for AWS Lambda (Python) API",
1835+
title: str = DEFAULT_OPENAPI_TITLE,
18321836
version: str = DEFAULT_API_VERSION,
18331837
openapi_version: str = DEFAULT_OPENAPI_VERSION,
18341838
summary: str | None = None,
@@ -1913,7 +1917,7 @@ def enable_swagger(
19131917
self,
19141918
*,
19151919
path: str = "/swagger",
1916-
title: str = "Powertools for AWS Lambda (Python) API",
1920+
title: str = DEFAULT_OPENAPI_TITLE,
19171921
version: str = DEFAULT_API_VERSION,
19181922
openapi_version: str = DEFAULT_OPENAPI_VERSION,
19191923
summary: str | None = None,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
DEFAULT_API_VERSION = "1.0.0"
22
DEFAULT_OPENAPI_VERSION = "3.1.0"
3+
DEFAULT_OPENAPI_TITLE = "Powertools for AWS Lambda (Python) API"

0 commit comments

Comments
 (0)