Allow non-Serialize default values.
Default values that don't implement Serialize are now ignored, rather than causing a compile error.
This is done by simulating specialization using a technique copied from Rocket:
5ebefa97c9/core/lib/src/sentinel.rs (L391-L445)
Fixes #115
This commit is contained in:
parent
6f39a13724
commit
690fe44343
4 changed files with 46 additions and 4 deletions
|
@ -68,7 +68,7 @@ impl<'a> SchemaMetadata<'a> {
|
|||
|
||||
if let Some(default) = &self.default {
|
||||
setters.push(quote! {
|
||||
default: #default.and_then(|d| schemars::_serde_json::value::to_value(d).ok()),
|
||||
default: #default.and_then(|d| schemars::_schemars_maybe_to_value!(d)),
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue