-
-
Notifications
You must be signed in to change notification settings - Fork 293
Valibot toJsonSchema v1.5
#1372
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
commit: |
There was a problem hiding this 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 adds support for JSON Schema draft-2020-12 alongside the existing draft-07 support, removes the dependency on @types/json-schema, and improves record schema conversion by adding propertyNames support for key validation constraints.
Key Changes
- Replaced external
JSONSchema7type with a customJsonSchematype that supports both draft-07 and draft-2020-12 - Added a
targetconfiguration option to specify which JSON Schema draft version to use (defaults to 'draft-07') - Enhanced record schema conversion to include
propertyNamesfor key validation, removing the previous restriction on pipes in record keys
Reviewed changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pnpm-lock.yaml | Updated lockfile to reflect removal of @types/json-schema dependency |
| packages/to-json-schema/package.json | Removed @types/json-schema from devDependencies |
| packages/to-json-schema/src/types/schema.ts | Added custom JsonSchema interface supporting both draft-07 and draft-2020-12 with deprecated JSONSchema7 alias |
| packages/to-json-schema/src/types/index.ts | New index file exporting type definitions |
| packages/to-json-schema/src/types/config.ts | Updated all type references from JSONSchema7 to JsonSchema and added target option |
| packages/to-json-schema/src/index.ts | Updated exports to use new types structure instead of external json-schema package |
| packages/to-json-schema/src/vitest/createContext.ts | Updated import path for types |
| packages/to-json-schema/src/utils/handleError.ts | Updated import path for types |
| packages/to-json-schema/src/functions/toJsonSchema/toJsonSchema.ts | Updated type references and added logic to set appropriate $schema based on target |
| packages/to-json-schema/src/functions/toJsonSchemaDefs/toJsonSchemaDefs.ts | Updated type references from JSONSchema7 to JsonSchema |
| packages/to-json-schema/src/converters/convertSchema/convertSchema.ts | Added conditional logic for tuple conversion based on target (prefixItems vs items array), and added propertyNames support for record schemas |
| packages/to-json-schema/src/converters/convertAction/convertAction.ts | Updated type references from JSONSchema7 to JsonSchema |
| packages/to-json-schema/src/converters/convertSchema/convertSchema.test.ts | Updated tests to expect propertyNames in record schema output and removed obsolete pipe-in-key error tests |
| packages/to-json-schema/CHANGELOG.md | Added changelog entry for v1.5 with new features |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (1)
packages/to-json-schema/src/types/config.ts:102
- The documentation for the
targetoption should explain the differences between draft-07 and draft-2020-12. For example, it should mention that draft-2020-12 usesprefixItemsfor tuple schemas whereas draft-07 uses an array foritems.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/to-json-schema/src/converters/convertSchema/convertSchema.test.ts
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 14 out of 15 changed files in this pull request and generated 1 comment.
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (1)
packages/to-json-schema/src/types/config.ts:101
- The documentation comment is slightly misleading. It states "The target JSON Schema draft version" but
openapi-3.0is not a JSON Schema draft version—it's the OpenAPI 3.0 Schema Object format. Consider updating to: "The target schema format. Supports JSON Schema draft versions and OpenAPI Schema Object format. Defaults to 'draft-07'."
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/to-json-schema/src/converters/convertSchema/convertSchema.test.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 21 out of 22 changed files in this pull request and generated 4 comments.
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
No description provided.