-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid emitting a #[schemars] annotation when one already exists
The #[schemars] annotation emitted by #[serde_as] will cause errors if the user has already added an existing #[schemars(with = ...)] annotation. This ends up being rather annoying since there's no way to work around the error other than to manually expand what #[serde_as] does. This commit fixes the issue by making #[serde_as] avoid emitting a schemars attribute if there is an existing one of the field that specifies any one of - #[schemars(with = "...")] - #[schemars(serialize_with = "...")] - #[schemars(deserialize_with = "...")] The actual code is a bit more involved (e.g. serialize_as doesn't conflict with #[schemars(deserialize_with = "...")]) but that's the gist of it. I have also included a test case to validate that this works as expected.
- Loading branch information
Showing
3 changed files
with
143 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters