feat(openapi): publish Stripe API specs to Vercel CDN (stripe-sync.dev)#214
Merged
feat(openapi): publish Stripe API specs to Vercel CDN (stripe-sync.dev)#214
Conversation
5960d4b to
4a1d3b8
Compare
- 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
2f2ee6a to
06cc7f5
Compare
…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
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
docs/scripts/generate-stripe-specs.mjs: clonesstripe/openapi(blobless) at Vercel build time and extracts every published spec version todocs/out/openapi/stripe/<version>.json+manifest.jsondocs/build.mjsto run the generator during the Vercel build (skip withSKIP_STRIPE_SPECS=1for fast local builds)'cdn'resolution step inspecFetchHelper.tsbetween local cache and GitHub API — no auth, no rate limitsResolution order:
explicit_path→bundled→cache→cdn→githubThe CDN base URL defaults to
https://stripe-sync.dev/openapi/stripeand is overridable viaSTRIPE_SPEC_CDN_BASE_URL.E2E test
e2e/openapi-cdn.test.tsverifies:manifest.jsonis reachable and has valid entriesresolveOpenApiSpecreturnssource:'cdn'for non-bundled versionsTests 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