|
| 1 | +## Spring REST API Documentation - Topics and Courses |
| 2 | + |
| 3 | +This API provides functionalities for managing topics and their associated courses. |
| 4 | + |
| 5 | +**Communication:** |
| 6 | + |
| 7 | +- **Content-Type:** Application/JSON is used for both request and response bodies. |
| 8 | +- **Spring Annotations:** The API leverages Spring annotations for controller definitions and dependency injection. |
| 9 | +- **Error Responses:** Responses include an error message and status code in case of exceptions. |
| 10 | + |
| 11 | +**1. Topics API** |
| 12 | + |
| 13 | +**Endpoints:** |
| 14 | + |
| 15 | +* **GET /get/topics** |
| 16 | + * Description: Retrieves a list of all topics. |
| 17 | + * Response: JSON array of `Topic` objects. |
| 18 | +* **GET /get/topic/{id}** |
| 19 | + * Description: Gets a specific topic by its ID. |
| 20 | + * Path Parameter: `{id}` - The numeric ID of the topic to retrieve. |
| 21 | + * Response: JSON object representing the `Topic` or a Not Found status code if not found. |
| 22 | +* **POST /post/topic** |
| 23 | + * Description: Creates a new topic. |
| 24 | + * Request Body: JSON object representing the new `Topic`. |
| 25 | + * Response: JSON array containing the list of topics after creation (including the newly created one). |
| 26 | +* **PUT /update/topic/{id}** |
| 27 | + * Description: Updates an existing topic. |
| 28 | + * Path Parameter: `{id}` - The numeric ID of the topic to update. |
| 29 | + * Request Body: JSON object representing the updated `Topic`. |
| 30 | + * Response: JSON object representing the updated `Topic` or a Not Found status code if not found. |
| 31 | +* **DELETE /delete/topic/{id}** |
| 32 | + * Description: Deletes a topic by its ID. |
| 33 | + * Path Parameter: `{id}` - The numeric ID of the topic to delete. |
| 34 | + * Response: No response body, but deletes the specified topic (returns void). |
| 35 | + |
| 36 | +**2. Courses API** |
| 37 | + |
| 38 | +**Endpoints (all require a topic ID in the path):** |
| 39 | + |
| 40 | +* **GET /get/topics/{id}/courses** |
| 41 | + * Description: Retrieves all courses associated with a specific topic. |
| 42 | + * Path Parameter: `{id}` - The numeric ID of the topic to get courses for. |
| 43 | + * Response: JSON array of `Course` objects. |
| 44 | +* **GET /get/topic/{topicId}/courses/{id}** |
| 45 | + * Description: Gets a specific course by its ID within a topic. |
| 46 | + * Path Parameters: |
| 47 | + * `{topicId}` - The numeric ID of the topic containing the course. |
| 48 | + * `{id}` - The numeric ID of the course to retrieve. |
| 49 | + * Response: JSON object representing the `Course` or a Not Found status code if not found. |
| 50 | +* **POST /post/topic/{topicId}/courses** |
| 51 | + * Description: Creates a new course associated with a specific topic. |
| 52 | + * Path Parameter: `{topicId}` - The numeric ID of the topic for the new course. |
| 53 | + * Request Body: JSON object representing the new `Course`. The course object should include the topic ID in its request body. |
| 54 | + * Response: No response body, but creates the new course associated with the specified topic. |
| 55 | +* **PUT /update/topic/{topicId}/courses/{id}** |
| 56 | + * Description: Updates an existing course within a topic. |
| 57 | + * Path Parameters: |
| 58 | + * `{topicId}` - The numeric ID of the topic containing the course. |
| 59 | + * `{id}` - The numeric ID of the course to update. |
| 60 | + * Request Body: JSON object representing the updated `Course`. The course object should include the topic ID in its request body. |
| 61 | + * Response: JSON object representing the updated `Course`. |
| 62 | +* **DELETE /delete/topic/{topicId}/courses/{id}** |
| 63 | + * Description: Deletes a course by its ID within a topic. |
| 64 | + * Path Parameters: |
| 65 | + * `{topicId}` - The numeric ID of the topic containing the course. |
| 66 | + * `{id}` - The numeric ID of the course to delete. |
| 67 | + * Response: No response body, but deletes the specified course (returns void). |
| 68 | + |
| 69 | +**Note:** |
| 70 | + |
| 71 | +- The `Course` API endpoints require the corresponding topic to exist before creating or updating courses. |
| 72 | +- Error responses might include details about exceptions encountered during processing. |
| 73 | + |
0 commit comments