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(event_handler): add support for multiValueQueryStringParameters in OpenAPI schema #3667

Merged

Conversation

leandrodamascena
Copy link
Contributor

Issue number: #3622

Summary

Changes

This pull request enhances the OpenAPI utility by introducing support for multiValueQueryStringParameters in the OpenAPI schema. Previously, our utility encountered issues parsing multi-value query fields, leading to errors for customers attempting to utilize such fields. Work did:

  • Added support for multiValueQueryStringParameters in the OpenAPI schema.
  • Resolved parsing issues previously encountered when dealing with multi-value fields in different Resolvers.
  • Added new tests

User experience

Using the code below now we can validate multi value param.

from enum import Enum
from http import HTTPStatus

from aws_lambda_powertools.event_handler import APIGatewayRestResolver
from aws_lambda_powertools.event_handler.openapi.params import Query
from aws_lambda_powertools.shared.types import Annotated
from aws_lambda_powertools.utilities.typing import LambdaContext

app = APIGatewayRestResolver(enable_validation=True)


class ExampleEnum(Enum):
    """Example of an Enum class."""

    ONE = "value_one"
    TWO = "value_two"
    THREE = "value_three"


@app.get("/example-resource")
def get(
    example_multi_value_param: Annotated[
        ExampleEnum,
        Query(
            description="This should be a multi value query parameter."
        ),  # TODO: How should this represent multi-value query string parameters?
    ]
):
    """Return validated multi-value param values."""
    return example_multi_value_param


def lambda_handler(event: dict, context: LambdaContext):
    """Handler to route API Gateway events."""
    return app.resolve(event, context)

image

Checklist

If your change doesn't seem to apply, please leave them unchecked.

Is this a breaking change?

RFC issue number:

Checklist:

  • Migration process documented
  • Implement warnings (if it can live side by side)

Acknowledgment

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.

@pull-request-size pull-request-size bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Jan 23, 2024
@codecov-commenter
Copy link

codecov-commenter commented Jan 23, 2024

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (517acd6) 95.57% compared to head (ee83b1b) 95.65%.
Report is 5 commits behind head on develop.

Files Patch % Lines
...lambda_powertools/utilities/data_classes/common.py 66.66% 1 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3667      +/-   ##
===========================================
+ Coverage    95.57%   95.65%   +0.07%     
===========================================
  Files          214      214              
  Lines         9993    10031      +38     
  Branches      1827     1840      +13     
===========================================
+ Hits          9551     9595      +44     
+ Misses         329      326       -3     
+ Partials       113      110       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@boring-cyborg boring-cyborg bot added the documentation Improvements or additions to documentation label Jan 23, 2024
@leandrodamascena leandrodamascena linked an issue Jan 23, 2024 that may be closed by this pull request
@leandrodamascena leandrodamascena marked this pull request as ready for review January 23, 2024 13:35
@leandrodamascena leandrodamascena requested a review from a team as a code owner January 23, 2024 13:35
Copy link
Contributor

@rubenfonseca rubenfonseca left a comment

Choose a reason for hiding this comment

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

Great job diving deep into OpenAPI :D Just left some small things

@leandrodamascena
Copy link
Contributor Author

Great job diving deep into OpenAPI :D Just left some small things

Thanks @rubenfonseca! Can you review it again pls?

Copy link

Quality Gate Passed Quality Gate passed

The SonarCloud Quality Gate passed, but some issues were introduced.

1 New issue
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

Copy link
Contributor

@rubenfonseca rubenfonseca left a comment

Choose a reason for hiding this comment

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

Great job, I've also checked the highlights in the documentation and it looks good!

@leandrodamascena leandrodamascena merged commit 0519fa3 into aws-powertools:develop Jan 23, 2024
16 checks passed
@leandrodamascena leandrodamascena deleted the query-headers-params branch January 23, 2024 15:09
@leandrodamascena leandrodamascena restored the query-headers-params branch January 30, 2024 23:17
@leandrodamascena leandrodamascena deleted the query-headers-params branch January 30, 2024 23:19
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 event_handlers size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: OpenAPI doesnt support multiValueQueryStringParameters
3 participants