Skip to content

fix: preserve external $ref URLs instead of converting to local refs - #11

Merged
MathurAditya724 merged 2 commits into
standard-community:mainfrom
remorses:fix/preserve-external-refs
Sep 6, 2026
Merged

MathurAditya724 merged 2 commits into
standard-community:mainfrom
remorses:fix/preserve-external-refs

Conversation

@remorses

@remorses remorses commented Feb 5, 2026 •

Copy link
Copy Markdown
Contributor

External $ref URLs (http/https) are now preserved as-is instead of being converted to local #/components/schemas/ references.

This allows schemas to reference external JSON Schema definitions for editor autocomplete while keeping the OpenAPI spec valid.

Example: $ref: "https://models.dev/model-schema.json#/$defs/Model" is now preserved instead of being converted to $ref: "#/components/schemas/Model".

cc @MathurAditya724

Blocked PR: anomalyco/opencode#12112

Copilot AI review requested due to automatic review settings February 5, 2026 10:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes the handling of external $ref URLs in schema conversions. Previously, all $ref values were converted to local OpenAPI component references (#/components/schemas/...), but now external URLs (http/https) are preserved as-is.

Changes:

  • Modified convertToOpenAPISchema to detect and preserve external $ref URLs instead of converting them to local component references
  • Added test case for external $ref URL preservation with Zod v4
  • Updated snapshot to reflect the new behavior where external URLs are kept intact

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/vendors/convert.ts Added logic to detect http/https URLs in $ref and preserve them instead of converting to local component refs
tests/zod_v4.test.ts Added test case verifying external $ref URLs are preserved
tests/snapshots/zod_v4.test.ts.snap Snapshot showing external URL is preserved alongside original schema properties

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/vendors/convert.ts Outdated
Comment thread src/vendors/convert.ts Outdated
@MathurAditya724
MathurAditya724 force-pushed the fix/preserve-external-refs branch from 2630490 to 0e62974 Compare September 6, 2026 05:45
@pkg-pr-new

pkg-pr-new Bot commented Sep 6, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@standard-community/standard-openapi@11

commit: 0e62974

@MathurAditya724
MathurAditya724 merged commit c802e24 into standard-community:main Sep 6, 2026
2 of 3 checks passed
@remorses

remorses commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

thanks!

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.

3 participants