Implement JsonSchema for nonzero signed ints
This commit is contained in:
parent
a35b469475
commit
50f00be97b
6 changed files with 92 additions and 2 deletions
33
schemars/tests/expected/nonzero_ints.json
Normal file
33
schemars/tests/expected/nonzero_ints.json
Normal file
|
@ -0,0 +1,33 @@
|
|||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "MyStruct",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"nonzero_signed",
|
||||
"nonzero_unsigned",
|
||||
"signed",
|
||||
"unsigned"
|
||||
],
|
||||
"properties": {
|
||||
"nonzero_signed": {
|
||||
"type": "integer",
|
||||
"format": "int32",
|
||||
"not": {
|
||||
"const": 0
|
||||
}
|
||||
},
|
||||
"nonzero_unsigned": {
|
||||
"type": "integer",
|
||||
"format": "uint32",
|
||||
"minimum": 1.0
|
||||
},
|
||||
"signed": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
},
|
||||
"unsigned": {
|
||||
"type": "integer",
|
||||
"format": "uint32"
|
||||
}
|
||||
}
|
||||
}
|
21
schemars/tests/nonzero_ints.rs
Normal file
21
schemars/tests/nonzero_ints.rs
Normal file
|
@ -0,0 +1,21 @@
|
|||
mod util;
|
||||
|
||||
#[cfg(num_nonzero_signed)]
|
||||
mod nonzero_ints {
|
||||
use super::*;
|
||||
use schemars::JsonSchema;
|
||||
use util::*;
|
||||
|
||||
#[derive(Debug, JsonSchema)]
|
||||
struct MyStruct {
|
||||
unsigned: u32,
|
||||
nonzero_unsigned: std::num::NonZeroU32,
|
||||
signed: i32,
|
||||
nonzero_signed: std::num::NonZeroI32,
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn nonzero_ints() -> TestResult {
|
||||
test_default_generated_schema::<MyStruct>("nonzero_ints")
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue