Description
Enhance the SQS parser models with field descriptions and examples using Pydantic's Field() functionality. This improvement will provide better documentation and metadata for SQS event parsing, following the pattern established in PR #7100.
Motivation
Currently, the SQS 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/sqs.py
Reference events:
Check the sample events in tests/events/ for realistic field values:
sqsEvent.json
sqsEventBatch.json
Implementation Requirements
- ✅ Add detailed
description for each field explaining its purpose and usage
- ✅ Include practical
examples showing realistic AWS SQS values
- ✅ Base descriptions on official AWS SQS documentation
- ✅ Maintain all existing functionality, types, and validation logic
- ✅ Follow the same pattern established in EventBridge, Kinesis, and ALB models
Example Implementation
# Before
class SqsRecordModel(BaseModel):
message_id: str
receipt_handle: str
body: str
attributes: SqsAttributesModel
# After
class SqsRecordModel(BaseModel):
message_id: str = Field(
description="A unique identifier for the message.",
examples=[
"19dd0b57-b21e-4ac1-bd88-01bbb068cb78",
"059f36b4-87a3-44ab-83d2-661975830a7d"
]
)
receipt_handle: str = Field(
description="An identifier associated with the act of receiving the message.",
examples=[
"MessageReceiptHandle",
"AQEBwJnKyrHigUMZj6rYigCgxlaS3SLy0a..."
]
)
body: str = Field(
description="The message's contents (not URL-encoded).",
examples=[
"Hello from SQS!",
'{"key": "value", "message": "test"}'
]
)
attributes: SqsAttributesModel = Field(
description="A map of the attributes requested in ReceiveMessage to their respective values."
)
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
Description
Enhance the SQS parser models with field descriptions and examples using Pydantic's
Field()functionality. This improvement will provide better documentation and metadata for SQS event parsing, following the pattern established in PR #7100.Motivation
Currently, the SQS models lack detailed field documentation, making it harder for developers to:
Proposed Changes
Add
descriptionandexamplesparameters to all fields in the following models usingField():Files to modify:
aws_lambda_powertools/utilities/parser/models/sqs.pyReference events:
Check the sample events in
tests/events/for realistic field values:sqsEvent.jsonsqsEventBatch.jsonImplementation Requirements
descriptionfor each field explaining its purpose and usageexamplesshowing realistic AWS SQS valuesExample Implementation
Benefits
For Developers
For Documentation Tools
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:
Acknowledgment