-
-
Notifications
You must be signed in to change notification settings - Fork 27
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
fix: Consistent response format #259
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #259 +/- ##
==========================================
- Coverage 95.06% 94.48% -0.58%
==========================================
Files 5 5
Lines 324 381 +57
==========================================
+ Hits 308 360 +52
- Misses 16 21 +5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
@ekas-7 per se it's a good idea, but as already said on other PRs we can't change the API without first verifying it does not break:
- the mobile app
- the open food facts website.
So to propose this PR, you must verify if it's causing problem for them, or not.
I will propose this in an issue @alexgarel in both repos |
Opened an issue in smooth app |
Opened in Web as well |
Standardize API Response Format
Description
This PR addresses issue #119 "Streamline and harmonize simple responses across API routes" by implementing a consistent response format across all endpoints in the Folksonomy API.
Previously, the API returned responses in various formats:
"ok"
{"detail": "message"}
{"detail": {"msg": "message"}}
This inconsistency made it difficult for API consumers to handle responses predictably.
Changes Made
Added a
SimpleResponse
model inmodels.py
with a standardized structure:Updated the
PingResponse
model to follow the same structure.Modified all endpoints that return simple responses to use this consistent format:
/product
endpoint (create)/product
endpoint (update)/product/{product}/{k}
endpoint (delete)/ping
endpointUpdated error responses to follow the same format.
Fixed empty array responses to return
[]
instead ofnull
when no data is found.Added
response_model=SimpleResponse
parameter to appropriate API routes for better documentation.Example Changes
Before:
After: