8000 Merge branch 'develop' into rf/bedrock-agents-docs · ericbn/powertools-lambda-python@f54a585 · GitHub
[go: up one dir, main page]

Skip to content 8000

Commit f54a585

Browse files
Merge branch 'develop' into rf/bedrock-agents-docs
2 parents c729d29 + e34f719 commit f54a585

File tree

6 files changed

+38
-12
lines changed

6 files changed

+38
-12
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
## Maintenance
88

9+
* **deps-dev:** bump cfn-lint from 0.83.7 to 0.83.8 ([#3603](https://github.com/aws-powertools/powertools-lambda-python/issues/3603))
910

1011

1112
<a name="v2.31.0"></a>

aws_lambda_powertools/event_handler/api_gateway.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1627,7 +1627,7 @@ def swagger_handler():
16271627

16281628
openapi_servers = servers or [Server(url=(base_path or "/"))]
16291629

1630-
spec = self.get_openapi_json_schema(
1630+
spec = self.get_openapi_schema(
16311631
title=title,
16321632
version=version,
16331633
openapi_version=openapi_version,

aws_lambda_powertools/event_handler/openapi/swagger_ui/html.py

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,35 @@
1-
def generate_swagger_html(spec: str, js_url: str, css_url: str) -> str:
1+
from typing import TYPE_CHECKING
2+
3+
if TYPE_CHECKING:
4+
from aws_lambda_powertools.event_handler.openapi.models import OpenAPI
5+
6+
7+
def generate_swagger_html(spec: "OpenAPI", js_url: str, css_url: str) -> str:
28
"""
39
Generate Swagger UI HTML page
410
511
Parameters
612
----------
7-
spec: str
8-
The OpenAPI spec in the JSON format
13+
spec: OpenAPI
14+
The OpenAPI spec
915
js_url: str
1016
The URL to the Swagger UI JavaScript file
1117
css_url: str
1218
The URL to the Swagger UI CSS file
1319
"""
20+
21+
from aws_lambda_powertools.event_handler.openapi.compat import model_json
22+
23+
# The .replace('</', '<\\/') part is necessary to prevent a potential issue where the JSON string contains
24+
# </script> or similar tags. Escaping the forward slash in </ as <\/ ensures that the JSON does not inadvertently
25+
# close the script tag, and the JSON remains a valid string within the JavaScript code.
26+
escaped_spec = model_json(
27+
spec,
28+
by_alias=True,
29+
exclude_none=True,
30+
indent=2,
31+
).replace("</", "<\\/")
32+
1433
return f"""
1534
<!DOCTYPE html>
1635
<html>
@@ -41,9 +60,7 @@ def generate_swagger_html(spec: str, js_url: str, css_url: str) -> str:
4160
layout: "BaseLayout",
4261
showExtensions: true,
4362
showCommonExtensions: true,
44-
spec: JSON.parse(`
45-
{spec}
46-
`.trim()),
63+
spec: {escaped_spec},
4764
presets: [
4865
SwaggerUIBundle.presets.apis,
4966
SwaggerUIBundle.SwaggerUIStandalonePreset

docs/we_made_this.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,14 @@ This blog post focuses on the importance of idempotency in distributed services
9696

9797
* [Implementing Idempotency in Serverless Architectures](https://medium.com/@nuatmochoi/implementing-idempotency-in-serverless-architectures-f9079ef1c7da){target="_blank" rel="nofollow"}
9898

99+
### Creating a serverless API using Powertools for AWS Lambda and AWS CDK
100+
101+
This blog post showcases how to use AWS CDK and Powertools for AWS Lambda, along with Amazon API Gateway and AWS Lambda, to effortlessly deploy scalable infrastructure with just a few lines of code.
102+
103+
> **Author: [Thomas Taylor](https://www.linkedin.com/in/iamthomastaylor/){target="_blank" rel="nofollow"}** :material-linkedin:
104+
105+
[Creating a serverless API using Powertools for AWS Lambda and CDK](https://how.wtf/creating-a-serverless-api-using-aws-lambda-powertools-and-cdk.html){target="_blank" rel="nofollow"}
106+
99107
## Videos
100108

101109
#### Building a resilient input handling with Parser

poetry.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ datadog = ["datadog-lambda"]
102102
datamasking-aws-sdk = ["aws-encryption-sdk"]
103103

104104
[tool.poetry.group.dev.dependencies]
105-
cfn-lint = "0.83.7"
105+
cfn-lint = "0.83.8"
106106
mypy = "^1.1.1"
107107
types-python-dateutil = "^2.8.19.6"
108108
httpx = ">=0.23.3,<0.25.0"

0 commit comments

Comments
 (0)
0