Skip to content

Commit 019c985

Browse files
committed
feat(frontend): typed API client generated from the OpenAPI spec + gen-verify CI
The code-first OpenAPI generator landed on main (covering projects + sessions), superseding this branch's backend work. This repurposes the PR to the parts main still lacks: - frontend/src/api/schema.d.ts — generated from backend/internal/httpd/apispec/ openapi.yaml via openapi-typescript (`npm run gen:api`); covers projects, sessions, and orchestrators. - frontend/src/api/client.ts — a small openapi-fetch client typed by that schema, so the renderer's request/response types come from the daemon contract instead of being hand-maintained. - CI gen-verify job — regenerates the spec from Go and the TS client from the spec, failing if either committed artifact is stale. Backend drift is also covered by the apispec tests; this additionally guards the frontend artifact, which nothing else checks. Frontend typecheck passes; the gen pipeline reproduces the committed files with no drift.
1 parent 9058017 commit 019c985

5 files changed

Lines changed: 1283 additions & 0 deletions

File tree

.github/workflows/go.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
pull_request:
77
paths:
88
- "backend/**"
9+
- "frontend/**"
910
- ".github/workflows/go.yml"
1011

1112
permissions:
@@ -68,3 +69,42 @@ jobs:
6869
working-directory: backend
6970
# Blocking on the full ruleset: the tree is clean at zero findings, so
7071
# any new issue fails CI rather than being grandfathered.
72+
73+
# gen-verify regenerates the code-first pipeline end to end — openapi.yaml from
74+
# the Go types, then the frontend TS client from that spec — and fails if the
75+
# committed copies are stale. The backend drift is also covered by the apispec
76+
# tests; this job additionally guards the frontend artifact, which nothing else
77+
# checks (someone changing a Go contract type must run `go generate ./...` and
78+
# `npm run gen:api`, then commit).
79+
gen-verify:
80+
runs-on: ubuntu-latest
81+
steps:
82+
- uses: actions/checkout@v4
83+
84+
- uses: actions/setup-go@v5
85+
with:
86+
go-version-file: backend/go.mod
87+
cache: false
88+
89+
- uses: actions/setup-node@v4
90+
with:
91+
node-version: "20"
92+
cache: npm
93+
cache-dependency-path: frontend/package-lock.json
94+
95+
- name: Generate OpenAPI from Go
96+
working-directory: backend
97+
run: go generate ./...
98+
99+
- name: Generate TypeScript from OpenAPI
100+
working-directory: frontend
101+
run: |
102+
npm ci
103+
npm run gen:api
104+
105+
- name: Fail on stale generated files
106+
run: |
107+
if ! git diff --exit-code; then
108+
echo "::error::Generated files are stale. Run 'go generate ./...' in backend and 'npm run gen:api' in frontend, then commit."
109+
exit 1
110+
fi

0 commit comments

Comments
 (0)