Repository navigation
feat: read an api spec from a url, and transform it before nimbus reads it - #424
Merged
Merged
Conversation
🚀 Deploying Preview to Cloudflare 🚀Preview URL: https://feat-api-spec-sources-transform.nimbus-docs.com (commit 816b98d)This URL reflects your latest Preview deploymentPreview Deployments by commit
|
🚀 Deploying Preview to Cloudflare 🚀Preview URL: https://feat-api-spec-sources-transform.demo.nimbus-docs.com (commit 816b98d)This URL reflects your latest Preview deploymentPreview Deployments by commit
|
commit: |
… into feat/api-spec-sources-transform
MohamedH1998
marked this pull request as ready for review
November 23, 2026 15:04
This branch was successfully deployed
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.
A content source can now be one file at a URL, and an API collection can prepare its spec in Node before Nimbus reads it. A site whose spec is a published file (a release asset, say) no longer needs its own download, cache and preview code, and a heavy preparation step stays out of the server bundle.
Before → after: a URL that redirects to another file
A source at a "latest" URL that redirects to a versioned file (
/latest→/v1.yaml, then/v2.yaml), where both files send the same ETag and answer 304 to any conditional request. Three builds on a fresh site, on this branch's previous head and on its current one:d34e9d1)/latest→/v1.yaml/v1.yamlfetched; page shows v1/v1.yamlfetched; page shows v1/v1.yamlasked conditionally, 304; v1/v1.yamlasked conditionally, 304; v1/latest→/v2.yaml/v2.yamlasked with v1's ETag, 304; page still shows v1/v2.yamlasked plainly; page shows v2The cache headers now go only to the URL that sent them: the saved record keeps the SHA-256 of that URL (not the URL, whose query string can hold a token).
With the server down, the fallback warning names the reason:
the request failed (ECONNREFUSED), where it saidthe request failed ().What changed
sources.<name>{ url, integrity? }, one fileapi[].spec,api[].versions[].spec{ source, path }pathis left out for a URL sourcenimbus()optionsapi: { <collection>: { transform } }, Node only, once per specnimbus-docs checkintegrityreportsnimbus/source-floating-refastro previewA URL source behaves like a Git source: saved under
.nimbus/sources, pinned or floating, revalidated withETag/Last-Modified, and read from the saved file when the server is down. Sites that use neither feature are unchanged. No starter or user-owned file changes.How to review
packages/nimbus-docs/src/types.ts,src/_internal/validate.ts: the config shape.src/_internal/source-repo.ts: fetching one file, redirects, the saved snapshot.src/_internal/content-sources.ts,src/content.ts: a URL source in the source store.src/_internal/api/spec-transform.ts: running the transform, writing and restoring its result.src/integration.ts,src/_internal/virtual-config.ts: where both are wired in.src/check/sources.ts: the floating source check.test/content-sources-url.test.ts,test/api-spec-transform.test.ts.apps/www/src/content/docs/api-reference/openapi/spec-sources.mdxand the three updated docs pages.Try it
cd packages/nimbus-docs node --import tsx --test test/content-sources-url.test.ts node --import tsx --test test/api-spec-transform.test.ts node --import tsx --test test/content-sources.test.tsChecks
tsc --noEmitclean; the three test files above pass (5, 4 and 13 tests). The transform test is a real Astro build.nimbus-docs checkreporting the floating source, the transform on rendered pages, andastro previewmaking no request.main:main