Refactory of private functions

This commit is contained in:
Graham Esau 2021-04-15 13:34:04 +01:00
parent 5dc644000c
commit 55b860428e
8 changed files with 74 additions and 87 deletions

View file

@ -70,18 +70,12 @@ fn derive_json_schema(
<#ty as schemars::JsonSchema>::json_schema(gen)
}
fn json_schema_for_flatten(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema {
<#ty as schemars::JsonSchema>::json_schema_for_flatten(gen)
fn _schemars_private_non_optional_json_schema(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema {
<#ty as schemars::JsonSchema>::_schemars_private_non_optional_json_schema(gen)
}
fn add_schema_as_property(
gen: &mut schemars::gen::SchemaGenerator,
parent: &mut schemars::schema::SchemaObject,
name: String,
metadata: Option<schemars::schema::Metadata>,
required: bool,
) {
<#ty as schemars::JsonSchema>::add_schema_as_property(gen, parent, name, metadata, required)
fn _schemars_private_is_option() -> bool {
<#ty as schemars::JsonSchema>::_schemars_private_is_option()
}
};
};

View file

@ -49,7 +49,7 @@ impl<'a> SchemaMetadata<'a> {
quote! {
{
let schema = #schema_expr;
gen.apply_metadata(schema, #self)
schemars::_private::apply_metadata(schema, #self)
}
}
}

View file

@ -433,7 +433,7 @@ fn expr_for_struct(
let args = quote!(gen, &mut schema_object, #name.to_owned(), #metadata, #required);
quote_spanned! {ty.span()=>
<#ty as schemars::JsonSchema>::add_schema_as_property(#args);
schemars::_private::add_schema_as_property::<#ty>(#args);
}
})
.collect();
@ -448,7 +448,7 @@ fn expr_for_struct(
let gen = quote!(gen);
quote_spanned! {ty.span()=>
.flatten(<#ty as schemars::JsonSchema>::json_schema_for_flatten(#gen))
.flatten(schemars::_private::json_schema_for_flatten::<#ty>(#gen))
}
})
.collect();