-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Description
Develop an endpoint to handle requests to fetch and return the details of a specific blog post. This endpoint should be accessible to all users. If the blog post is fetched successfully, it will be returned to the client with a 200 OK status. If an error occurs, an appropriate error status will be returned.
Acceptance Criteria
- The endpoint allows users to fetch the details of a specific blog post by its ID.
- The endpoint is accessible to all users.
- The endpoint validates the blog post ID and returns appropriate error messages for invalid IDs.
- Returns a
200 OKstatus code and the blog post details when the blog post is fetched successfully.
Requirements
- Implement API endpoint for fetching the details of a specific blog post.
- Validate the blog post ID and return appropriate error messages for invalid IDs.
- Handle unexpected errors and return the appropriate status code.
- Ensure soft-deleted blog posts are not returned.
Expected Outcome
- Users should be able to send a request to fetch the details of a specific blog post.
- Users should receive appropriate status codes and responses based on the outcome of the request.
Endpoints
[GET] /api/v1/blogs/:id
-
Description: Fetches the details of a specific blog post.
-
Path Parameters:
id: The ID of the blog post to fetch.
-
Success Response:
-
Status:
200 OK -
Body:
{ "id": "id", "title": "Blog Post Title", "excerpt": "Blog post excerpt here.", "content": "Content of the blog post...", "image_url": "image-url-link", "created_at": "2024-07-18T00:00:00Z", "updated_at": "2024-07-18T00:00:00Z", }
-
-
Error Response:
-
Status:
500 Internal Server Error -
Body:
{ "error": "Internal server error." }
-
-
Not Found Response:
-
Status:
404 Not Found -
Body:
{ "error": "Blog post not found." }
-
-
Bad Request Response:
-
Status:
400 Bad Request -
Body:
{ "error": "Invalid blog post ID." }
-
Testing
Test Scenarios
-
Successful Retrieval of Blog Post
- Ensure that the endpoint successfully retrieves the details of an existing blog post.
- Verify that the response includes the blog post details and a
200 OKstatus code.
-
Blog Post Not Found
- Simulate a request to fetch a blog post that does not exist.
- Confirm that the endpoint returns a
404 Not Foundstatus code and an appropriate error message.
-
Internal Server Error
- Simulate an internal server error to raise an exception.
- Verify that the endpoint returns a
500 Internal Server Errorstatus code and an appropriate error message.
-
Invalid Blog Post ID
- Send requests with invalid blog post IDs (e.g., non-integer values).
- Verify that the endpoint returns a
400 Bad Requeststatus code and an appropriate error message.
-
Soft-Deleted Blog Post Access Control
- Ensure that soft-deleted blog posts are not returned in regular queries.
- Confirm that the endpoint returns a
404 Not Foundstatus code and an appropriate error message.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request