-
Notifications
You must be signed in to change notification settings - Fork 403
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): mark API operation as deprecated for OpenAPI documentation #5732
feat(event_handler): mark API operation as deprecated for OpenAPI documentation #5732
Conversation
Thanks a lot for your first contribution! Please check out our contributing guidelines and don't hesitate to ask whatever you need. |
TODOTesting:
Documentation:
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #5732 +/- ##
========================================
Coverage 96.17% 96.17%
========================================
Files 231 231
Lines 10920 10922 +2
Branches 2019 2019
========================================
+ Hits 10502 10504 +2
Misses 329 329
Partials 89 89 ☔ View full report in Codecov by Sentry. |
I would also ask for some help with adding an entry into
I cannot get |
Hello everyone! I'm starting the review! Thanks for your patience @tcysin. I'll check all your comments and respond. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @tcysin! Thanks a lot for working on this, we completely missed that field. Sorry for the delay in responding and reviewing, but you know, the year is almost over and people are on annual leave.
Please let me know if you need help to address the comments.
Hey, what is going on here? Can you please paste the error? |
Oh my bad, I run Linux Mint 21.3 Cinnamon as an operating system, and installed Docker using the Software Manager. 👉 To run Docker commands, I must use
If I run Docker commands without $ docker run hello-world
docker: permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/containers/create": dial unix /var/run/docker.sock: connect: permission denied.
See 'docker run --help'. When I try to add the documentation and commit, I get this: $ git commit -m "Add parameter description to Markdown docs"
[WARNING] Unstaged files detected.
[INFO] Stashing unstaged files to /home/tcysin/.cache/pre-commit/patch1734636743-94026.
check for merge conflicts................................................Passed
trim trailing whitespace.................................................Passed
check toml...........................................(no files to check)Skipped
formatting::black....................................(no files to check)Skipped
linting-format::ruff.................................(no files to check)Skipped
markdownlint-docker......................................................Failed
- hook id: markdownlint-docker
- exit code: 126
docker: permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/containers/create": dial unix /var/run/docker.sock: connect: permission denied.
See 'docker run --help'.
linting::cloudformation..............................(no files to check)Skipped
Lint GitHub Actions workflow file Docker.............(no files to check)Skipped
Terraform fmt........................................(no files to check)Skipped
Detect hardcoded secrets.................................................Passed
[INFO] Restored changes from /home/tcysin/.cache/pre-commit/patch1734636743-94026. Pre-commit fails when running
Here's me running that same hook directly: $ pre-commit run markdownlint-docker --verbose
[WARNING] Unstaged files detected.
[INFO] Stashing unstaged files to /home/tcysin/.cache/pre-commit/patch1734636928-95070.
markdownlint-docker......................................................Failed
- hook id: markdownlint-docker
- duration: 0.02s
- exit code: 126
docker: permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/containers/create": dial unix /var/run/docker.sock: connect: permission denied.
See 'docker run --help'.
[INFO] Restored changes from /home/tcysin/.cache/pre-commit/patch1734636928-95070. I'm afraid, I don't know how to make the hook run Docker with |
Quality Gate passedIssues Measures |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @tcysin! I made some changes to this PR and let me explain those:
1 - I simplified the condition where you check self.deprecated.
2 - I understand where you're going with the change in middlewares merge method (and the defaultdict definition) and that's really cool, but I don't know if we'll have any side effects if we don't define self._routes_with_middleware[route_key] = []
.
3 - I added a new test just to make sure we are not serializing the None value.
4 - I added the line you suggested in the documentation.
Again, thanks a lot for working on this PR!!
APPROVED!
Hmm the |
Hey @anafalcao, please approve this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! Approving this PR
Awesome work, congrats on your first merged pull request and thank you for helping improve everyone's experience! |
This works 👍 Once again, thanks for your help! |
🎉 It's alive as of 3.4.0! Codefrom aws_lambda_powertools.event_handler import APIGatewayRestResolver
from aws_lambda_powertools.event_handler.api_gateway import Router
app = APIGatewayRestResolver()
@app.get("/spam")
def spam():
return
@app.get("/eggs", deprecated=True)
def eggs():
return
router = Router()
@router.get("/ham", deprecated=True)
def ham():
return
app.include_router(router, "/cheese")
if __name__ == "__main__":
schema = app.get_openapi_json_schema()
print(schema) Generated JSON schemaSwagger Editor screenshot |
Thats amazing @tcysin! Nice work 👏👏👏 |
Issue number: #5674
Summary
Add support for marking API operations as
deprecated
for OpenAPI documentation.Changes
deprecated
parameter with default valueFalse
for all named decorators (get
,post
,put
,delete
,patch
,head
) inApiGatewayResolver
,ApiGatewayRestResolver
,BedrockAgentResolver
andRouter
.include_router
.collections.defaultdict
.User experience
Checklist
If your change doesn't seem to apply, please leave them unchecked.
Is this a breaking change?
RFC issue number:
Checklist:
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.