-
Notifications
You must be signed in to change notification settings - Fork 45
feat: accept JSON Schema Draft 6 & Draft 7 #139
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,7 +25,7 @@ export const numberValidationNames = [ | |
| 'exclusiveMaximum', | ||
| ]; | ||
|
|
||
| const exampleValidationNames = ['examples', 'example', 'x-example']; | ||
| const exampleValidationNames = ['examples']; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| const excludedValidations = ['exclusiveMinimum', 'exclusiveMaximum', 'readOnly', 'writeOnly']; | ||
|
|
||
|
|
@@ -58,11 +58,8 @@ const createValidationsFormatter = (name: string, options?: { exact?: boolean; n | |
| }; | ||
|
|
||
| const validationFormatters: Record<string, (value: unknown) => ValidationFormat | null> = { | ||
| ['const']: createValidationsFormatter('Allowed'), | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| enum: createValidationsFormatter('Allowed'), | ||
| examples: createValidationsFormatter('Example'), | ||
| example: createValidationsFormatter('Example'), | ||
| ['x-example']: createValidationsFormatter('Example'), | ||
| multipleOf: createValidationsFormatter('Multiple of', { exact: true }), | ||
| pattern: createValidationsFormatter('Match pattern', { exact: true, nowrap: true }), | ||
| default: createValidationsFormatter('Default'), | ||
|
|
@@ -208,8 +205,6 @@ export function getValidationsFromSchema(schemaNode: RegularNode) { | |
| ? { | ||
| ...(schemaNode.annotations.default ? { default: schemaNode.annotations.default } : null), | ||
| ...(schemaNode.annotations.examples ? { examples: schemaNode.annotations.examples } : null), | ||
| ...(schemaNode.annotations.const ? { const: schemaNode.annotations.const } : null), | ||
| ...(schemaNode.annotations['x-example'] ? { ['x-example']: schemaNode.annotations['x-example'] } : null), | ||
| } | ||
| : null), | ||
| ...getFilteredValidations(schemaNode), | ||
|
|
||
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.
I hope the order doesn't matter for you.