@@ -18,6 +18,12 @@ The Expense System UI is a FastAPI-based web application that provides both a we
1818
1919## API Endpoints
2020
21+ ### Parameter Validation
22+ All endpoints use FastAPI's automatic parameter validation:
23+ - Missing required parameters return HTTP 422 (Unprocessable Entity)
24+ - Invalid parameter types return HTTP 422 (Unprocessable Entity)
25+ - This validation occurs before endpoint-specific business logic
26+
2127### 1. Home/List View (` GET / ` or ` GET /list ` )
2228** Purpose** : Display all expenses in an HTML table format
2329
@@ -44,15 +50,15 @@ The Expense System UI is a FastAPI-based web application that provides both a we
4450- ` approve ` : Changes CREATED → APPROVED
4551- ` reject ` : Changes CREATED → REJECTED
4652- ` payment ` : Changes APPROVED → COMPLETED
47- - Invalid IDs return 400 error
48- - Invalid action types return 400 error
53+ - Invalid IDs return HTTP 200 with error message in response body
54+ - Invalid action types return HTTP 200 with error message in response body
4955- State changes from CREATED to APPROVED/REJECTED trigger workflow notifications
5056- API calls return "SUCCEED" on success
5157- UI calls redirect to list view after success
5258
5359** Error Handling** :
54- - API calls return "ERROR: INVALID_ID " or "ERROR: INVALID_TYPE "
55- - UI calls return HTTP 400 with descriptive messages
60+ - API calls return HTTP 200 with "ERROR: INVALID_ID " or "ERROR: INVALID_TYPE " in response body
61+ - UI calls return HTTP 200 with descriptive messages like "Invalid ID" or "Invalid action type" in response body
5662
5763### 3. Create Expense (` GET /create ` )
5864** Purpose** : Create a new expense entry
@@ -64,11 +70,11 @@ The Expense System UI is a FastAPI-based web application that provides both a we
6470** Business Rules** :
6571- Expense ID must be unique
6672- New expenses start in CREATED state
67- - Duplicate IDs return 400 error
73+ - Duplicate IDs return HTTP 200 with error message in response body
6874
6975** Error Handling** :
70- - API calls return "ERROR: ID_ALREADY_EXISTS "
71- - UI calls return HTTP 400 with descriptive message
76+ - API calls return HTTP 200 with "ERROR: ID_ALREADY_EXISTS " in response body
77+ - UI calls return HTTP 200 with descriptive message "ID already exists" in response body
7278
7379### 4. Status Check (` GET /status ` )
7480** Purpose** : Retrieve current expense state
@@ -77,7 +83,7 @@ The Expense System UI is a FastAPI-based web application that provides both a we
7783- ` id ` (required): Expense ID
7884
7985** Response** : Current expense state as string
80- ** Error Handling** : Returns "ERROR: INVALID_ID " for unknown IDs
86+ ** Error Handling** : Returns HTTP 200 with "ERROR: INVALID_ID " in response body for unknown IDs
8187
8288### 5. Callback Registration (` POST /registerCallback ` )
8389** Purpose** : Register Temporal workflow callback for expense state changes
@@ -92,9 +98,9 @@ The Expense System UI is a FastAPI-based web application that provides both a we
9298- Enables workflow notification on state changes
9399
94100** Error Handling** :
95- - "ERROR: INVALID_ID " for unknown expenses
96- - "ERROR: INVALID_STATE " for non-CREATED expenses
97- - "ERROR: INVALID_FORM_DATA " for invalid tokens
101+ - HTTP 200 with "ERROR: INVALID_ID " in response body for unknown expenses
102+ - HTTP 200 with "ERROR: INVALID_STATE " in response body for non-CREATED expenses
103+ - HTTP 200 with "ERROR: INVALID_FORM_DATA " in response body for invalid tokens
98104
99105## Workflow Integration
100106
@@ -128,8 +134,8 @@ The Expense System UI is a FastAPI-based web application that provides both a we
128134
129135### Error Recovery
130136- Graceful handling of workflow callback failures
131- - Input validation on all endpoints
132- - Descriptive error messages
137+ - Input validation on all endpoints (422 for missing/invalid parameters, 200 with error messages for business logic errors)
138+ - Descriptive error messages in response body
133139
134140### Logging
135141- State change operations are logged
0 commit comments