-
-
Notifications
You must be signed in to change notification settings - Fork 99
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
Roadmap for 1.0 #408
Comments
Awesome stuff @Stranger6667 ! +1 on everything, and particularly spec support, the You may also want to specify an explicit MSRV policy and consider bumping it to a more current Rust as 1.56.1 is pretty old. Using a newer Rust also unlocks newer language features that JSONschema can leverage in your roadmap. Finally, can't help but notice that crates.io is still on 0.16.1 and the repo is on 0.16.3. Any particular reason the newer releases are not published on crates.io? |
@jqnatividad thank you for your feedback and kind words! I think there will be some series of pre-releases to get the feeling of how things work and if everything is good, then I'd like to add newer specs. Recently I made some progress on the rewrite and I think things should work out with that approach, but still need to re-check things like custom keywords, anchors, dynamic refs, etc.
Great idea! Something like
Sorry for the confusion. |
@Stranger6667 , jsonschema-rs is really amazing as is. With it, Bumping the MSRV should make it even faster for "free" as the underlying under-the-hood Rust components have been updated. Inlined string formatting is great, and you should consider setting MSRV to 1.65.0 - with its Just for the heck of it, I bumped the MSRV to 1.65.0 and ran As for 0.16.3, you may want to reconsider publishing to crates.io. If anything, coz of the |
@jqnatividad thank you! It is always pleasant to hear about performance, especially when it comes to such numbers! Hopefully, there could be some more improvements coming from Aha, at this point it is hard to say whether there is a direct use case for GATs, but
Oh, indeed you're right - I forgot that I did it! Will make a new release in the next few days :) |
UPDATE: I've been working on the complete rewrite during the last month and have made some progress. I am going to update the original issue comment accordingly. So far I have implemented a generic JSON trait that allows for almost zero overhead working with the underlying JSON implementation and additionally provides a way to choose the output type for numbers (and the corresponding fn works<J: Json>(value: &J) {
let object = value.as_object().expect("Should be an object");
assert!(object.get("a").is_some());
assert!(object.get("b").is_none());
let val = value
.as_object()
.and_then(|obj| obj.get("c"))
.and_then(|k| k.as_string())
.map(|s| s.borrow().to_owned())
.expect("Key exists");
assert_eq!(val, "d");
} This approach also will help with using this library for C/C++ code by wrapping FFI pointers and implementing the Currently, I work on referencing, taking great inspiration from Python's Once referencing is done, I am going to work on the schema compiler, which will be built on top of Then output formatting as per the JSON Schema spec. Then custom keywords & format validators. With enum dispatch, I think it could be just a In any event, I am not yet ready to share what I was working on, but it will be a complete from scratch rewrite after multiple attempts (hopefully this won't be an unfinished one). P.S. And yes, it will support all current specs |
Is there a plan to introduce $ref to the local file, in addition to the remote location? For example, I have two schema files in the same dir, and I want to reference from the first file to the second one. Example:
|
@djpesic yes, I want to have resolvers to support the “file” scheme by default + have a way to build a custom resolver (which is possible with the current version too). Currently it is supported via the resolve-file feature |
Closing in favour of #475 |
This is a live document where I’d like to put my thoughts about the future 1.0 release.
Spec support
Surely all recent drafts will be nice to have but they could be added later on, as they won’t break any compatibility.
Public API
Validation
Auto-detect spec:
Specific variant:
Configure validator:
Every validation result is lazy and is cached under the hood to avoid re-validation.
Generally, the wrapper need to have the access to schema, and having a reference there is ideal, but for the shortcut api like jsonschema::validate it should be owned.
Output formatting seems to be
serde
-specific, but maybe it could be possible to provide a way to use something else via a custom trait impl.Another thing is that validation may fail because of schema error - this should be semantically separate from errors in the input instance.
Errors should be lifetime independent, or at least there should be a way to make them owned (there is a
pub(crate)
method in the current impl), otherwise moving errors around is painful.Compilation & options
I am slightly concerned about using "compilation" as a reference for this step. It is a bit confusing in the context of code compilation, maybe "build" / "builder" / "building" would be clearer.
Also, I think removing
with
/should
prefixes for options should make the process more readable. Example from another crate -Url::options().base_url(...).parse(...)
JSONSchema
->Validator
. The current naming is not compliant with Rust's naming rules +JsonSchema
will collide withschemars::JsonSchema
which is often used in the same codebase. Also, it is less repetitive.Another idea: user-provided memory. E.g. if the user passes arrays of sufficient length (for nodes, etc), then the whole
Schema
can live on the stack which could potentially give quite a big performance benefit.Extending
I think it would be nice to expose the
Validate
trait (and maybe rename it toKeyword
, not sure).Extras
Error paths could be better - they should expose the inner chunks, otherwise, the user always gets a vec of
String
viainto_vec
. However, it would be nice to avoid allocations.Internals
The main thing here is that I’d like to move away from boxing each individual keyword and use a single arena - it allows us to simplify ref resolving and move it to the schema compilation step. All other things like strings could be moved to some interner that is memory efficient
Currently, we have all the output formatting internals together with boxed keywords which implies some performance hit. It would be better to keep them separately and use them only if output formats are used, i.e. it should be a zero-cost abstraction.
Another one is generic input, so we don’t depend on
serde_json
layout. This is a huge benefit for any bindings + will unblock direct validation of e.gserde_yaml
values. This change will also affect the possibility of exposing a C API, but not yet sure about this.Project structure
Not necessarily needed for 1.0, but would help.
Ideas:
/crates/
cli
feature -> no conditional compilation forwasm32-wasi
.The text was updated successfully, but these errors were encountered: