Process validation attributes in tuple structs
This commit is contained in:
parent
31a5893d10
commit
9e507272da
3 changed files with 55 additions and 10 deletions
18
schemars/tests/expected/validate_tuple.json
Normal file
18
schemars/tests/expected/validate_tuple.json
Normal file
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "Tuple",
|
||||
"type": "array",
|
||||
"items": [
|
||||
{
|
||||
"type": "integer",
|
||||
"format": "uint8",
|
||||
"maximum": 10.0,
|
||||
"minimum": 0.0
|
||||
},
|
||||
{
|
||||
"type": "boolean"
|
||||
}
|
||||
],
|
||||
"maxItems": 2,
|
||||
"minItems": 2
|
||||
}
|
|
@ -47,6 +47,17 @@ fn validate() -> TestResult {
|
|||
test_default_generated_schema::<Struct>("validate")
|
||||
}
|
||||
|
||||
#[derive(Debug, JsonSchema)]
|
||||
pub struct Tuple(
|
||||
#[validate(range(max = 10))] u8,
|
||||
#[validate(required)] Option<bool>,
|
||||
);
|
||||
|
||||
#[test]
|
||||
fn validate_tuple() -> TestResult {
|
||||
test_default_generated_schema::<Tuple>("validate_tuple")
|
||||
}
|
||||
|
||||
#[derive(Debug, JsonSchema)]
|
||||
pub struct NewType(#[validate(range(max = 10))] u8);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue