Debian Codegraph @

tests/integration/deprecated.rs

raw symbols SCIP
1 #![allow(deprecated)]
2
3 use crate::prelude::*;
4 use pretty_assertions::assert_eq;
5
6 #[derive(JsonSchema, Default, Serialize, Deserialize)]
7 #[deprecated]
8 struct DeprecatedStruct {
9 foo: i32,
10 #[deprecated]
11 bar: bool,
12 }
13
14 #[allow(deprecated)]
15 #[test]
16 fn deprecated_struct() {
17 test!(DeprecatedStruct)
18 .assert_snapshot()
19 .assert_allows_ser_roundtrip_default()
20 .custom(|schema, _| {
21 assert_eq!(
22 schema.as_value().pointer("/deprecated"),
23 Some(&Value::Bool(true)),
24 );
25 assert_eq!(
26 schema.as_value().pointer("/properties/bar/deprecated"),
27 Some(&Value::Bool(true)),
28 );
29 });
30 }
31
32 #[derive(JsonSchema, Default, Serialize, Deserialize)]
33 #[deprecated]
34 enum DeprecatedEnum {
35 #[default]
36 Unit,
37 #[deprecated]
38 DeprecatedUnitVariant,
39 #[deprecated]
40 DeprecatedStructVariant {
41 foo: i32,
42 #[deprecated]
43 deprecated_field: bool,
44 },
45 }
46
47 #[test]
48 fn deprecated_enum() {
49 test!(DeprecatedEnum)
50 .assert_snapshot()
51 .assert_allows_ser_roundtrip_default()
52 .custom(|schema, _| {
53 assert_eq!(
54 schema.as_value().pointer("/deprecated"),
55 Some(&Value::Bool(true)),
56 );
57 assert_eq!(
58 schema.as_value().pointer("/oneOf/1/deprecated"),
59 Some(&Value::Bool(true)),
60 );
61 assert_eq!(
62 schema.as_value().pointer("/oneOf/2/deprecated"),
63 Some(&Value::Bool(true)),
64 );
65 assert_eq!(
66 schema.as_value().pointer("/oneOf/2/properties/DeprecatedStructVariant/properties/deprecated_field/deprecated"),
67 Some(&Value::Bool(true)),
68 );
69 });
70 }