forked from jonasbb/serde_with
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for emitting #[schemars(...)] attributes to #[serde_as]
This commit adds support for emitting #[schemars(with = "::serde_with::Schema<T, ...>")] field annotations when any of the following are true: - there is a #[derive(JsonSchema)] attribute, or, - the user explicitly requests it via #[serde_as(schemars)] This requires a bunch of extra work to properly scan for a few different possible paths to JsonSchema (see the added docs for details) and also to properly handle the case where the derive is within a #[cfg_attr]. eg #[cfg_attr(feature = "blah", derive(schemars::JsonSchema))] While rustc will evaluate the cfgs for attributes declared by derive macros unfortunately it does not do the same for attribute macros so we need to do it ourselves. The code here started from jonasbb#623 as a base and all changes have been made on top of that. Co-Authored-By: Jonas Bushart <[email protected]>
- Loading branch information
Showing
3 changed files
with
168 additions
and
4 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