diff --git a/proxmox-api-macro/src/api/enums.rs b/proxmox-api-macro/src/api/enums.rs index 0cc22517..4ffb7a9a 100644 --- a/proxmox-api-macro/src/api/enums.rs +++ b/proxmox-api-macro/src/api/enums.rs @@ -9,7 +9,7 @@ use syn::punctuated::Punctuated; use syn::Token; use super::Schema; -use crate::util::{JSONObject, JSONValue, FieldName}; +use crate::util::{self, FieldName, JSONObject, JSONValue}; /// `parse_macro_input!` expects a TokenStream_1 struct AttrArgs { @@ -44,7 +44,13 @@ pub fn handle_enum( } let schema = { - let schema: Schema = attribs.try_into()?; + let mut schema: Schema = attribs.try_into()?; + + if schema.description.is_none() { + let (comment, span) = util::get_doc_comments(&enum_ty.attrs)?; + schema.description = Some(syn::LitStr::new(comment.trim(), span)); + } + let mut ts = TokenStream::new(); schema.to_typed_schema(&mut ts)?; ts diff --git a/proxmox-api-macro/tests/types.rs b/proxmox-api-macro/tests/types.rs index e6ceacf8..9400a331 100644 --- a/proxmox-api-macro/tests/types.rs +++ b/proxmox-api-macro/tests/types.rs @@ -23,8 +23,9 @@ impl OkString { .schema(); } -#[api(description: "A selection of either a, B or C")] +#[api] #[derive(Deserialize)] +/// A selection of either a, B or C pub enum Selection { #[serde(rename = "a")] A,