Derive JsonSchema_repr (#76)

This commit is contained in:
Graham Esau 2021-03-25 22:36:28 +00:00 committed by GitHub
parent 7de2b2276f
commit 11d95b79e5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 225 additions and 18 deletions

View file

@ -18,6 +18,7 @@ pub struct Attrs {
pub description: Option<String>,
pub deprecated: bool,
pub examples: Vec<syn::Path>,
pub repr: Option<syn::Type>,
}
#[derive(Debug)]
@ -33,6 +34,10 @@ impl Attrs {
.populate(attrs, "serde", true, errors);
result.deprecated = attrs.iter().any(|a| a.path.is_ident("deprecated"));
result.repr = attrs
.iter()
.find(|a| a.path.is_ident("repr"))
.and_then(|a| a.parse_args().ok());
let (doc_title, doc_description) = doc::get_title_and_desc_from_doc(attrs);
result.title = result.title.or(doc_title);