Skip to content
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

#[serde_as(deserialize_as = …)] generates #[schemars(deserialize_with(…))], which is invalid #735

Closed
sivizius opened this issue Apr 26, 2024 · 1 comment · Fixed by #736

Comments

@sivizius
Copy link
Contributor

Due to https://github.com/jonasbb/serde_with/blob/master/serde_with_macros/src/lib.rs#L814, a #[serde_as(deserialize_as = …)] will generate #[schemars(deserialize_with(…))] if feature schemars_0_8 is enabled, but https://github.com/GREsau/schemars/blob/master/schemars_derive/src/attr/schemars_to_serde.rs#L8-L31 does not contain deserialize_with, only serialize_with. Generation of #[schemars(deserialize_with(…))] thus results in an compiler error. I suggest to use #[schemars(schema_with = "…")].

The error I get looks like this:

error: unknown schemars attribute `deserialize_with`
  --> cherub/src/foo/bar.rs:23:1
   |
23 | #[serde_as]
jonasbb added a commit that referenced this issue Apr 28, 2024
This is not supported by the schemars macro.

Closes #735
jonasbb added a commit that referenced this issue Apr 28, 2024
This is not supported by the schemars macro.

Closes #735
jonasbb added a commit that referenced this issue Apr 28, 2024
This is not supported by the schemars macro.

Closes #735
@jonasbb
Copy link
Owner

jonasbb commented Apr 28, 2024

Thanks for finding this problem. Indeed, deserialize_with for schemars is not supported. It seems that serialize_with is only "supported" in that it doesn't cause compilation failures, but it won't change the generated schema. The problem is fixed in v3.8.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants