Regenerated mammon OpenAPI client breaks typecheck (LedgerResponse/TransferResponse discriminated-union codegen) #51

Open
opened 2026-08-14 22:55:12 +02:00 by Sirttas · 0 comments
Owner

Summary

After regenerating docs/mammon-api.yml / src/generated/mammon/ from mammon's current OpenAPI spec (feature/transaction-valuation merge), npm run build / vue-tsc --noEmit fails. The regenerated client contains self-referencing TypeScript interfaces for the discriminated-union response types, plus several downstream call sites that no longer compile against the new shapes.

Steps to reproduce

  1. cd gemory && npx vue-tsc --noEmit

Expected

Clean typecheck against the regenerated client.

Actual

src/generated/mammon/api.ts(149,18): error TS2310: Type 'CombinedLedgerResponse' recursively references itself as a base type.
src/generated/mammon/api.ts(149,49): error TS2312: An interface can only extend an object type or intersection of object types with statically known members.
src/generated/mammon/api.ts(301,18): error TS2310: Type 'IskTransferResponse' recursively references itself as a base type.
src/generated/mammon/api.ts(301,46): error TS2312: An interface can only extend an object type or intersection of object types with statically known members.
src/generated/mammon/api.ts(331,18): error TS2310: Type 'ItemTransferResponse' recursively references itself as a base type.
src/generated/mammon/api.ts(331,47): error TS2312: An interface can only extend an object type or intersection of object types with statically known members.
src/generated/mammon/api.ts(358,18): error TS2310: Type 'MainLedgerResponse' recursively references itself as a base type.
src/generated/mammon/api.ts(358,45): error TS2312: An interface can only extend an object type or intersection of object types with statically known members.

Plus downstream compile errors at call sites relying on the old shape:

  • src/ledger/EditLedgerModal.vue — type string not assignable to "COMBINED" | "MAIN", Property 'type' does not exist on type 'MainLedgerResponse'
  • src/ledger/ledger.ts:38,41 — Property 'type' does not exist on type 'Ledger' (Ledger = generated LedgerResponse union)
  • src/transaction/TransferList.vue — TransferResponse union no longer assignable to the local TransferWithValue type; several unknown-typed narrowing failures
  • src/pages/market/TypeInfo.vue:52 — Property 'source' does not exist on type 'AcquisitionResponse'

Notes

Root cause for the api.ts interface errors: LedgerResponse (and TransferResponse) are OpenAPI oneOf + discriminator schemas, and each variant (MainLedgerResponse, CombinedLedgerResponse, IskTransferResponse, ItemTransferResponse) is defined via allOf: [$ref: LedgerResponse, ...] on the mammon side. openapi-generator's typescript-axios generator turns the discriminated parent into a type alias (type LedgerResponse = {type: 'COMBINED'} & CombinedLedgerResponse | {type: 'MAIN'} & MainLedgerResponse) instead of an interface, then emits interface MainLedgerResponse extends LedgerResponse for the variant — extending a type alias that resolves back to itself, hence the TS2310 recursion error.

Confirmed this is not caused by the profit/margin wiring work (gemory profitApi wiring) — those two files are the only ones touched for that, and this breakage is isolated to the ledger/transfer discriminated-union schemas and their generated client.

Two possible fix directions to evaluate during refinement:

  1. Change how mammon's Swagger/OpenAPI annotations model these discriminated unions (e.g. avoid allOf referencing the discriminator parent directly) so the generator produces non-recursive types.
  2. Post-process/patch the generated client, or adjust the gemory consumer code to work around the generator's output shape.

Since src/generated/mammon/ is documented as generated/do-not-edit, the fix likely needs to originate on the mammon OpenAPI schema side (mammon #cross-repo), unless the generator config in gemory can be adjusted instead.

Related

Surfaced while wiring gemory to mammon's feature/transaction-valuation branch (profit/margin endpoints).

## Summary After regenerating `docs/mammon-api.yml` / `src/generated/mammon/` from mammon's current OpenAPI spec (feature/transaction-valuation merge), `npm run build` / `vue-tsc --noEmit` fails. The regenerated client contains self-referencing TypeScript interfaces for the discriminated-union response types, plus several downstream call sites that no longer compile against the new shapes. ## Steps to reproduce 1. `cd gemory && npx vue-tsc --noEmit` ## Expected Clean typecheck against the regenerated client. ## Actual ``` src/generated/mammon/api.ts(149,18): error TS2310: Type 'CombinedLedgerResponse' recursively references itself as a base type. src/generated/mammon/api.ts(149,49): error TS2312: An interface can only extend an object type or intersection of object types with statically known members. src/generated/mammon/api.ts(301,18): error TS2310: Type 'IskTransferResponse' recursively references itself as a base type. src/generated/mammon/api.ts(301,46): error TS2312: An interface can only extend an object type or intersection of object types with statically known members. src/generated/mammon/api.ts(331,18): error TS2310: Type 'ItemTransferResponse' recursively references itself as a base type. src/generated/mammon/api.ts(331,47): error TS2312: An interface can only extend an object type or intersection of object types with statically known members. src/generated/mammon/api.ts(358,18): error TS2310: Type 'MainLedgerResponse' recursively references itself as a base type. src/generated/mammon/api.ts(358,45): error TS2312: An interface can only extend an object type or intersection of object types with statically known members. ``` Plus downstream compile errors at call sites relying on the old shape: - `src/ledger/EditLedgerModal.vue` — `type` string not assignable to `"COMBINED" | "MAIN"`, `Property 'type' does not exist on type 'MainLedgerResponse'` - `src/ledger/ledger.ts:38,41` — `Property 'type' does not exist on type 'Ledger'` (`Ledger` = generated `LedgerResponse` union) - `src/transaction/TransferList.vue` — `TransferResponse` union no longer assignable to the local `TransferWithValue` type; several `unknown`-typed narrowing failures - `src/pages/market/TypeInfo.vue:52` — `Property 'source' does not exist on type 'AcquisitionResponse'` ## Notes Root cause for the `api.ts` interface errors: `LedgerResponse` (and `TransferResponse`) are OpenAPI `oneOf` + `discriminator` schemas, and each variant (`MainLedgerResponse`, `CombinedLedgerResponse`, `IskTransferResponse`, `ItemTransferResponse`) is defined via `allOf: [$ref: LedgerResponse, ...]` on the mammon side. openapi-generator's typescript-axios generator turns the discriminated parent into a type alias (`type LedgerResponse = {type: 'COMBINED'} & CombinedLedgerResponse | {type: 'MAIN'} & MainLedgerResponse`) instead of an interface, then emits `interface MainLedgerResponse extends LedgerResponse` for the variant — extending a type alias that resolves back to itself, hence the TS2310 recursion error. Confirmed this is not caused by the profit/margin wiring work (gemory `profitApi` wiring) — those two files are the only ones touched for that, and this breakage is isolated to the ledger/transfer discriminated-union schemas and their generated client. Two possible fix directions to evaluate during refinement: 1. Change how mammon's Swagger/OpenAPI annotations model these discriminated unions (e.g. avoid `allOf` referencing the discriminator parent directly) so the generator produces non-recursive types. 2. Post-process/patch the generated client, or adjust the `gemory` consumer code to work around the generator's output shape. Since `src/generated/mammon/` is documented as generated/do-not-edit, the fix likely needs to originate on the mammon OpenAPI schema side (`mammon #cross-repo`), unless the generator config in gemory can be adjusted instead. ## Related Surfaced while wiring gemory to mammon's `feature/transaction-valuation` branch (profit/margin endpoints).
Sirttas added the
Priority
High
2
Kind/Bug
Status
To Refine
labels 2026-08-14 22:55:12 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: eveal/gemory#51