Stu Mason · Folkestone, Kent
One entryMerged PR· StuMason/coolify-mcp· TypeScript

PR #247 merged: fix: refresh bundled OpenAPI spec and add client-vs-spec drift check

additions
+2533
deletions
-489
files changed
6

Closes #236

What

docs/coolify-openapi.yaml was stale — missing the scheduled-tasks, storages, and /databases/{uuid}/envs* endpoints that src/lib/coolify-client.ts already calls (added in earlier PRs but never reflected in the bundled spec).

  1. Refreshed the spec from coollabsio/coolify main (openapi.yaml, 3.1.0). Old bundled copy: 7,403 lines / 79 paths. New: 8,778 lines / 96 paths.
  2. Added scripts/check-client-spec-drift.mjs — a no-network, no-build script that:
    • Extracts every path template passed to this.request(...) in coolify-client.ts (plus /version, which getVersion() fetches directly rather than via this.request).
    • Extracts every top-level path key from the spec's paths: block.
    • Normalises both to segment lists (${var} / {param} segments become wildcards; hardcoded query strings and ${query}/${qs}-style suffixes glued onto the previous segment are stripped).
    • Matches by segment count + literal-segment equality (param names don't need to match) and fails, listing unmatched routes, if any client route has no corresponding spec path.
    • Supports a documented ALLOWLIST for endpoints upstream genuinely hasn't specced yet.
  3. Wired it into CI as npm run check:spec-drift, a new step in .github/workflows/ci.yml right after lint. Left .github/workflows/openapi-drift.yml untouched — it covers the other drift direction (upstream spec changes vs. a baseline, over time).
  4. Unit tests for the extraction/normalisation/matching logic in scripts/__tests__/check-client-spec-drift.test.ts (jest testMatch extended to also pick up scripts/**/*.test.ts).

Coverage after the refresh

Ran the new script against the refreshed spec: all 101 client-called routes now match a spec path. The ALLOWLIST is empty — there was nothing left over that upstream hasn't specced yet. (I verified the script actually detects drift by first running it against the old stale spec, where it correctly flagged the 16 routes named in the issue — scheduled-tasks, storages, database envs, plus one the issue didn't mention: /applications/{uuid}/previews/{pull_request_id}, which is also now covered.)

Note on docs/openapi-chunks/

There's a separate, hand-split-by-tag copy of the spec in docs/openapi-chunks/*.yaml (referenced by CLAUDE.md / contributor docs as the first place to check when adding a new endpoint — it is not read by search_docs, which fetches https://coolify.io/docs/llms-full.txt at runtime and never touches local files). Those chunks are equally stale relative to the now-refreshed bundled spec but regenerating them is a bigger, separate job (no existing splitter script) and out of scope for this issue. Flagging so it doesn't get lost — happy to file a follow-up issue if useful.

Test plan

  • npm test — 377 tests passing (5 suites)
  • npm run lint — 0 errors (pre-existing warnings only, none new besides missing-return-type warnings on the new plain-JS script, which is consistent with how debug.js is written)
  • npx prettier --check . — clean
  • npm run build — verified dist/index.js still lands at the expected path (adding the script initially expanded tsc's inferred rootDir when tests imported it from under src/; fixed by keeping the script's test alongside it in scripts/__tests__/ instead)
  • node scripts/check-client-spec-drift.mjs — passes clean against the refreshed spec; also manually verified it fails correctly against the old spec

🤖 Generated with Claude Code