-
-
Notifications
You must be signed in to change notification settings - Fork 35
feat: improve Swagger authentication UX with Bearer scheme #338
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
base: main
Are you sure you want to change the base?
feat: improve Swagger authentication UX with Bearer scheme #338
Conversation
VaiTon
left a comment
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.
What is this? You removed almost all the API routes...
8b24779 to
a46a1f4
Compare
|
Thanks for pointing that out — you were absolutely right 👍 That comment was based on an earlier commit where api.py was accidentally overwritten, which removed many routes. I’ve fixed that mistake and force-pushed a corrected commit. Current state (commit a46a1f4):
No authentication or business logic was modified. Please let me know if you’d like me to split this into a smaller change or adjust anything further. |
|
how did you test this? can you share any ss to validate? |
|
@MaramMaruthiChethan I'm still not quite sure about what this PR does. We already have the "Authenticate" button on https://api.folksonomy.openfoodfacts.org/docs (which, by the way, has an expired cert cc @alexgarel). Maybe I'm missing something. Can you explain what we get by overriding the |
|
Thanks for the questions — let me clarify what this PR does, why it changes OpenAPI generation, and how it was tested. Ran the API locally Opened /docs and verified: Bearer-based “Authorize” modal is present Tokens are correctly injected as Authorization: Bearer Protected endpoints show as secured Swagger loads without DB-related errors Confirmed the diff only affects OpenAPI security configuration (no routes added/removed) If helpful, I can share before/after screenshots of the Swagger UI to validate the UX change. Happy to adjust or simplify further if you’d prefer a different approach — thanks for the review 🙌 |
Summary
This PR improves the Swagger/OpenAPI configuration by adding a proper
HTTP Bearer authentication scheme.
What was changed
Why
Previously, Swagger UI did not provide a clear way to authenticate before
testing protected endpoints. This change makes authentication explicit
and usable for contributors, addressing issue #110.
Notes
Authentication relies on existing Open Food Facts user accounts.
No changes were made to the authentication logic itself.