File: enum_repr.rs

package info (click to toggle)
rust-schemars 0.8.22-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,312 kB
  • sloc: makefile: 2
file content (16 lines) | stat: -rw-r--r-- 315 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#![cfg(feature = "derive")]
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());
}