-
-
Notifications
You must be signed in to change notification settings - Fork 97
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
HTTP Resolver Not Working? #343
Comments
Hi! Thanks for reporting! Could you, please, share the schema so I can reproduce the issue? Looks strange to me - does it work with |
Sure, the schema is: {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"people": {
"type": "array",
"items": {
"$ref": "https://schema.rawkode.dev/person"
},
"links": [
{
"rel": "collection",
"href": "#/organizations/{id}",
"templateRequired": [
"id"
]
}
]
},
"organizations": {
"type": "array",
"items": {
"$ref": "https://schema.rawkode.dev/organization"
}
}
}
} I'll test with 0.14 and report back. |
Still a problem with Let me know if you need anything else, @Stranger6667 |
Thanks for sharing! At 778b424 I cannot reproduce it locally :( Tried this instance: {
"people": [
{"name": "x", "forename": "y", "surname": "z"}
],
"organizations": [
{"name": "a"}
]
} And this command (I suppressed warnings coming from not enabled newer drafts support):
Though it is the same result with all features enabled (including partial Draft 2020-12 support):
The same happens with the Could you, please, provide the following:
Later I'll try to create a PR with this test case to isolate it a bit (maybe I have something that hides the issue locally). |
I'm actually using this as a library and my code looks like: use std::{fs::File, io::BufReader};
use jsonschema::JSONSchema;
fn main() {
let file = File::open("schema.json").unwrap();
let reader = BufReader::new(file);
let schema = serde_json::from_reader(reader).unwrap();
let file = File::open("data.json").unwrap();
let reader = BufReader::new(file);
let instance = serde_json::from_reader(reader).unwrap();
let compiled = JSONSchema::compile(&schema).expect("A valid schema");
let result = compiled.validate(&instance);
if let Err(errors) = result {
for error in errors {
println!("Validation error: {}", error);
println!("Instance path: {}", error.instance_path);
}
}
} My {
"$schema": "./schema.json",
"people": [
{
"forename": "David",
"surname": "Flanagan",
"email": "david@rawkode.dev",
"employers": [
"Pulumi"
]
}
],
"organizations": [
{
"name": "Pulumi"
}
]
} and my {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"people": {
"type": "array",
"items": {
"$ref": "https://schema.rawkode.dev/person"
},
"links": [
{
"rel": "collection",
"href": "#/organizations/{id}",
"templateRequired": [
"id"
]
}
]
},
"organizations": {
"type": "array",
"items": {
"$ref": "https://schema.rawkode.dev/organization"
}
}
}
} |
Running the js schema.json -i data.json
data.json - VALID I'm confused 😅 |
And so am I! :) Will check it deeper |
@Stranger6667 Am I reading that correctly? Did that test pass? 😱 |
Yes 😕 Maybe it is related to some dependencies? which somehow indirectly affect |
|
@Stranger6667 I've pushed the whole thing. This is very much the testing phase, there's nothing secret |
❯ cargo run
Finished dev [unoptimized + debuginfo] target(s) in 0.03s
Running `target/debug/active-data`
thread 'main' panicked at 'assertion failed: result.is_ok()', src/main.rs:14:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace |
Thank you so much for such detailed info :) I reproduced this behavior Could you try adding |
Oh, we have reqwest = { version = ">= 0.10", features = ["blocking", "json"], default-features = false, optional = true } which means that by default, |
Sorry that it took so long, |
Hi,
Sorry, I've been trying to work this out myself, but I'm not sure what's going wrong.
These URLs are definitely OK and I'm not sure what I've done wrong.
I've tried using
http
instead ofhttps
in my schema, but the problem is the same.Any help appreciated.
The text was updated successfully, but these errors were encountered: