-
-
Notifications
You must be signed in to change notification settings - Fork 240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support #[serde(skip_serializing_if = "path")] #26
Comments
My the field causing error looks like, #[schemars(with = "Option<String>")]
#[serde(
default,
with = "duration_utils::opt",
skip_serializing_if = "Option::is_none"
)]
pub duration: Option<StdDuration>, removing any of the serde attributes makes it OK. I don't get what is wrong. |
Yep that's definitely a bug in schemars, I'll try to get a fix out asap |
Previously whenever a field with a default value has both `skip_serializing_if` and `with`/`serialize_with` attributes, the value would be converted to a type that performs the custom serialization before checking if it should be serialized. This would cause the wrong type to be given to the skip_serializing_if function, causing a compile error. Issue #26
This should be fixed in v0.7.1 which is now on crates.io: https://crates.io/crates/schemars/0.7.1 @RagibHasin could you please re-test and let me know if it works for you? |
Thanks for that quick a reply! It solved the problem. I was taking a break for a while. So, sorry for my being late. |
Currently this causes an error like
mismatched types
expected reference
&std::option::Option<_>
found reference
&<task::Task as schemars::JsonSchema>::json_schema::_SchemarsDefaultSerialize<std::option::Option<std::time::Duration>>
I think it should mark that field as not required.
Thanks in advance.
The text was updated successfully, but these errors were encountered: