Repository navigation
feat: resolve external $refs (files and URLs) - #16
Merged
Merged
Conversation
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
$ref: ./schemas/pet.yaml#/Pet,$ref: https://example.com/defs.yaml#/Error) are now bundled per source before merging: each external target is hoisted into that source's owncomponentsand the$refis rewritten to#/components/.... Circular refs work, and the existing merge and rename logic is untouched. Specs without external refs produce identical output.bundlemodule inopenapi-aggregator-core(no I/O, still wasm-compatible):missing_documentsfinds what a spec needs,bundle/bundle_sourcebundle it once loaded. Each front end runs its own fetch loop.refs.rs. Addedaggregate_with_optionsandAggregateOptions;aggregateandaggregate_with_reportkeep their signatures and use the sandboxed defaults.pendingRefsand adocsargument onaggregate. The pipeline resolves referenced files from the workspace (and URLs through the existing guarded loader). Missing files get an actionable problem, and all of them are reported at once. Added a "Multi-file spec" example.Hoisting rules
#/components/<type>/<name>keeps its type and name;#/definitions/Xand#/$defs/Xbecome schemas.$refsits, and the name is the last pointer segment (the file stem for a whole-file ref).pet_Pet) and a warning is emitted. Path-item refs are inlined.example,default,enumandvaluedata is never treated as refs.Security
--allow-outside-config-dir(CLI) orAggregateOptions::allow_outside_config_dir.headersare only sent to its own origin. A document fetched over HTTP can never cause a local file read, andfile:URLs are rejected.Test plan
cargo test --workspace(location helpers, doc discovery, every bundling rule,bundle_source, 11 new CLI integration tests covering sandbox, symlink escape, absolute paths, sibling sources, header origin rule via mockito,file:from remote, missing file, 100-document cap; wasm tests)cargo clippy --workspace --all-targets -- -D warningsandcargo fmt --checkcd web && npm test(69 tests),npm run typecheck,npm run e2e