Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(parser): add schema support for API Gateway WebSocket events #3807

Merged

Conversation

VatsalGoel3
Copy link
Contributor

@VatsalGoel3 VatsalGoel3 commented Apr 4, 2025

Summary

Changes

Added schema support for API Gateway WebSocket events to the Parser utility.

This PR introduces a new schema named APIGatewayProxyWebsocketEventSchema under packages/parser/src/schemas/api-gateway-websocket.ts. It enables developers to validate and parse WebSocket Lambda events using @aws-lambda-powertools/parser.

Additionally:

  • Added test event file at packages/parser/tests/events/apigw-websocket/connectEvent.json
  • Added corresponding unit tests in packages/parser/tests/unit/schema/apigw-websocket.test.ts using the getTestEvent utility
  • Schema supports all documented fields including headers, multiValueHeaders, queryStringParameters, stageVariables, requestContext, and body

This schema follows the same structure as other API Gateway events and enables first-class support for $connect, $disconnect, and $message WebSocket routes in Lambda.

Please add the issue number below, if no issue is present the PR might get blocked and not be reviewed

Issue number: closes #3787


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

@boring-cyborg boring-cyborg bot added parser This item relates to the Parser Utility tests PRs that add or change tests labels Apr 4, 2025
@pull-request-size pull-request-size bot added the size/L PRs between 100-499 LOC label Apr 4, 2025
Copy link
Contributor

@dreamorosi dreamorosi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

I've left a couple minor comments but the PR looks good. Can you also add the new schema to the table in docs/utilities/parser.md here.

@github-actions github-actions bot added the feature PRs that introduce new features or minor changes label Apr 5, 2025
@boring-cyborg boring-cyborg bot added the documentation Improvements or additions to documentation label Apr 5, 2025
@VatsalGoel3
Copy link
Contributor Author

@dreamorosi, I have made the required changes

Copy link

sonarqubecloud bot commented Apr 5, 2025

Copy link
Contributor

@dreamorosi dreamorosi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

@dreamorosi dreamorosi merged commit 663d328 into aws-powertools:main Apr 5, 2025
43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation feature PRs that introduce new features or minor changes parser This item relates to the Parser Utility size/L PRs between 100-499 LOC tests PRs that add or change tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: implement APIGatewayProxyWebsocketEventSchema
2 participants