Skip to content

feat(event-handler): add compress option when serving Swagger HTML #3946

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

Conversation

xquek
Copy link
Contributor

@xquek xquek commented Mar 13, 2024

Issue number: #3935

Summary

Changes

Added option to compress response for swagger UI page.

User experience

from aws_lambda_powertools import Logger, Tracer
from aws_lambda_powertools.event_handler import APIGatewayRestResolver
from aws_lambda_powertools.utilities.typing import LambdaContext

tracer = Tracer()
logger = Logger()
app = APIGatewayRestResolver(enable_validation=True)
app.enable_swagger(path="/swagger", compress=True)  


@app.get("/todos")
def get_todos():
    return {"todos": "todos"}


def lambda_handler(event: dict, context: LambdaContext) -> dict:
    return app.resolve(event, context)

Checklist

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

  • Meet tenets criteria
  • I have performed a self-review of this change
  • Changes have been tested
  • Changes are documented ( i have document this option in the docstring, i am not sure if this needs to be added to the README.md as well)
  • PR title follows conventional commit semantics
Is this a breaking change? No this is not a breaking change as the default is set to false (current behaviour) **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.

@xquek xquek requested a review from a team March 13, 2024 05:24
@pull-request-size pull-request-size bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Mar 13, 2024
Copy link

boring-cyborg bot commented Mar 13, 2024

Thanks a lot for your first contribution! Please check out our contributing guidelines and don't hesitate to ask whatever you need.
In the meantime, check out the #python channel on our Powertools for AWS Lambda Discord: Invite link

@xquek
Copy link
Contributor Author

xquek commented Mar 13, 2024

hi i didnt add any notes aws_lambda_powertools/event_handler/api_gateway.py let me know if i should! thank you!

Also looks like sonar is failing with too many parameters for the enable_swagger function. let me know if there is something that you will like me change

@github-actions github-actions bot added feature New feature or functionality labels Mar 13, 2024
@codecov-commenter
Copy link

codecov-commenter commented Mar 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.33%. Comparing base (e14e768) to head (1544951).
Report is 169 commits behind head on develop.

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

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3946      +/-   ##
===========================================
- Coverage    96.38%   96.33%   -0.05%     
===========================================
  Files          214      215       +1     
  Lines        10030    10251     +221     
  Branches      1846     1913      +67     
===========================================
+ Hits          9667     9875     +208     
- Misses         259      269      +10     
- Partials       104      107       +3     

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

@leandrodamascena leandrodamascena linked an issue Mar 13, 2024 that may be closed by this pull request
2 tasks
@boring-cyborg boring-cyborg bot added the documentation Improvements or additions to documentation label Mar 13, 2024
Copy link

Quality Gate Passed Quality Gate passed

Issues
0 New issues
1 Accepted issue

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

See analysis details on SonarCloud

@leandrodamascena leandrodamascena changed the title feat(event-handler): Add compress option to enable_swagger feat(event-handler): add compress option when serving Swagger HTML Mar 13, 2024
@github-actions github-actions bot removed the documentation Improvements or additions to documentation label Mar 13, 2024
@leandrodamascena
Copy link
Contributor

@rubenfonseca I need your review here, please.

@leandrodamascena
Copy link
Contributor

hi i didnt add any notes aws_lambda_powertools/event_handler/api_gateway.py let me know if i should! thank you!

Also looks like sonar is failing with too many parameters for the enable_swagger function. let me know if there is something that you will like me change

Hi @xquek! Yes, Sonar was complaining about too many parameters, but I marked it as "Will not fix" because we have nothing to do.
Thanks for working on this. I added some information in our documentation to help others with the same problem you had.

@boring-cyborg boring-cyborg bot added the documentation Improvements or additions to documentation label Mar 13, 2024
@github-actions github-actions bot removed the documentation Improvements or additions to documentation label Mar 13, 2024
@leandrodamascena leandrodamascena merged commit 946980d into aws-powertools:develop Mar 13, 2024
15 checks passed
Copy link

boring-cyborg bot commented Mar 13, 2024

Awesome work, congrats on your first merged pull request and thank you for helping improve everyone's experience!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
event_handlers feature New feature or functionality size/S Denotes a PR that changes 10-29 lines, ignoring generated files. tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: Add compression for swagger ui
4 participants