Skip to content

feat(openapi): publish Stripe API specs to Vercel CDN (stripe-sync.dev)#214

Merged
tonyxiao merged 8 commits intov2from
feat/vercel-stripe-specs
Apr 1, 2026
Merged

feat(openapi): publish Stripe API specs to Vercel CDN (stripe-sync.dev)#214
tonyxiao merged 8 commits intov2from
feat/vercel-stripe-specs

Conversation

@tonyxiao
Copy link
Copy Markdown
Collaborator

Summary

  • Adds docs/scripts/generate-stripe-specs.mjs: clones stripe/openapi (blobless) at Vercel build time and extracts every published spec version to docs/out/openapi/stripe/<version>.json + manifest.json
  • Updates docs/build.mjs to run the generator during the Vercel build (skip with SKIP_STRIPE_SPECS=1 for fast local builds)
  • Adds 'cdn' resolution step in specFetchHelper.ts between local cache and GitHub API — no auth, no rate limits

Resolution order: explicit_pathbundledcachecdngithub

The CDN base URL defaults to https://stripe-sync.dev/openapi/stripe and is overridable via STRIPE_SPEC_CDN_BASE_URL.

E2E test

e2e/openapi-cdn.test.ts verifies:

  1. manifest.json is reachable and has valid entries
  2. First 3 spec files are valid OpenAPI objects
  3. resolveOpenApiSpec returns source:'cdn' for non-bundled versions

Tests skip gracefully (with a warning) when the CDN isn't deployed yet, and fail hard once it's live but broken.

Activation

Once this PR merges and Vercel redeploys the docs site, the CDN will be populated and the e2e tests will run for real.

🤖 Generated with Claude Code

@tonyxiao tonyxiao force-pushed the feat/vercel-stripe-specs branch from 5960d4b to 4a1d3b8 Compare March 31, 2026 18:17
tonyxiao and others added 4 commits March 31, 2026 23:02
- Add docs/scripts/generate-stripe-specs.mjs: fetches every published
  Stripe REST API spec version via GitHub Commits API + raw.githubusercontent.com,
  writes <version>.json + manifest.json + index.html to outputDir.
  Queries both spec paths (latest/openapi.spec3.sdk.json and openapi/spec3.json)
  to cover historic and current versions (~51 total).

- Update docs/build.mjs to run the generator into out/stripe-api-specs/
  during Vercel build; skip via SKIP_STRIPE_SPECS=1.

- Add CDN fallback tier to resolveOpenApiSpec (specFetchHelper.ts):
  checks stripe-sync.dev/stripe-api-specs/manifest.json before hitting
  GitHub API, avoiding rate limits for consumers. Override with
  STRIPE_SPEC_CDN_BASE_URL env var.

- Export BUNDLED_API_VERSION from packages/openapi index.

- Add 'cdn' to ResolvedOpenApiSpec.source union type.

- Add ci: pass GITHUB_TOKEN to Deploy Docs build step for authenticated
  GitHub API calls during spec generation.

- Add e2e/openapi-cdn.test.ts: skips gracefully if CDN not deployed,
  verifies manifest reachable + spot-checks spec files + resolveOpenApiSpec
  returns source:'cdn'.

These are the official Stripe REST API specs (github.com/stripe/openapi),
NOT the Sync Engine's own OpenAPI spec.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Committed-By-Agent: claude
- Remove push-only guard from docs job so branch deployments trigger Vercel
- Branch pushes get a preview URL; main pushes deploy to production
- Capture deployment URL as job output and print to step summary with branch name
- Add e2e_cdn job (needs: docs) that runs openapi-cdn.test.ts against the deployed URL

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Committed-By-Agent: claude
Replace GitHub REST API + raw.githubusercontent.com with a blobless
git clone:
- No auth required (drops GITHUB_TOKEN from vercel build step)
- No rate limits (was 60 req/h without token)
- ls-tree reads tree objects locally (no network per-commit)
- Only unique blobs are fetched via cat-file (deduplicates identical
  content across commits)
- STRIPE_OPENAPI_REPO env var allows injecting a pre-cloned path
  (e.g. from CI cache) to skip the clone entirely

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Committed-By-Agent: claude
…fix PAGES_DIR

- Switch from blobless clone to single-branch clone so blobs are available locally
  (blobless clone caused 0 spec versions: git cat-file fetches were failing silently)
- Default maxVersions to 3 for simplicity (was 5)
- Fix PAGES_DIR from nonexistent `docs/pages` to `docs/` root

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Committed-By-Agent: claude
@tonyxiao tonyxiao force-pushed the feat/vercel-stripe-specs branch from 2f2ee6a to 06cc7f5 Compare April 1, 2026 06:03
tonyxiao and others added 4 commits March 31, 2026 23:19
…n default

- generate-stripe-specs.mjs: set maxBuffer: 50MB for git cat-file; Stripe specs
  are ~10MB so the 1MB default was silently throwing, yielding 0 spec versions
- source-stripe: default api_version to BUNDLED_API_VERSION instead of '2020-08-27'
  so tests without an explicit api_version use the bundled spec (no network needed)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Committed-By-Agent: claude
Required after the inject-fetch refactor in v2.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Committed-By-Agent: claude
- Remove MAX_VERSIONS cap — collect every unique API version from history
  since the full clone already has everything; blob-SHA dedup keeps it fast
- Add trailingSlash: true to vercel.json so /stripe-api-specs redirects to
  /stripe-api-specs/ before serving index.html, fixing relative links

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Committed-By-Agent: claude
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Committed-By-Agent: claude
@tonyxiao tonyxiao merged commit 21c8d8d into v2 Apr 1, 2026
10 checks passed
@tonyxiao tonyxiao deleted the feat/vercel-stripe-specs branch April 1, 2026 07:10
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.

1 participant