-
-
Notifications
You must be signed in to change notification settings - Fork 9
Add Support for JSON Schema Draft-04 Keywords #130
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
base: main
Are you sure you want to change the base?
Conversation
|
@jdesrosiers please have a look whenever you're free,because i feel a lot of it needs to be re iterated over |
jdesrosiers
left a comment
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.
This is a quick review. I didn't have enough time to look over everything in much detail.
Make sure you're working with @Adityakumar37 on the items/additionalItems keywords. I'm hoping to merge that PR first, then you can rebase and add the rest of the draft-04 implementation on top of that.
Anyway, your approach for those keywords isn't right. Those are simple applicators. Simple applicators don't need error handlers. Your normalization handlers should look a lot like the keywords from draft-2020-12 that serve the same purpose.
dependencies is a weird one because it's a simple applicator in some cases (schemas) and a validation keyword in other cases (string array). It can even do both at the same time. I need to go through that handler closer later, but it seems like it should be a problem.
|
hey @jdesrosiers , |
jdesrosiers
left a comment
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.
Looks pretty close now. The only thing I haven't looked at yet is the tests.
- Add normalization handlers - Add error handlers - Fix type handling and numeric count/matchCount constraints - Update draft-04 test suite
feat(draft-04): add support for JSON Schema Draft-04 keywords - Add normalization handlers - Add error handlers - Fix type handling and numeric count/matchCount constraints - Update draft-04 test suite A fix normalization and error handlers Signed-off-by: Diya <diyasrivastava2023@gmail.com> fix: normalization and error handlers for draft-04 fix type checks revert minimum and maximum error handler
|
hey @jdesrosiers |
We want to merge #131 first, so let's keep this in draft until that's merged. Other than that, yes. I'll review now, but I think it's mostly ready with exception of that one part. |
jdesrosiers
left a comment
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 added a couple more comments in the dependencies error handler. I also took a look at the tests this time. I skipped the items/additionalItems tests because I expect those to come from the other PR, but the rest of the tests look good enough.
Signed-off-by: Diya <diyasrivastava2023@gmail.com>
Signed-off-by: Diya <diyasrivastava2023@gmail.com>
jdesrosiers
left a comment
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.
Looks good except for a little cleanup.
| "$schema": "../test-suite.schema.json", | ||
| "description": "The dependencies keyword", |
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 want to maintain a convention of an empty space after $schema.
| "$schema": "../test-suite.schema.json", | |
| "description": "The dependencies keyword", | |
| "$schema": "../test-suite.schema.json", | |
| "description": "The dependencies keyword", |
| ] | ||
| } | ||
| ] | ||
| } No newline at end of file |
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.
All files should end with a newline.
| // Draft 04 Normalization Handlers | ||
| import draft04AdditionalItemsNormalizationHandler from "./normalization-handlers/draft-04/additionalItems.js"; | ||
| import draft04DependenciesNormalizationHandler from "./normalization-handlers/draft-04/dependencies.js"; | ||
| import draft04ExclusiveMaximumNormalizationHandler from "./normalization-handlers/draft-04/exclusiveMaximum.js"; | ||
| import draft04ExclusiveMinimumNormalizationHandler from "./normalization-handlers/draft-04/exclusiveMinimum.js"; | ||
| import draft04ItemsNormalizationHandler from "./normalization-handlers/draft-04/items.js"; | ||
| import draft04MaximumNormalizationHandler from "./normalization-handlers/draft-04/maximum.js"; | ||
| import draft04MinimumNormalizationHandler from "./normalization-handlers/draft-04/minimum.js"; |
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.
Imports need to be at the top.
| "messageParams": { | ||
| "maximum": "3" | ||
| }, | ||
| "messageParams": { "maximum": "3" }, |
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.
Try to avoid any unnecessary formatting changes. Please revert this and other places that were changed.
Added Support for JSON Schema Draft-04 Keywords
I have implemented full support for the requested Draft-04 keywords in
@hyperjump/json-schema-errors.Issue : #119
Changes made
itemsandadditionalItemsDraft-04 treats
itemsandadditionalItemsas siblings whereadditionalItemsvalidation depends onitems(ifitemsis an array).itemsnormalization handler in items.js.itemshandler infers the URI of the siblingadditionalItemskeyword (by string manipulation of theitemsURI) and retrieves the schema from the AST. It then acts as the validator for the "tail" items that fall underadditionalItemscriteria.dependenciesImplemented
dependencies.jsto handle both:Numeric Keywords (
maximum,minimum)Implemented handlers
maximum.js,minimum.js.exclusiveMaximum(boolean).exclusiveMaximum) to construct the correct error message ("less than" vs "less than or equal to").Also Added test cases