schemars 1.0.3

Generate JSON Schemas from Rust code
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use schemars::{schema_for, JsonSchema_repr};

#[derive(JsonSchema_repr)]
#[repr(u8)]
enum SmallPrime {
    Two = 2,
    Three = 3,
    Five = 5,
    Seven = 7,
}

fn main() {
    let schema = schema_for!(SmallPrime);
    println!("{}", serde_json::to_string_pretty(&schema).unwrap());
}