jsonschema-rs icon indicating copy to clipboard operation
jsonschema-rs copied to clipboard

Interest in a "lite" feature?

Open enkore opened this issue 3 months ago • 3 comments

This is a very good library with solid coverage of the JSON schema spec. However, both JSON and JSON schema especially have a few corner cases that are particularly difficult to handle. JSON itself has the whole "what's a number, really?" thing, and JSON schema has a few interesting corners in the spec like:

These add considerable amounts of code to jsonschema; fancy regex and the "high-end" regex crate seem to add up to about 1 MB of code these days. Just the special case of multipleOf with a float multiple adds a bignum math library.

I suspect that many end-users don't use these corners of the spec (I know I don't) and could benefit from a "lite" feature set:

  • fewer dependencies means less code to keep an eye on,
  • quicker compile times and
  • smaller artifacts

I did some haphazard exploration of adding this and it doesn't seem to be particularly annoying. The biggest change would be introducing a module (or just a bunch of #[cfg] use in lib.rs) to select between the different regex engines for the different use-cases, since fancy-regex is only used for matching schema-supplied RE, while regex is used for internal REs. lite would switch both of these to regex-lite. The remainder is pretty much just a few cfg attributes to disable some validators. I haven't looked at tests though, yet.

enkore avatar Mar 25 '24 15:03 enkore