| 1 | use craterust-analyzer cargo schemars 1.2.2 crate/::preluderust-analyzer cargo schemars 1.2.2 prelude/::*; |
| 2 | |
| 3 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(JsonSchemarust-analyzer cargo schemars_derive 1.2.2 JsonSchema:, Deserializerust-analyzer cargo serde_derive 1.0.229 Deserialize:, Serializerust-analyzer cargo serde_derive 1.0.229 Serialize:)] |
| 4 | #[serde(deny_unknown_fields)] |
| 5 | struct Structrust-analyzer cargo schemars 1.2.2 skip/Struct# { |
| 6 | #[serderust-analyzer cargo schemars_derive 1.2.2 serde:(skip)] |
| 7 | _skippedrust-analyzer cargo schemars 1.2.2 skip/Struct#_skipped.: bool, |
| 8 | includedrust-analyzer cargo schemars 1.2.2 skip/Struct#included.: bool, |
| 9 | } |
| 10 | |
| 11 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 12 | fn skip_struct_fieldrust-analyzer cargo schemars 1.2.2 skip/skip_struct_field().() { |
| 13 | testrust-analyzer cargo schemars 1.2.2 test!!(Structrust-analyzer cargo schemars 1.2.2 skip/Struct#) |
| 14 | .assert_snapshotrust-analyzer cargo schemars 1.2.2 test_helper/impl#[`TestHelper<T>`]assert_snapshot().() |
| 15 | .assert_allows_de_roundtriprust-analyzer cargo schemars 1.2.2 test_helper/impl#[`TestHelper<T>`]assert_allows_de_roundtrip().([jsonrust-analyzer cargo serde_json 1.0.151 macros/json!!({ "included": true })]) |
| 16 | .assert_rejects_derust-analyzer cargo schemars 1.2.2 test_helper/impl#[`TestHelper<T>`]assert_rejects_de().([jsonrust-analyzer cargo serde_json 1.0.151 macros/json!!({ |
| 17 | "_skipped": true, |
| 18 | "included": true |
| 19 | })]) |
| 20 | .assert_matches_de_roundtriprust-analyzer cargo schemars 1.2.2 test_helper/impl#[`TestHelper<T>`]assert_matches_de_roundtrip().(arbitrary_values_exceptrust-analyzer cargo schemars 1.2.2 test_helper/arbitrary_values_except().( |
| 21 | Valuerust-analyzer cargo serde_json 1.0.151 value/Value#::is_arrayrust-analyzer cargo serde_json 1.0.151 value/impl#[Value]is_array()., |
| 22 | "structs with `#derive(Deserialize)` can technically be deserialized from sequences, but that's not intended to be used via JSON, so schemars ignores it", |
| 23 | )); |
| 24 | } |
| 25 | |
| 26 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(JsonSchemarust-analyzer cargo schemars_derive 1.2.2 JsonSchema:, Deserializerust-analyzer cargo serde_derive 1.0.229 Deserialize:, Serializerust-analyzer cargo serde_derive 1.0.229 Serialize:)] |
| 27 | pub enum Enumrust-analyzer cargo schemars 1.2.2 skip/Enum# { |
| 28 | Included1rust-analyzer cargo schemars 1.2.2 skip/Enum#Included1#, |
| 29 | #[serderust-analyzer cargo schemars_derive 1.2.2 serde:(skip)] |
| 30 | _Skippedrust-analyzer cargo schemars 1.2.2 skip/Enum#_Skipped#, |
| 31 | Included2rust-analyzer cargo schemars 1.2.2 skip/Enum#Included2#, |
| 32 | } |
| 33 | |
| 34 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 35 | fn skip_enum_variantsrust-analyzer cargo schemars 1.2.2 skip/skip_enum_variants().() { |
| 36 | testrust-analyzer cargo schemars 1.2.2 test!!(Enumrust-analyzer cargo schemars 1.2.2 skip/Enum#) |
| 37 | .assert_snapshotrust-analyzer cargo schemars 1.2.2 test_helper/impl#[`TestHelper<T>`]assert_snapshot().() |
| 38 | .assert_allows_de_roundtriprust-analyzer cargo schemars 1.2.2 test_helper/impl#[`TestHelper<T>`]assert_allows_de_roundtrip().([jsonrust-analyzer cargo serde_json 1.0.151 macros/json!!("Included1"), jsonrust-analyzer cargo serde_json 1.0.151 macros/json!!("Included2")]) |
| 39 | .assert_rejects_derust-analyzer cargo schemars 1.2.2 test_helper/impl#[`TestHelper<T>`]assert_rejects_de().([jsonrust-analyzer cargo serde_json 1.0.151 macros/json!!("_Skipped")]) |
| 40 | .assert_matches_de_roundtriprust-analyzer cargo schemars 1.2.2 test_helper/impl#[`TestHelper<T>`]assert_matches_de_roundtrip().(arbitrary_valuesrust-analyzer cargo schemars 1.2.2 test_helper/arbitrary_values().()); |
| 41 | } |