Skip to content

refactor Monitoring API Types: Use OpenAPI Spec #135

@lucasbalieiro

Description

@lucasbalieiro

If stratum-mining/sv2-apps#469 gets merged, we should stop manually maintaining monitoring API types and instead generate them from openapi.json as the single source of truth.

The current src/types/api.ts will inevitably drift from the real API and creates unnecessary maintenance overhead.

We can commit the OpenAPI specs from Translator and JDC into src/api-specs/monitoring/{translator,jdc}/openapi.json, updating them only when upstream changes (we will be notified via issue).

Then add a generate:types script using a tool like @hey-api/openapi-ts (or equivalent) to generate TypeScript types into src/api/generated, and replace all manual types with the generated ones. This step introduces no runtime changes.

After that, we can progressively replace fetchWithTimeout<T>() calls with a generated client (e.g. translatorClient.v1.global()), removing manual generics and endpoint duplication.

Proxies (/translator-api, /jdc-api) remain unchanged. The goal is to eliminate drift and reduce complexity by making OpenAPI the only source of truth and treating generated code as disposable.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions