-
Notifications
You must be signed in to change notification settings - Fork 428
feat(event_handler): add support to download OpenAPI spec file #3571
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 to download OpenAPI spec file #3571
Conversation
Thanks a lot for your first contribution! Please check out our contributing guidelines and don't hesitate to ask whatever you need. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## develop #3571 +/- ##
========================================
Coverage 95.78% 95.78%
========================================
Files 210 210
Lines 9686 9688 +2
Branches 1774 1775 +1
========================================
+ Hits 9278 9280 +2
Misses 294 294
Partials 114 114 ☔ View full report in Codecov by Sentry. |
Hi @Thomas-McKanna! I'm unsure if we would set this parameter to We can keep it as False by default and hear from others before merging. |
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 @Thomas-McKanna! Thanks a lot for sending this PR, I left some comments.
We need to create some additional tests to check if we propagate/use this new parameter. Can you add this, please?
Co-authored-by: Leandro Damascena <[email protected]> Signed-off-by: Thomas McKanna <[email protected]>
@leandrodamascena I added a couple of tests to ensure this feature is working with the default path ( |
Hi @Thomas-McKanna! Comment here instead of the initial conversation because it is more visible to everyone. I had a conversation with @rubenfonseca - who created the OpenAPI feature in Powertools - and the main reason we inject OpenAPI spec into the configuration (using <script>
var swaggerUIOptions = {{
dom_id: "#swagger-ui",
.
.
spec: JSON.parse(`
{spec}
`.trim()),
.
.
}}
var ui = SwaggerUIBundle(swaggerUIOptions)
ui.specActions.updateUrl('{URL}/{PATH}.json'); // NEW LINE
</script> We agree that enabling it with a conditional query string is a good approach and we can remove the Thanks for addressing all the feedback and participating in this discussion, Thomas! We always try to find the best experience for our customers and avoid breaking anything. |
Sounds good @leandrodamascena, I will get these changes committed soon! |
@leandrodamascena I have implemented the requested changes. Now the OpenAPI spec JSON can be fetched by setting the ![]() I also removed the documentation section I had added. Let me know if you'd like me to change anything. |
Hey @Thomas-McKanna! Thanks for addressing the feedback! I'll review this tomorrow and I expect to merge this before our next release! |
|
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.
@Thomas-McKanna I resolved a conflict we had due to a PR we merged today and made a small change, but nothing that changes your logic.
@rubenfonseca please review this PR.
Awesome work, congrats on your first merged pull request and thank you for helping improve everyone's experience! |
Issue number: #3560
Summary
This feature allows for setting the
enable_download_spec
in theenable_swagger
function so that the OpenAPI specification file can be download for use generating client libraries, hosted documentation external, or for another reason.Usage would look like:
As I was working on this task, I came to think that it might be better to just expose the JSON endpoint by default rather
than require the user to opt-in. I don't see how adding this feature as default would break existing deployments, and would cut down the number of steps for a user to use the feature from two steps (adding
enable_download_spec
parameter and adding endpoint in SAM template) to one step (adding endpoint in SAM template). What are thoughts on this?Changes
Update - 09/01/2024
We decided to drop the
enable_download_spec=True
flag. We added a querystring parameter (?format=json) along the /swagger route.User experience
Additional flexibility of the OpenAPI feature.
Checklist
If your change doesn't seem to apply, please leave them unchecked.
Is this a breaking change? No.
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.