Marwes / schemafy

Crate for generating rust types from a json schema
MIT License
242 stars 51 forks source link

Add `#[serde(deny_unknown_fields)]` when `additionalProperties` is false #56

Closed bgilbert closed 2 years ago

bgilbert commented 2 years ago

If a schema sets additionalProperties to false, it's asking us to reject structs with unknown fields. If it also doesn't define any patternProperties, the explicitly enumerated set of properties is exhaustive, so we can safely set #[serde(deny_unknown_fields)].

Marwes commented 2 years ago

Thanks!