Skip to content

feat(api): publish canonical OpenAPI spec, add /version endpoint#292

Merged
vredchenko merged 1 commit into
mainfrom
feat/openapi-publish-and-version-endpoint
Jun 2, 2026
Merged

feat(api): publish canonical OpenAPI spec, add /version endpoint#292
vredchenko merged 1 commit into
mainfrom
feat/openapi-publish-and-version-endpoint

Conversation

@vredchenko

Copy link
Copy Markdown
Collaborator

Summary

Makes smartem-decisions the canonical OpenAPI spec publisher (ADR 0020 — DiamondLightSource/smartem-devtools#222) and adds the /version contract the frontend's compatibility check reads.

  • docs/api/openapi.json — the canonical spec, now committed in-repo (the single source; frontend and devtools are downstream caches of it).
  • publish-openapi-spec.yml — on pushes to main touching the backend, regenerates the spec; when the API surface actually changes (per-commit version churn ignored via tools/publish_openapi.py), commits the refresh and fires a repository_dispatch to smartem-devtools to refresh its caches + rebuild Pages.
  • GET /version — small, stable, machine-readable ({service, version}); /status is unchanged.

Action required after merge

Add a DEVTOOLS_DISPATCH_TOKEN secret (fine-grained PAT with Contents: write on smartem-devtools, or a GitHub App). The publish workflow degrades gracefully without it — it still commits the spec and logs a warning; the devtools sync can be run manually meanwhile.

Companion PRs (merge together)

Test plan

  • uv run pytest tests/smartem_backend/test_misc_endpoints.py/version covered, suite green
  • ruff check / format --check clean
  • Canonical spec generates (62 paths incl. /version and /acquisitions/grid-counts); change-detection ignores version churn

Closes #253.

Make smartem-decisions the canonical OpenAPI spec publisher (ADR 0020): commit
the spec at docs/api/openapi.json and add a workflow that, on pushes to main
touching the backend, regenerates it and - when the API surface actually changes
(version churn ignored) - commits the refresh and notifies smartem-devtools via
repository_dispatch so it can refresh its downstream caches and redeploy Pages.

Add a small /version endpoint as the machine-readable contract the frontend's
observe-only compatibility check reads (the /status payload is unchanged).

Requires a DEVTOOLS_DISPATCH_TOKEN secret to notify smartem-devtools; the
workflow degrades gracefully (warns, still commits) until it exists.
@vredchenko vredchenko merged commit 8fa353e into main Jun 2, 2026
11 checks passed
@vredchenko vredchenko deleted the feat/openapi-publish-and-version-endpoint branch June 2, 2026 16:19
vredchenko added a commit to DiamondLightSource/smartem-frontend that referenced this pull request Jun 2, 2026
## Summary

Implements the **frontend side** of ADR 0020
(DiamondLightSource/smartem-devtools#222): finishes the
backend-compatibility check and points the client at the canonical spec
source.

- **Boot-time check wired into `apps/smartem/src/main.tsx`** (live mode
only) — queries the backend `/version` endpoint and compares it
**semantically** (release portion, ignoring the `dev+sha` suffix) to the
version the client was built against. Logs always; shows a
**non-blocking dev banner** on drift. **Never enforced** — rolling
deploys that momentarily differ don't break the app.
- **`version-check.ts` rewritten** — fetches `/version` (was
`/openapi.json`), semantic compare (was exact-string, which
false-alarmed on every commit). Same exported surface, so the legacy
`ApiVersionCheck` still builds.
- **`api:fetch` repointed** — pulls the canonical spec from
smartem-decisions (`docs/api/openapi.json`) instead of the stale
devtools Pages copy. `npm run api:update` is now safe and canonical.

## Notes

- The committed `openapi.json` is unchanged here (still has the
endpoints from #108). Once the backend PR merges and publishes, a
routine `npm run api:update` refreshes it; until then the observe-only
check simply notes the client is slightly behind — which is honest and
non-blocking.

## Companion PRs (merge together)

- DiamondLightSource/smartem-decisions#292 — `/version` endpoint +
canonical publisher.
- DiamondLightSource/smartem-devtools#222 — ADR 0020 + sync pipeline.

## Test plan

- [x] `npm run typecheck` clean
- [x] `npx biome check` clean on touched files (+ lefthook)
- [x] `npm run build:smartem` succeeds

Closes #93.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chore: restore and automate OpenAPI spec sync to smartem-devtools

1 participant