-
Notifications
You must be signed in to change notification settings - Fork 444
Open
Open
Copy link
Labels
good first issueGood for newcomersGood for newcomershelp wantedCould use a second pair of eyes/handsCould use a second pair of eyes/handsparserParser (Pydantic) utilityParser (Pydantic) utilitytech-debtTechnical Debt tasksTechnical Debt tasks
Description
Description
Enhance the S3 parser models with field descriptions and examples using Pydantic's Field()
functionality. This improvement will provide better documentation and metadata for S3 event parsing, following the pattern established in PR #7100.
Motivation
Currently, the S3 models lack detailed field documentation, making it harder for developers to:
- Understand field purposes without referencing external AWS documentation
- Generate rich API documentation with tools like Swagger/OpenAPI
- Create realistic test data using model factories
- Get helpful IntelliSense in IDEs
Proposed Changes
Add description
and examples
parameters to all fields in the following models using Field()
:
Files to modify:
aws_lambda_powertools/utilities/parser/models/s3.py
Reference events:
Check the sample events in tests/events/
for realistic field values:
s3Event.json
s3EventBatch.json
s3EventBridgeNotification.json
Implementation Requirements
- ✅ Add detailed
description
for each field explaining its purpose and usage - ✅ Include practical
examples
showing realistic AWS S3 values - ✅ Base descriptions on official AWS S3 documentation
- ✅ Maintain all existing functionality, types, and validation logic
- ✅ Follow the same pattern established in EventBridge, Kinesis, and ALB models
Example Implementation
# Before
class S3EventNotificationObjectModel(BaseModel):
key: str
size: Optional[NonNegativeFloat] = None
etag: str = Field(default="")
version_id: Optional[str] = Field(None, alias="version-id")
sequencer: Optional[str] = None
# After
class S3EventNotificationObjectModel(BaseModel):
key: str = Field(
description="The object key (file name) of the S3 object.",
examples=[
"my-image.jpg",
"documents/report.pdf",
"logs/2023/01/15/app.log"
]
)
size: Optional[NonNegativeFloat] = Field(
None,
description="The size of the object in bytes.",
examples=[1024, 2048576, 0]
)
etag: str = Field(
default="",
description="The entity tag (ETag) of the object.",
examples=[
"d41d8cd98f00b204e9800998ecf8427e",
"098f6bcd4621d373cade4e832627b4f6"
]
)
version_id: Optional[str] = Field(
None,
alias="version-id",
description="The version ID of the object (if versioning is enabled).",
examples=[
"096fKKXTRTtl3on89fVO.nfljtsv6qko",
"null"
]
)
sequencer: Optional[str] = Field(
None,
description="A string representation of a hexadecimal value used to determine event sequence.",
examples=[
"0A1B2C3D4E5F678901",
"005B21C13A6F24045E"
]
)
Benefits
For Developers
- Better IntelliSense with field descriptions and example values
- Self-documenting code without needing external AWS documentation
- Faster development with immediate reference for acceptable values
For Documentation Tools
- Rich Swagger/OpenAPI docs via .model_json_schema()
- Automated documentation generation with comprehensive metadata
- Interactive documentation with practical examples
Getting Started
This is a great first issue for newcomers to Powertools for AWS! The task is straightforward and helps you get familiar with our codebase structure.
Need help?
We're here to support you! Feel free to:
- Ask questions in the comments
- Request guidance on implementation approach
Acknowledgment
- This request meets Powertools for AWS Lambda (Python) Tenets
- Should this be considered in other Powertools for AWS Lambda languages? i.e. Java, TypeScript, and .NET
Metadata
Metadata
Assignees
Labels
good first issueGood for newcomersGood for newcomershelp wantedCould use a second pair of eyes/handsCould use a second pair of eyes/handsparserParser (Pydantic) utilityParser (Pydantic) utilitytech-debtTechnical Debt tasksTechnical Debt tasks
Type
Projects
Status
Backlog