You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Publish typed algorithm result kinds in the API once the UI generates its types from it #1482
The occurrence history endpoint (#1461) publishes each algorithm result's data as plain JSON in the OpenAPI schema. The server validates data against a pydantic model per result kind (ami/ml/results/schemas.py), and the UI types it by kind by hand (ui/src/data-services/models/occurrence-history.ts). An earlier revision of #1461 also published one typed OpenAPI component per kind. It was removed before merge because nothing consumed it yet, and because naming its enums made config/settings/base.py import application code.
This ticket is the reminder to bring typed result kinds back to the schema once the UI generates its TypeScript types from the OpenAPI schema, so the hand-written types and the server models cannot drift.
Name the single-value enums without importing app code into settings, for example with a drf-spectacular postprocessing hook, or by building ENUM_NAME_OVERRIDES lazily.
Keep data models flat: nested models and Enum fields emit #/definitions/... references that do not resolve inside OpenAPI. Restore the test that checks each kind's schema is closed and flat.
Replace the hand-written per-kind interfaces in the UI with the generated ones.
Depends on: OpenAPI-to-TypeScript generation in the UI (not started).
Summary
The occurrence history endpoint (#1461) publishes each algorithm result's
dataas plain JSON in the OpenAPI schema. The server validatesdataagainst a pydantic model per result kind (ami/ml/results/schemas.py), and the UI types it by kind by hand (ui/src/data-services/models/occurrence-history.ts). An earlier revision of #1461 also published one typed OpenAPI component per kind. It was removed before merge because nothing consumed it yet, and because naming its enums madeconfig/settings/base.pyimport application code.This ticket is the reminder to bring typed result kinds back to the schema once the UI generates its TypeScript types from the OpenAPI schema, so the hand-written types and the server models cannot drift.
What to do then
ALGORITHM_RESULT_DATA_MODELS):kindas a literal anddataas the kind's JSON schema, inside the history'soneOf. The removed implementation is in the history of Record any algorithm's results on occurrences in a standard way, and show them in each occurrence's history #1461 (_result_entry_componentinami/main/api/serializers.py).ENUM_NAME_OVERRIDESlazily.Enumfields emit#/definitions/...references that do not resolve inside OpenAPI. Restore the test that checks each kind's schema is closed and flat.Depends on: OpenAPI-to-TypeScript generation in the UI (not started).