This document describes the REST API for managing forms and their fields.
http://localhost:8080/forms
| Method | Path | Description | Request Body |
|---|---|---|---|
GET |
/ |
Retrieves a list of all forms. | None |
POST |
/ |
Creates a new form. | Form object (without id). Example:{"name": "New Form", "published": false} |
GET |
/{id} |
Retrieves a specific form by its ID. | None |
PUT |
/{id} |
Updates an existing form by its ID. | Form object (without id). Example:{"name": "Updated Form Name", "published": true} |
DELETE |
/{id} |
Deletes a form by its ID. | None |
GET |
/{id}/fields |
Retrieves fields of a specific form by its ID. | None |
PUT |
/{id}/fields |
Updates fields of a specific form by its ID. | Array of Field objects (include id for updates, omit for new fields). Example:[{"id": 1,"name": "Updated Field Name","label": "Updated Label","type": "TEXT","defaultValue": "New Value"},{"name": "New Field","label": "New Label","type": "NUMBER","defaultValue": "0"}] |
POST |
/{id}/publish |
Toggles form's publication status. | None |
GET |
/published |
Retrieves all published forms. | None |
1. Database Setup
- Install and configure a PostgreSQL database server.
- Update the
application.propertiesfile (located insrc/main/resources) with your database connection details (host, port, username, password, etc.).
2. Run the Application
- Ensure you have Maven installed.
- Run the application:
- Open a terminal and navigate to your project's root directory.
- Run
mvn spring-boot:run.
- Alternatively, run the main class (
src/main/java/edu/sharif/web/Main.java) directly in your IDE.