feat: Custom Resolvers for external references - #341
Conversation
Codecov Report
@@ Coverage Diff @@
## master #341 +/- ##
==========================================
- Coverage 82.72% 82.70% -0.02%
==========================================
Files 57 57
Lines 5516 5533 +17
==========================================
+ Hits 4563 4576 +13
- Misses 953 957 +4
Continue to review full report at Codecov.
|
Stranger6667
left a comment
There was a problem hiding this comment.
Amazing! Thank you so much @tamasfe for putting this PR with such a great level of details :)
I added a few minor comments, and here are a few more general things:
- I am good with adding
anyhow, it is indeed quite convenient :) - Re: benchmarks - I don't think there will be notable changes + caching will reduce it even more
- A changelog entry would be nice
- There are failing tests in Python bindings, but it should be solved by adding new
resolve-*features
Otherwise, looks great to me!
Co-authored-by: Dmitry Dygalo <Stranger6667@users.noreply.github.com>
|
Thanks @Stranger6667! I've also added the original schema reference string to be passed to the resolver so that relative references are always preserved. The tests should pass now as well. I also started building on |
|
Thank you @tamasfe for your contribution! :) Great PR!
Glad to hear about it! |
|
Could you, please, rebase the branch? |
|
Strange, that after rebase the UI still showed some conflicts, so I squashed it :) Will make a new release soon |
|
Awesome, thanks! Github also showed that my branch was based on master HEAD, so I'm not entirely sure why the rebase was needed (but it was). It was probably due to making edits on the GUI here. Sorry about the awful graph, I don't think I'll ever figure git out in this lifetime. |
A PR for #246. It does not touch on the
asyncfeature, but makes the library build onwasm32-unknown-unknownwithdefault-features = falseand enables my use-case in taplo.Added
The
SchemaResolvertrait that is supposed to resolve external schemas by given URLs along with aDefaultResolverthat does what was already implemented, and additionally also resolvesfileschemes via std.I decided to just use
Arc<dyn SchemaResolver>as it is only used by ref validators currently, and adding generics everywhere would've added too much complexity.A
ValidationError::Resolvervariant was also added accordingly to report if any of the external resolutions failed.A compiler option to set a custom resolver was also added.
The following features were added to customize the default resolver:
resolve-http: blocking reqwestresolve-file: resolution viastd::fsBoth of them are enabled by default so there should be no breaking changes for current users.
Removed
The reqwest error variant.
All
reqwest-*features, the users of the library can addreqwestas a dependency itself and enable the features they wish, this is a breaking change, although I don't know if anyone used these features.Additional Dependencies
Box<dyn std::error::Error>, although it's not strictly required for this PR.TODO
More documentation and tests perhaps?
Also I haven't yet ran or compared the benchmarks, but I don't think that there would be any visible performance hits.