parent
e2d09aa932
commit
233e1a0a41
|
@ -2,6 +2,15 @@
|
|||
|
||||
## [Unreleased]
|
||||
|
||||
### Fixed
|
||||
|
||||
- Library compilation with no default features. [#356](https://github.com/Stranger6667/jsonschema-rs/issues/356)
|
||||
- Compilation with `resolve-file` only. [#358](https://github.com/Stranger6667/jsonschema-rs/issues/358)
|
||||
|
||||
### Changed
|
||||
|
||||
- **BREAKING**: Revert changes from [#353](https://github.com/Stranger6667/jsonschema-rs/issues/353) and [#343](https://github.com/Stranger6667/jsonschema-rs/issues/343), as they caused compilation issues.
|
||||
|
||||
## [0.15.2] - 2022-04-10
|
||||
|
||||
### Fixed
|
||||
|
|
14
README.md
14
README.md
|
@ -23,9 +23,6 @@ Partially supported drafts (some keywords are not implemented):
|
|||
jsonschema = "0.15"
|
||||
```
|
||||
|
||||
By default `jsonschema` resolves remote references via HTTP by using `reqwest` with `native-tls`.
|
||||
If you'd like to use `rustls`, you have to explicitly enable `reqwest` and `rustls` features and disable `native-tls` via `default-features = false` in your `Cargo.toml` file.
|
||||
|
||||
To validate documents against some schema and get validation errors (if any):
|
||||
|
||||
```rust
|
||||
|
@ -121,6 +118,17 @@ fn main() {
|
|||
}
|
||||
```
|
||||
|
||||
## Reference resolving and TLS
|
||||
|
||||
By default, `jsonschema` resolves HTTP references via `reqwest` without TLS support.
|
||||
If you'd like to resolve HTTPS, you need to enable TLS support in `reqwest`:
|
||||
|
||||
```toml
|
||||
reqwest = { version = "*", features = [ "rustls-tls" ] }
|
||||
```
|
||||
|
||||
Otherwise, you might get validation errors like `invalid URL, scheme is not http`.
|
||||
|
||||
## Status
|
||||
|
||||
This library is functional and ready for use, but its API is still evolving to the 1.0 API.
|
||||
|
|
|
@ -21,12 +21,9 @@ default = ["resolve-http", "resolve-file", "cli"]
|
|||
draft201909 = []
|
||||
draft202012 = []
|
||||
|
||||
resolve-http = ["reqwest", "native-tls"]
|
||||
resolve-http = ["reqwest"]
|
||||
resolve-file = []
|
||||
|
||||
native-tls = ["reqwest/default-tls"]
|
||||
rustls = ["reqwest/rustls-tls"]
|
||||
|
||||
[dependencies]
|
||||
ahash = { version = "0.7.6", features = ["serde"] }
|
||||
anyhow = "1.0.55"
|
||||
|
@ -42,7 +39,7 @@ num-cmp = "0.1.0"
|
|||
parking_lot = "0.12.0"
|
||||
percent-encoding = "2.1.0"
|
||||
regex = "1.5.4"
|
||||
reqwest = { package = "reqwest", version = "0.11.9", features = ["blocking", "json"], default-features = false, optional = true }
|
||||
reqwest = { version = "0.11.9", features = ["blocking", "json"], default-features = false, optional = true }
|
||||
serde = { version = "1.0.136", features = ["derive"] }
|
||||
serde_json = "1.0.79"
|
||||
structopt = { version = "0.3.26", optional = true }
|
||||
|
|
|
@ -76,30 +76,17 @@ impl SchemaResolver for DefaultResolver {
|
|||
) -> Result<Arc<Value>, SchemaResolverError> {
|
||||
match url.scheme() {
|
||||
"http" | "https" => {
|
||||
#[cfg(not(any(
|
||||
feature = "resolve-http",
|
||||
all(feature = "reqwest", feature = "rustls"),
|
||||
test
|
||||
)))]
|
||||
#[cfg(all(feature = "reqwest", not(feature = "resolve-http")))]
|
||||
{
|
||||
compile_error!(
|
||||
r#"the `reqwest` feature alone does not enable HTTP schema resolving anymore.
|
||||
Use the `resolve-http` feature which enables `native-tls` as well;
|
||||
or both `reqwest` and `rustls` features together, if you prefer rustls."#
|
||||
);
|
||||
compile_error!("the `reqwest` feature does not enable HTTP schema resolving anymore, use the `resolve-http` feature instead");
|
||||
}
|
||||
|
||||
#[cfg(any(
|
||||
feature = "resolve-http",
|
||||
all(feature = "reqwest", feature = "rustls"),
|
||||
test
|
||||
))]
|
||||
#[cfg(any(feature = "resolve-http", test))]
|
||||
{
|
||||
let response = reqwest::blocking::get(url.as_str())?;
|
||||
let document: Value = response.json()?;
|
||||
Ok(Arc::new(document))
|
||||
}
|
||||
#[cfg(not(any(feature = "resolve-http", all(feature="reqwest", feature="rustls"), test)))]
|
||||
#[cfg(not(any(feature = "resolve-http", test)))]
|
||||
Err(anyhow::anyhow!("`resolve-http` feature or a custom resolver is required to resolve external schemas via HTTP"))
|
||||
}
|
||||
"file" => {
|
||||
|
|
Loading…
Reference in New Issue