feat(api): publish canonical OpenAPI spec, add /version endpoint#292
Merged
Conversation
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
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.
This was referenced Jun 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Makes smartem-decisions the canonical OpenAPI spec publisher (ADR 0020 — DiamondLightSource/smartem-devtools#222) and adds the
/versioncontract 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 tomaintouching the backend, regenerates the spec; when the API surface actually changes (per-commit version churn ignored viatools/publish_openapi.py), commits the refresh and fires arepository_dispatchto smartem-devtools to refresh its caches + rebuild Pages.GET /version— small, stable, machine-readable ({service, version});/statusis unchanged.Action required after merge
Add a
DEVTOOLS_DISPATCH_TOKENsecret (fine-grained PAT withContents: writeon 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—/versioncovered, suite greenruff check/format --checkclean/versionand/acquisitions/grid-counts); change-detection ignores version churnCloses #253.