Add choices API endpoint and OpenAPI client setup

Introduces a new /api/choices/ endpoint for fetching model choices with multilingual labels. Updates Django models to use 'cz#' prefix for Czech labels. Adds OpenAPI client generation via orval, refactors frontend API structure, and provides documentation and helper scripts for dynamic choices and OpenAPI usage.
This commit is contained in:
David Bruno Vontor
2025-12-04 17:35:47 +01:00
parent ebab304b75
commit d94ad93222
24 changed files with 281 additions and 76 deletions

View File

@@ -107,6 +107,13 @@ Notes
- **Task queue**: Celery + Redis for async/background jobs.
- **API**: REST endpoints, JWT auth, API key support.
### OpenAPI Client Generation
- Schema: `config = { schemaUrl: "/api/schema/", baseUrl: "/api/" }`
- Commands: `npm run api:update` (fetch schema + generate client)
- Output: `frontend/src/api/generated/` (TypeScript Axios client)
- Axios instance: `frontend/src/api/api.ts` with `withCredentials` and JWT auto-refresh via existing `Client.ts`.
- Choices helper: `frontend/src/api/get_choices.ts``getChoices(requests, lang)` returns `{ "Model.field": [{ value, label }] }`.
## References
- [frontend/REACT.md](../frontend/REACT.md): Frontend structure, workflows, and conventions.
- [frontend/src/layouts/LAYOUTS.md](../frontend/src/layouts/LAYOUTS.md): Layout/component patterns.