Add schema_id(), handles different types with the same name (#247)

This commit is contained in:
Graham Esau 2023-09-17 20:36:52 +01:00 committed by GitHub
parent 53bb51cb25
commit 342b2dff33
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 415 additions and 34 deletions

View file

@ -109,6 +109,15 @@ fn type_for_schema(with_attr: &WithAttr) -> (syn::Type, Option<TokenStream>) {
#fn_name.to_string()
}
fn schema_id() -> std::borrow::Cow<'static, str> {
std::borrow::Cow::Borrowed(std::concat!(
"_SchemarsSchemaWithFunction/",
std::module_path!(),
"/",
#fn_name
))
}
fn json_schema(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema {
#fun(gen)
}