Skip to content

feat(event_handler): add custom method for OpenAPI configuration #6204

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 10 commits into from
Mar 17, 2025

Conversation

leandrodamascena
Copy link
Contributor

Issue number: #6122

Summary

Changes

This PR introduces a new method configure_openapi() to simplify OpenAPI configuration while maintaining backwards compatibility.

Currently, OpenAPI configuration must be specified in both enable_swagger() and get_openapi_json_schema() methods, leading to:

  • Duplication of configuration
  • Inconsistent documentation when configurations differ
  • More complex maintenance

User experience

Introduce a new configure_openapi() method while preserving existing functionality:

from aws_lambda_powertools.event_handler import APIGatewayRestResolver

app = APIGatewayRestResolver(enable_validation=True)
# New configuration approach
app.configure_openapi(
    title="My API",
    version="1.0.0",
    description="API Description"
)

# Existing methods continue to work
app.enable_swagger(path="/docs")  # Uses configured values

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.

@leandrodamascena leandrodamascena requested a review from a team as a code owner March 3, 2025 16:55
@pull-request-size pull-request-size bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Mar 3, 2025
@leandrodamascena leandrodamascena linked an issue Mar 3, 2025 that may be closed by this pull request
2 tasks
@leandrodamascena leandrodamascena self-assigned this Mar 3, 2025
@github-actions github-actions bot added feature New feature or functionality and removed internal Maintenance changes labels Mar 3, 2025
Copy link

codecov bot commented Mar 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.32%. Comparing base (7e56fe1) to head (6a30901).
Report is 1 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #6204      +/-   ##
===========================================
+ Coverage    96.30%   96.32%   +0.01%     
===========================================
  Files          240      241       +1     
  Lines        11596    11633      +37     
  Branches       862      864       +2     
===========================================
+ Hits         11168    11205      +37     
  Misses         336      336              
  Partials        92       92              

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

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@boring-cyborg boring-cyborg bot added the internal Maintenance changes label Mar 3, 2025
@github-actions github-actions bot removed the internal Maintenance changes label Mar 3, 2025
@boring-cyborg boring-cyborg bot added the internal Maintenance changes label Mar 3, 2025
@github-actions github-actions bot removed the internal Maintenance changes label Mar 3, 2025
@boring-cyborg boring-cyborg bot added documentation Improvements or additions to documentation internal Maintenance changes labels Mar 3, 2025
@github-actions github-actions bot removed documentation Improvements or additions to documentation internal Maintenance changes labels Mar 3, 2025
@boring-cyborg boring-cyborg bot added documentation Improvements or additions to documentation internal Maintenance changes labels Mar 3, 2025
@github-actions github-actions bot removed documentation Improvements or additions to documentation internal Maintenance changes labels Mar 3, 2025
@boring-cyborg boring-cyborg bot added the documentation Improvements or additions to documentation label Mar 7, 2025
@github-actions github-actions bot removed the internal Maintenance changes label Mar 9, 2025
@boring-cyborg boring-cyborg bot added documentation Improvements or additions to documentation internal Maintenance changes labels Mar 10, 2025
@github-actions github-actions bot removed documentation Improvements or additions to documentation internal Maintenance changes labels Mar 10, 2025
@boring-cyborg boring-cyborg bot added commons dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation internal Maintenance changes labels Mar 17, 2025
@pull-request-size pull-request-size bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 17, 2025
@pull-request-size pull-request-size bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Mar 17, 2025
@leandrodamascena
Copy link
Contributor Author

@leandrodamascena leandrodamascena requested review from dreamorosi and removed request for dreamorosi March 17, 2025 15:28
dreamorosi
dreamorosi previously approved these changes Mar 17, 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.

Left only one comment about a default value, other than that it looks good.

Great improvement for customers!

@leandrodamascena leandrodamascena merged commit e002d5c into develop Mar 17, 2025
12 checks passed
@leandrodamascena leandrodamascena deleted the openapi/common-method branch March 17, 2025 16:04
@github-actions github-actions bot removed documentation Improvements or additions to documentation internal Maintenance changes labels Mar 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
commons dependencies Pull requests that update a dependency file event_handlers feature New feature or functionality size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: Improve OpenAPI configuration with a common method
2 participants