Fix "null" default not being set on schema (#296)

Fixes #295
This commit is contained in:
Graham Esau 2024-05-23 17:25:07 +01:00 committed by GitHub
parent 7ecaa7feab
commit a9a9c7e8ed
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 9 additions and 1 deletions

View file

@ -161,7 +161,7 @@ pub mod metadata {
add_metadata_fn!(add_deprecated, deprecated, bool);
add_metadata_fn!(add_read_only, read_only, bool);
add_metadata_fn!(add_write_only, write_only, bool);
add_metadata_fn!(add_default, default, Value);
add_metadata_fn!(add_default, default, Option<Value>);
pub fn add_examples<I: IntoIterator<Item = Value>>(schema: Schema, examples: I) -> Schema {
let mut schema_obj = schema.into_object();

View file

@ -30,6 +30,7 @@ where
struct MyStruct {
my_int: i32,
my_bool: bool,
my_optional_string: Option<String>,
#[serde(serialize_with = "custom_serialize")]
my_struct2: MyStruct2,
#[serde(

View file

@ -12,6 +12,13 @@
"default": false,
"type": "boolean"
},
"my_optional_string": {
"default": null,
"type": [
"string",
"null"
]
},
"my_struct2": {
"default": "i:0 b:false",
"allOf": [