diff --git a/schemars/tests/crate_alias.rs b/schemars/tests/crate_alias.rs deleted file mode 100644 index e5d56f9d..00000000 --- a/schemars/tests/crate_alias.rs +++ /dev/null @@ -1,20 +0,0 @@ -mod util; -use ::schemars as not_schemars; -use util::*; - -#[allow(unused_imports)] -use std as schemars; - -#[allow(dead_code)] -#[derive(not_schemars::JsonSchema)] -#[schemars(crate = "not_schemars")] -struct Struct { - /// This is a document - foo: i32, - bar: bool, -} - -#[test] -fn test_crate_alias() -> TestResult { - test_default_generated_schema::("crate_alias") -} diff --git a/schemars/tests/expected/crate_alias.json b/schemars/tests/expected/crate_alias.json deleted file mode 100644 index c2f14305..00000000 --- a/schemars/tests/expected/crate_alias.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "$schema": "https://json-schema.org/draft/2020-12/schema", - "title": "Struct", - "type": "object", - "properties": { - "foo": { - "description": "This is a document", - "type": "integer", - "format": "int32" - }, - "bar": { - "type": "boolean" - } - }, - "required": [ - "foo", - "bar" - ] -} \ No newline at end of file diff --git a/schemars/tests/integration/crate_alias.rs b/schemars/tests/integration/crate_alias.rs new file mode 100644 index 00000000..f84fe228 --- /dev/null +++ b/schemars/tests/integration/crate_alias.rs @@ -0,0 +1,19 @@ +use crate::prelude::*; +use ::schemars as aliased_schemars; + +#[allow(dead_code)] +#[derive(aliased_schemars::JsonSchema, Deserialize, Serialize, Default)] +#[schemars(crate = "aliased_schemars")] +struct MyStruct { + /// Is it ok with doc comments? + foo: i32, + #[schemars(extend("x-test" = "...and extensions?"))] + bar: bool, +} + +#[test] +fn crate_alias() { + test!(MyStruct) + .assert_allows_ser_roundtrip_default() + .assert_matches_de_roundtrip(arbitrary_values()); +} diff --git a/schemars/tests/integration/main.rs b/schemars/tests/integration/main.rs index 60c2fae7..160dc837 100644 --- a/schemars/tests/integration/main.rs +++ b/schemars/tests/integration/main.rs @@ -6,6 +6,7 @@ mod bytes; #[cfg(feature = "chrono04")] mod chrono; mod contract; +mod crate_alias; mod prelude { pub use crate::test; diff --git a/schemars/tests/integration/test_helper.rs b/schemars/tests/integration/test_helper.rs index f1b577eb..7f23dcdd 100644 --- a/schemars/tests/integration/test_helper.rs +++ b/schemars/tests/integration/test_helper.rs @@ -246,7 +246,7 @@ impl Deserialize<'de>> TestHelper { assert!( T::deserialize(value).is_err(), - "invalid test case - expected deserialize to succeed for {}: {value}", + "invalid test case - expected deserialize to fail for {}: {value}", type_name::() );