Skip to content

Commit

Permalink
docs(api): Add problem generation endpoints to API documentation
Browse files Browse the repository at this point in the history
- Added detailed documentation for the problem generation endpoints.
- Documented the `GET /api/problems` endpoint to retrieve the problem generator index.
- Added information on the `GET /api/problems/:topics/:subtopics/...` endpoint for generating a problem based on topics and subtopics.
- Provided example responses for successful problem generation, 404 (Generator not found), and 500 (Internal server error).
  • Loading branch information
TKanX committed Sep 26, 2024
1 parent 866ae41 commit 845036b
Showing 1 changed file with 81 additions and 0 deletions.
81 changes: 81 additions & 0 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ The API uses JWT (JSON Web Token) for authentication. To access protected routes
- [Rename Task](#rename-task)
- [Update Description](#update-description)
- [Update Grading Status](#update-grading-status)
- [Problem Generation Endpoints](#problem-generation-endpoints)
- [Get Problem Generator Index](#get-problem-generator-index)
- [Generate Problem](#generate-problem)

### Authentication Endpoints

Expand Down Expand Up @@ -2803,3 +2806,81 @@ The API uses JWT (JSON Web Token) for authentication. To access protected routes
```

> **Note:** The endpoint is protected, and the user must be authenticated to access it.

### Problem Generation Endpoints

#### Get Problem Generator Index

- **URL:** `/api/problems`
- **Method:** `GET`

- **Response**:

- **Status:** `200 OK`

```json
{
"status": "success",
"data": [],
"message": "Problem generator index retrieved successfully."
}
```

> **Note:** The problem generator index will be returned in the response (`data` field).

#### Generate Problem

- **URL:** `/api/problems/:topics/:subtopics/:...`
- **Method:** `GET`

- **Request Parameters**:

- `topics`: The topics to generate the problem for.
- `subtopics`: The subtopics to generate the problem for.
- `...`: More subtopics if needed.

> **Note:** The topics and subtopics are separated by `/`.

- **Query Parameters**:

- `options`: The problem generation options.

- **Response**:

- **Status:** `200 OK`

```json
{
"status": "success",
"data": {},
"message": "Problem generated successfully."
}
```

> **Note:** The generated problem will be returned in the response (`data` field).

- **Status:** `404 Not Found`

```json
{
"status": "error",
"message": "Generator not found.",
"error": {
"code": "GENERATOR_NOT_FOUND",
"details": {}
}
}
```

- **Status:** `500 Internal Server Error`

```json
{
"status": "error",
"message": "Error generating problem.",
"error": {
"code": "GENERATE_PROBLEM_ERROR",
"details": {}
}
}
```

0 comments on commit 845036b

Please sign in to comment.