Actions
CompressPdf #483
openDevelop GET /v1/ratings API
Start date:
10/15/2024
Due date:
10/15/2024 (about 18 months late)
% Done:
100%
Estimated time:
4:00 h
Description
Description:¶
The current implementation of the GET /v1/ratings API for retrieving tool ratings should follow standard RESTful practices, ensuring proper response structures, status codes, and validation for query parameters.
Query Parameters:¶
The tool_id parameter is required to fetch the ratings of a specific tool. Ensure proper validation for tool_id to confirm it is an integer and not missing from the query.
Status Codes:¶
- 200 OK: This should be returned when a valid tool_id is provided, and ratings are available for that tool.
Example response:¶
{
"tool_id": 1,
"average_rating": 4.5,
"total_ratings": 500,
"status": true
}
- 404 Not Found: This should be returned when there are no ratings for the given tool_id.
Example response:¶
{
"detail": "Rating not found for the given tool id",
"status": false
}
Response Structure:¶
- The successful response (200 OK) should return the tool_id, average_rating, total_ratings, and a status flag to indicate success.
- Error responses (404 Not Found) should return a clear error message in the detail field along with a status flag indicating failure.
Request Validation:¶
- Ensure that the tool_id is properly validated:
- It must be a valid integer.
- The tool_id must be present in the database; otherwise, return a 404 Not Found error.
Swagger Documentation:¶
- Ensure the Swagger documentation accurately reflects the query parameter (tool_id) and the response structure.
- Ensure that both 200 OK and 404 Not Found responses are properly documented.
Actions