Request & Response Schemas¶
All schemas are defined in models/schemas.py using Pydantic v2.
Request Schemas¶
AskRequest¶
Used by: POST /ask, POST /generate-sql
| Field | Type | Required | Description |
|---|---|---|---|
question |
string |
✅ | Natural language question about the loan data |
Example:
SQLRequest¶
Used by: POST /run-sql
| Field | Type | Required | Description |
|---|---|---|---|
sql |
string |
✅ | A valid SQLite SQL query to execute |
Example:
Response Schemas¶
SQLResponse¶
Returned by: POST /generate-sql
| Field | Type | Nullable | Description |
|---|---|---|---|
sql |
string |
❌ | Generated SQL string |
DataResponse¶
Returned by: POST /run-sql
| Field | Type | Nullable | Description |
|---|---|---|---|
data |
array[object] |
❌ | List of row objects; empty list if no results |
NaN handling
SQLite NULL values and pandas NaN values are serialised as JSON null.
AskResponse¶
Returned by: POST /ask
| Field | Type | Nullable | Description |
|---|---|---|---|
sql |
string |
❌ | The generated SQL query |
data |
array[object] |
❌ | Query result rows |
plotly_code |
string |
✅ | Python code to render a Plotly chart, or null |
JSON Schema¶
The full OpenAPI schema is auto-generated by FastAPI and available at:
- /openapi.json — Machine-readable JSON schema