Skip to content

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

Open
remorses wants to merge 2 commits intostandard-community:mainfrom
remorses:fix/preserve-external-refs
Open

fix: preserve external $ref URLs instead of converting to local refs#11
remorses wants to merge 2 commits intostandard-community:mainfrom
remorses:fix/preserve-external-refs

Conversation

@remorses
Copy link
Copy Markdown

@remorses remorses commented Feb 5, 2026

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
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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.

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.

2 participants