Contract and codegen
shared/openapi/openapi.yaml is the API contract
(ADR 0003): every path, request, response and
model. It is the source of truth. Clients are generated from it, and the
API reference on this site is drawn from it.
| Output | How it is made | Committed? |
|---|---|---|
Go types (shared/types-go) | oapi-codegen via cd shared/types-go && make codegen | Yes. Do not hand-edit *.gen.go. |
TypeScript types (shared/types-ts) | openapi-typescript via pnpm --filter @caregiver/types-ts run build | Yes |
Swift client (CaregiverAPI) | Apple's swift-openapi-generator, as a build plugin, from a copy of the contract in shared/types-swift/Sources/CaregiverAPI/ | Only the copy |
When the contract changes
You don't run these by hand. A lefthook pre-commit hook sees a staged openapi.yaml,
regenerates the Go and TypeScript types, copies the contract into the Swift package, and stages the
results. CI then runs a codegen-drift check that fails the pull request if the committed output
differs from a fresh generation.
Add new operations with an operationId (the Swift method name comes from it) and a tags entry
(the group it appears under in the reference).
Rules of thumb
- Change the contract first, then the code. A handler that answers something the contract does not describe is a bug in one of them.
- A field removed from a response breaks older app builds still installed on phones. Add fields freely; remove them only once no supported build reads them.