Skip to content

fix(event_handler): allow responses and metadata when using Router #3514

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

Merged
merged 3 commits into from
Dec 15, 2023

Conversation

rubenfonseca
Copy link
Contributor

Issue number: #3506

Summary

Changes

Please provide a summary of what's being changed

Some of the new additions related to OpenAPI support added non-hashable elements to the route key when using the built-in Router.
This made the code crash. With this change, we convert all those new parameters into hashable equivalents.

User experience

Please share what the user experience looks like before and after this change

The following code now works:

router = Router()

@router.put("/example-resource", responses={200: {"description": "Custom response"}}, tags=["example"])
def handler():
    pass

app = APIGatewayRestResolver(enable_validation=True)
app.include_router(router)

schema = app.get_openapi_schema()
put = schema.paths["/example-resource"].put
assert len(put.tags) == 1
assert puts.tags[0].name == "example"
assert 200 in put.responses.keys()
assert put.responses[200].description == "Custom response"

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/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Dec 15, 2023
@rubenfonseca rubenfonseca marked this pull request as ready for review December 15, 2023 12:18
@rubenfonseca rubenfonseca requested a review from a team December 15, 2023 12:18
@codecov-commenter
Copy link

codecov-commenter commented Dec 15, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (4cfe976) 95.78% compared to head (2c7ca54) 95.78%.
Report is 1 commits behind head on develop.

❗ Current head 2c7ca54 differs from pull request most recent head 6332ca7. Consider uploading reports for the commit 6332ca7 to get more accurate results

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

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #3514   +/-   ##
========================================
  Coverage    95.78%   95.78%           
========================================
  Files          209      210    +1     
  Lines         9675     9681    +6     
  Branches      1774     1774           
========================================
+ Hits          9267     9273    +6     
  Misses         294      294           
  Partials       114      114           

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

@heitorlessa
Copy link
Contributor

looking... 👀

Copy link
Contributor

@heitorlessa heitorlessa left a comment

Choose a reason for hiding this comment

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

let's add a note to refactor that tuple into a class for better encapsulation and growth

Copy link

Quality Gate Passed Quality Gate passed

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

2 New issues
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@heitorlessa heitorlessa merged commit ebb10ea into develop Dec 15, 2023
@heitorlessa heitorlessa deleted the rf/fix-router-openapi branch December 15, 2023 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
event_handlers size/M Denotes a PR that changes 30-99 lines, ignoring generated files. tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: APIGatewayRestResolver - openAPI metadata responses / tags on @router fails with unhashable type: dict
3 participants