additionalProperties: false
for struct annotated with serde deny_unknown_fields
(#30)
Co-authored-by: Denis Kurilov <denis@routinghub.com>
This commit is contained in:
parent
ea351f3b42
commit
1190b1fad9
4 changed files with 53 additions and 2 deletions
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "Struct",
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"bar",
|
||||
"foo"
|
||||
],
|
||||
"properties": {
|
||||
"bar": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"baz": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"foo": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
}
|
||||
}
|
||||
}
|
16
schemars/tests/struct_additional_properties.rs
Normal file
16
schemars/tests/struct_additional_properties.rs
Normal file
|
@ -0,0 +1,16 @@
|
|||
mod util;
|
||||
use schemars::JsonSchema;
|
||||
use util::*;
|
||||
|
||||
#[derive(Debug, JsonSchema)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct Struct {
|
||||
foo: i32,
|
||||
bar: bool,
|
||||
baz: Option<String>,
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn struct_normal_additional_properties() -> TestResult {
|
||||
test_default_generated_schema::<Struct>("struct-normal-additional-properties")
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue