You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ cargo test --features=schemars test_ipnetwork_json Blocking waiting for file lock on build directory Compiling does-it-json v0.0.1 (/Users/ahl/src/does-it-json) Compiling ipnetwork v0.19.0 (/Users/ahl/src/ipnetwork) Finished test [unoptimized + debuginfo] target(s) in 2.20s Running unittests src/lib.rs (target/debug/deps/ipnetwork-5bc3e27d373077a5)running 0 teststest result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 63 filtered out; finished in 0.00s Running tests/test_json.rs (target/debug/deps/test_json-c7e0909f58ffe5cf)running 1 testtest tests::test_ipnetwork_json ... FAILEDfailures:---- tests::test_ipnetwork_json stdout ----thread 'tests::test_ipnetwork_json' panicked at 'error: "127.1.0.0/24" did not conform to the schema at #/definitions/IpNetwork.oneOf: value validated against 0 of 2 `oneOf` schemas (rather than 1)schema: { "$schema": "http://json-schema.org/draft-07/schema#", "title": "MyStruct", "type": "object", "required": [ "ipnetwork" ], "properties": { "ipnetwork": { "type": "array", "items": { "$ref": "#/definitions/IpNetwork" } } }, "definitions": { "IpNetwork": { "description": "Represents a generic network range. This type can have two variants: the v4 and the v6 case.", "oneOf": [ { "type": "object", "required": [ "V4" ], "properties": { "V4": { "$ref": "#/definitions/Ipv4Network" } }, "additionalProperties": false }, { "type": "object", "required": [ "V6" ], "properties": { "V6": { "$ref": "#/definitions/Ipv6Network" } }, "additionalProperties": false } ] }, "Ipv4Network": { "description": "Represents a network range where the IP addresses are of v4", "type": "object", "required": [ "addr", "prefix" ], "properties": { "addr": { "type": "string", "format": "ipv4" }, "prefix": { "type": "integer", "format": "uint8", "minimum": 0.0 } } }, "Ipv6Network": { "description": "Represents a network range where the IP addresses are of v6", "type": "object", "required": [ "addr", "prefix" ], "properties": { "addr": { "type": "string", "format": "ipv6" }, "prefix": { "type": "integer", "format": "uint8", "minimum": 0.0 } } } }}value: { "ipnetwork": [ "127.1.0.0/24", "::1/0" ]}', tests/test_json.rs:69:13note: run with `RUST_BACKTRACE=1` environment variable to display a backtracefailures: tests::test_ipnetwork_jsontest result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 2 filtered out; finished in 0.00serror: test failed, to rerun pass '--test test_json'
The problem is that #153 simply derived JsonSchema rather than generating a schema that matches the implementation of Serialize. I would be happy to submit a PR; just let me know.
The text was updated successfully, but these errors were encountered:
See: https://github.com/ahl/ipnetwork/tree/fail
The problem is that #153 simply derived
JsonSchema
rather than generating a schema that matches the implementation ofSerialize
. I would be happy to submit a PR; just let me know.The text was updated successfully, but these errors were encountered: