Clarify generic type behaviour in with attribute

This commit is contained in:
Graham Esau 2019-12-27 16:12:46 +00:00
parent 781f40b061
commit be92d4da5f

View file

@ -117,6 +117,8 @@ Serde docs: [field](https://serde.rs/field-attrs.html#flatten)
Set on a field to generate this field's schema as the given type instead of the field's actual type. Serde allows the `with` attribute to refer to any module path, but Schemars requires this to be an actual type which implements `JsonSchema`. Set on a field to generate this field's schema as the given type instead of the field's actual type. Serde allows the `with` attribute to refer to any module path, but Schemars requires this to be an actual type which implements `JsonSchema`.
If the given type has any required generic type parameters, then they must all be explicitly specified in this attribute. Serde frequently allows you to omit them as it can make use of type inference, but unfortunately this is not possible with Schemars. For example, `with = "Vec::<i32>"` will work, but `with = "Vec"` and `with = "Vec::<_>"` will not.
Serde docs: [field](https://serde.rs/field-attrs.html#with) Serde docs: [field](https://serde.rs/field-attrs.html#with)
</div> </div>