Check for #[deprecated] attributes
This commit is contained in:
parent
bb8c93ddc1
commit
509a1c3b7b
7 changed files with 124 additions and 7 deletions
|
@ -7,6 +7,7 @@ use syn::Attribute;
|
|||
pub struct SchemaMetadata {
|
||||
pub title: Option<String>,
|
||||
pub description: Option<String>,
|
||||
pub deprecated: bool,
|
||||
pub read_only: bool,
|
||||
pub write_only: bool,
|
||||
pub default: Option<TokenStream>,
|
||||
|
@ -30,11 +31,13 @@ impl ToTokens for SchemaMetadata {
|
|||
}
|
||||
|
||||
impl SchemaMetadata {
|
||||
pub fn from_doc_attrs(attrs: &[Attribute]) -> SchemaMetadata {
|
||||
pub fn from_attrs(attrs: &[Attribute]) -> SchemaMetadata {
|
||||
let (title, description) = attr::get_title_and_desc_from_doc(attrs);
|
||||
let deprecated = attrs.iter().any(|a| a.path.is_ident("deprecated"));
|
||||
SchemaMetadata {
|
||||
title,
|
||||
description,
|
||||
deprecated,
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
@ -62,6 +65,12 @@ impl SchemaMetadata {
|
|||
});
|
||||
}
|
||||
|
||||
if self.deprecated {
|
||||
setters.push(quote! {
|
||||
metadata.deprecated = true;
|
||||
});
|
||||
}
|
||||
|
||||
if self.read_only {
|
||||
setters.push(quote! {
|
||||
metadata.read_only = true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue