Forum API Documentation

Version 1.0

GET /api/forums

Fetches a list of all forums with their replies.

Request

            GET /api/forums HTTP/1.1
                        

Response

            200 OK
            [
                {
                    "id": 1,
                    "title": "Forum Title 1",
                    "name": "John Doe",
                    "email": "john@example.com",
                    "message": "This is the forum message.",
                    "replies": [
                        {
                            "id": 1,
                            "name": "Jane Doe",
                            "reply": "This is a reply.",
                            "formId": 1
                        }
                    ]
                },
                {
                    "id": 2,
                    "title": "Forum Title 2",
                    "name": "Alice",
                    "email": "alice@example.com",
                    "message": "Another forum message.",
                    "replies": []
                }
            ]
                            

POST /api/forums

Creates a new forum entry.

Request

            POST /api/forums HTTP/1.1
            Content-Type: application/json

            {
                "title": "New Forum Title",
                "name": "John Doe",
                "email": "john@example.com",
                "message": "This is the forum content."
            }
                        

Response

            201 Created
            {
                "id": 3,
                "title": "New Forum Title",
                "name": "John Doe",
                "email": "john@example.com",
                "message": "This is the forum content.",
                "replies": []
            }
                            

GET /api/forums/:id

Fetches details of a specific forum by its ID, including its replies.

Request

            GET /api/forums/1 HTTP/1.1
                        

Response

            200 OK
            {
                "id": 1,
                "title": "Forum Title 1",
                "name": "John Doe",
                "email": "john@example.com",
                "message": "This is the forum message.",
                "replies": [
                    {
                        "id": 1,
                        "name": "Jane Doe",
                        "reply": "This is a reply.",
                        "formId": 1
                    }
                ]
            }
                            

GET /api/forums/:id/replies

Fetches all replies for a specific forum.

Request

            GET /api/forums/1/replies HTTP/1.1
                        

Response

            200 OK
            [
                {
                    "id": 1,
                    "name": "Jane Doe",
                    "reply": "This is a reply to the forum.",
                    "formId": 1
                },
                {
                    "id": 2,
                    "name": "Alice",
                    "reply": "Another reply.",
                    "formId": 1
                }
            ]
                            

POST /api/forums/:id/replies

Adds a reply to an existing forum.

Request

            POST /api/forums/1/replies HTTP/1.1
            Content-Type: application/json

            {
                "name": "Jane Doe",
                "reply": "This is a reply to the forum."
            }
                        

Response

            201 Created
            {
                "id": 1,
                "name": "Jane Doe",
                "reply": "This is a reply to the forum.",
                "formId": 1
            }