schemars 1.2.1

Generate JSON Schemas from Rust code
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use crate::prelude::*;

#[derive(Default, JsonSchema, Serialize)]
#[schemars(example = Struct::default(), example = ())]
struct Struct {
    #[schemars(example = 4 + 4, example = ())]
    foo: i32,
    bar: bool,
    #[schemars(example = (), example = &"foo")]
    baz: Option<&'static str>,
}

#[test]
fn examples() {
    test!(Struct).assert_snapshot();
}