Skip to content

fix: unwrapSchema calls for libraries supporting open standard schema#313

Merged
SaltyAom merged 2 commits intoelysiajs:mainfrom
macieklad:fix-open-standard-schema-calls
Dec 26, 2025
Merged

fix: unwrapSchema calls for libraries supporting open standard schema#313
SaltyAom merged 2 commits intoelysiajs:mainfrom
macieklad:fix-open-standard-schema-calls

Conversation

@macieklad
Copy link
Contributor

@macieklad macieklad commented Dec 22, 2025

Open standard schema requires target property when calling input and output conversion functions. We didn't do it, and since projects have started implementing the standard, for example, it started breaking: #312.

This PR adds the required param to the call, fixing the issue. I tested it with arktype. Other code in the function was left untouched, as we should preserve old compatibility.

Summary by CodeRabbit

  • Chores
    • Improved OpenAPI/JSON Schema generation to target the 2020-12 JSON Schema draft for better compatibility and correctness.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 22, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

The unwrapSchema function in src/openapi.ts now passes { target: "draft-2020-12" } to the JSON Schema generator when converting standard JSON Schema for input and output I/O types.

Changes

Cohort / File(s) Summary
JSON Schema Draft Configuration
src/openapi.ts
In unwrapSchema, calls to jsonSchema?.input?() and jsonSchema?.output?() were changed to jsonSchema?.[io]?({ target: "draft-2020-12" }), adding an explicit JSON Schema draft target for input/output conversion.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5 minutes

Possibly related PRs

🐰 I hopped through code, so tiny and spry,
A draft flag added, precise as the sky.
Input and output now march in a line,
Draft-2020-12 — tidy and fine. 🥕✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title clearly and concisely describes the main change: fixing unwrapSchema calls to support the open standard schema specification by adding the required target parameter.

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c7463d2 and a71a4b5.

📒 Files selected for processing (1)
  • src/openapi.ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between db1dbc5 and c7463d2.

📒 Files selected for processing (1)
  • src/openapi.ts

Comment on lines +518 to +520
return schema['~standard']?.jsonSchema?.[io]?.({
target: "draft-2020-12"
})
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Add the target: "draft-2020-12" parameter to fix Standard Schema compliance.

The change correctly implements the Standard Schema specification requirement for the target parameter. "draft-2020-12" is strongly recommended and widely used, making it the appropriate hardcoded value. Major validation libraries including ArkType, Valibot, and Zod co-authored the Standard Schema specification and already support this target.

🤖 Prompt for AI Agents
In src/openapi.ts around lines 518 to 520, the Standard Schema invocation must
pass the required target parameter; update the call to
schema['~standard']?.jsonSchema?.[io] to include target: "draft-2020-12" in its
options object so the generated JSON Schema conforms to the Standard Schema spec
(use the hardcoded string "draft-2020-12" as the value).

@macieklad macieklad changed the title Fix unwrapSchema calls for libraries supporting open standard schema fix: unwrapSchema calls for libraries supporting open standard schema Dec 23, 2025
@SaltyAom SaltyAom merged commit 179a42d into elysiajs:main Dec 26, 2025
1 check was pending
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