Skip to content

Auto-generate API Reference from OpenAPI + self-healing screenshot pipeline#6

Open
maekuss wants to merge 3 commits into
mainfrom
claude/mintlify-api-screenshots-YIEi6
Open

Auto-generate API Reference from OpenAPI + self-healing screenshot pipeline#6
maekuss wants to merge 3 commits into
mainfrom
claude/mintlify-api-screenshots-YIEi6

Conversation

@maekuss
Copy link
Copy Markdown

@maekuss maekuss commented Jun 2, 2026

Summary

Two automation changes, both PR-only, idempotent, concurrency-guarded, least-privilege, with pinned action SHAs.

Part A — API Reference auto-generated from the OpenAPI spec

  • Added api-reference/openapi.json (OpenAPI 3.1.0) covering all 13 public endpoints (cost-estimations, scans, findings; X-Api-Key auth; base https://api.hacktron.ai/v1). Validated with mintlify openapi-check.
  • Wired the API Reference tab in docs.json to the spec via openapi, keeping Getting started as hand-written MDX and referencing each endpoint as METHOD /path to preserve group order.
  • Deleted the redundant hand-written endpoint MDX (cost-estimations/*, scans/*, findings/*) so there's no duplication/drift; repointed internal links to the generated slugs.
  • Removed the public references to the internal /docs basic-auth Swagger UI (replaced with the in-docs interactive playground).
  • .github/workflows/sync-openapi.yml: daily + manual; fetches the public */api-docs-json endpoint (prod first, never /docs), validates, and opens a PR only when the spec changed.

⚠️ Bootstrap note: the committed openapi.json was reconstructed from the existing documented endpoints because the CI sandbox could not reach api.hacktron.ai (host not in the network allowlist). The first sync-openapi run replaces it with the canonical production spec. Everything else (navigation, slugs, link-checking) reflects the final state.

Part B — Screenshot pipeline (Playwright, manifest-driven, self-healing)

  • automation/screenshots.json: manifest covering every screenshot referenced by index.mdx and platform/** (5 ready platform pages + 1 todo onboarding persona screen that isn't reproducible from a seeded org).
  • automation/screenshots/: harness — setup.mjs (Clerk programmatic sign-in via @clerk/testing + Vercel bypass as the _vercel_jwt cookie, saved storage state) and capture.mjs (deterministic dark color mode with verification, never networkidle, explicit waitFor anchors, PII masking, pixel-diff so only changed images are written, todo → ready self-heal).
  • images/placeholder.png: neutral generated placeholder + zero-dep generator.
  • .github/workflows/sync-screenshots.yml: weekly + manual; signs in, captures against DOCS_APP_BASE_URL, opens a PR only when an image changed, and lists unresolved todo/failed entries in the PR body.
  • README + CONTRIBUTING document both workflows, the placeholder contract, the required secrets, and how to add a screenshot.

Required secrets (human adds them): CLERK_PUBLISHABLE_KEY, CLERK_SECRET_KEY, E2E_USER_EMAIL, E2E_USER_PASSWORD, E2E_ORG_SLUG, VERCEL_BYPASS_TOKEN, DOCS_APP_BASE_URL.

Verification

  • mintlify openapi-check api-reference/openapi.json → valid ✅
  • mintlify broken-links → no broken links ✅
  • mintlify validate (strict) → build validation passed ✅
  • All harness scripts pass node --check; manifest schema validated; placeholder is a valid 1440×900 PNG.

Notes for the reviewer

The screenshot waitFor/route/mask selectors are best-effort guesses (the app source isn't in this repo). If any are wrong, the capture run leaves the existing image untouched and lists the entry in the PR body for tuning — it can't produce a bad screenshot silently.

https://claude.ai/code/session_01N1CRJkWgTr5cXqGk5tzFSg


Generated by Claude Code

claude added 3 commits June 2, 2026 19:56
Wire docs.json to generate the API Reference endpoint pages from a
committed OpenAPI spec instead of hand-written MDX.

- Add api-reference/openapi.json (OpenAPI 3.1.0) covering all 13 public
  endpoints: cost-estimations, scans, findings. Validated with
  `mintlify openapi-check`.
- Point the "API Reference" tab at the spec via `openapi`, keeping the
  curated "Getting started" group as hand-written MDX and referencing
  each endpoint explicitly so group order is preserved.
- Remove the now-redundant hand-written endpoint MDX (cost-estimations/*,
  scans/*, findings/*) to avoid duplication and drift.
- Repoint internal links to the generated endpoint slugs and replace the
  public references to the internal /docs Swagger UI with the in-docs
  interactive playground.

build: `mintlify openapi-check`, `broken-links`, and `validate` all pass.
Fetch the public OpenAPI spec (prod first, /docs endpoints excluded),
validate with mintlify openapi-check, and open a PR only when the
committed api-reference/openapi.json changed. workflow_dispatch + daily
schedule, concurrency-guarded, least-privilege permissions, pinned SHAs.
Add a manifest-driven Playwright pipeline that captures product
screenshots for the docs and self-heals placeholders.

- automation/screenshots.json: manifest of every screenshot referenced by
  index.mdx and platform/** (route, auth, theme, viewport, waitFor, masks,
  status). Authed routes are prefixed with the org slug at runtime.
- automation/screenshots/: capture harness. setup.mjs signs in via Clerk
  (@clerk/testing) and sets the Vercel bypass as the _vercel_jwt cookie,
  saving storage state; capture.mjs sets color mode deterministically,
  waits on explicit locators (never networkidle), masks PII, diffs, and
  writes only changed images, flipping fulfilled todo -> ready.
- generate-placeholder.mjs + images/placeholder.png: neutral placeholder
  for the placeholder contract.
- .github/workflows/sync-screenshots.yml: weekly + manual, PR-only,
  idempotent, concurrency-guarded, pinned SHAs; PR body lists unresolved
  todo/failed entries.
- README + CONTRIBUTING: document both workflows, required secrets, the
  placeholder contract, and how to add a screenshot.
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a293a19493

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

}

// Persist any todo -> ready transitions.
writeManifest(manifest);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid rewriting the manifest when nothing changed

Because the committed automation/screenshots.json uses compact inline objects/arrays, this unconditional JSON.stringify(..., 2) rewrites the manifest formatting even when every screenshot is unchanged and no todo entry healed. The workflow includes automation/screenshots.json in add-paths, so the next scheduled run can open a PR containing only formatting churn despite the workflow promise that PRs are opened only when an image or status changed; track whether any entry actually mutated before writing, or commit the manifest in the same normalized format.

Useful? React with 👍 / 👎.

Comment on lines +119 to +123
// Self-heal: a fulfilled "todo" becomes "ready".
if (entry.status === "todo") {
entry.status = "ready";
result.note = (result.note ? result.note + "; " : "") + "todo fulfilled -> ready";
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Update placeholder references when a todo heals

When a future docs page follows the new placeholder contract (/images/placeholder.png plus a status: "todo" manifest entry), this code writes images/${entry.name}.png and flips the manifest to ready but never edits the MDX files listed in usedBy to point at that new image. In that scenario the generated PR contains the captured image and a ready manifest entry, while the published page still renders the placeholder indefinitely; the heal step should replace the placeholder reference in the affected docs file(s) or otherwise require authors to use the final image path from the start.

Useful? React with 👍 / 👎.

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.

2 participants