feat(openapi): generate all spec versions from git history at Docker build time#208
Open
kdhillon-stripe wants to merge 5 commits intov2from
Open
feat(openapi): generate all spec versions from git history at Docker build time#208kdhillon-stripe wants to merge 5 commits intov2from
kdhillon-stripe wants to merge 5 commits intov2from
Conversation
…allback Commits the latest Stripe OpenAPI SDK spec into the package so that when a user requests the matching API version (2026-03-25.dahlia), it is served directly from the bundled file with no network calls. For all other versions the existing cache → GitHub fetch flow is unchanged. To update the bundled spec in the future: curl -sL https://raw.githubusercontent.com/stripe/openapi/master/latest/openapi.spec3.sdk.json \ -o packages/openapi/bundled-spec.json # then bump BUNDLED_API_VERSION in specFetchHelper.ts to match info.version Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> Committed-By-Agent: claude
…build time Adds a build-time utility that walks the stripe/openapi git history to extract every published OpenAPI spec version, and wires it into the Docker image and the spec resolution flow. Changes: - packages/openapi/scripts/generate-all-specs.mjs: standalone Node ESM script (builtins only) — clones stripe/openapi with --filter=blob:none, walks git log for both spec paths (latest/openapi.spec3.sdk.json and openapi/spec3.json), deduplicates by info.version, writes <version>.json + manifest.json to an output directory - Dockerfile: new spec-builder stage that runs generate-all-specs.mjs; output is copied into the build stage before pnpm deploy so all specs land in dist/generated-specs/ in the final image - specFetchHelper.ts: checks generated-specs/manifest.json (loaded once, cached in module scope) before falling through to network; silently skips if the directory is absent (local dev with no Docker build) - package.json build script: copies generated-specs to dist if present Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> Committed-By-Agent: claude
…e scope Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> Committed-By-Agent: claude
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> Committed-By-Agent: claude
Co-Authored-By: Claude Sonnet 4.6 (1M context) <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
packages/openapi/scripts/generate-all-specs.mjs— a standalone Node ESM utility (no npm deps) that walks thestripe/openapigit history to extract every published spec version, writing<version>.json+manifest.jsonto an output directoryspec-builderstage that does a blobless clone (--filter=blob:none) ofstripe/openapi, runs the script, and copies the output into the build stage — so all historical specs land indist/generated-specs/in the final imagespecFetchHelper.tsnow checksgenerated-specs/manifest.json(loaded once, cached in module scope) before falling through to the network; matches by date part so2026-03-25hits2026-03-25.dahlia.json; silently skips if the directory is absent (local dev)Why no GitHub API
The CDN only retains the last ~4 monthly releases (
max_versions: 5in theapi-artifactsnamespace config). The GitHub REST API is rate-limited without a token. Walking git history viagit showpulls only the blobs we actually need — no auth, no rate limits.Resolution flow (in order)
explicit_path— user-provided filebundled— matchesBUNDLED_API_VERSIONconstant (latest, from PR feat(openapi): bundle latest spec (2026-03-25.dahlia) as filesystem fallback #207)bundled— matches any entry ingenerated-specs/manifest.json(all historical versions, Docker only)cache— local filesystem cache from a previous fetchgithub— live fetch from raw.githubusercontent.comTest plan
pnpm buildinpackages/openapipasses locallydocker buildruns the spec-builder stage and populatesdist/generated-specs/2024-06-20) inside Docker returnssource: 'bundled'with no network callsgenerated-specs/dir) falls through to cache/GitHub as before🤖 Generated with Claude Code