You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#[derive(JsonSchema)]structHelper<T>{#[schemars(schema_with = "json_schema::<T>")]props:T,}fnjson_schema<T>(gen:&mut schemars::gen::SchemaGenerator) -> Schema{todo!()// will use `T::json_schema()` and possibly other things from `T`}
The error is:
275 | struct Helper<T> {
| - type parameter from outer item
276 | #[schemars(schema_with = "json_schema::<T>")]
| ^^^^^^^^^^^^^^^^^^- help: try introducing a local generic parameter here: `<T>`
| |
| use of generic parameter from outer item
However, equivalent serde annotation works with generics. For example, this compiles just fine:
Is it possible to use schema_with with a generic function? My use case is adding additional information to the schema generated by T::json_schema() of a generic T parameter in a struct.
The text was updated successfully, but these errors were encountered:
This fails to compile:
The error is:
However, equivalent serde annotation works with generics. For example, this compiles just fine:
Is it possible to use
schema_with
with a generic function? My use case is adding additional information to the schema generated byT::json_schema()
of a genericT
parameter in a struct.The text was updated successfully, but these errors were encountered: