From ba3ee7a4db55e5a122ab9afdeefccc59d87ef079 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Tue, 22 Oct 2024 15:14:42 +0200 Subject: [PATCH] api-marcro: throw compiler error if description for enums is empty A description is required for the API schema types and we fallback to the rust doc-comment when no explicit one is set. But a empty string was returned if no doc-comment existed, so check for the comment to be non-empty and throw a compile-time error otherwise. Signed-off-by: Thomas Lamprecht --- proxmox-api-macro/src/api/enums.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/proxmox-api-macro/src/api/enums.rs b/proxmox-api-macro/src/api/enums.rs index cb72ec84..7257c51e 100644 --- a/proxmox-api-macro/src/api/enums.rs +++ b/proxmox-api-macro/src/api/enums.rs @@ -74,6 +74,12 @@ fn handle_string_enum( if schema.description.is_none() { let (comment, span) = util::get_doc_comments(&enum_ty.attrs)?; + if comment.is_empty() { + error!( + Span::call_site(), + "missing doc comment on enum for api-schema description" + ); + } schema.description = Maybe::Derived(syn::LitStr::new(comment.trim(), span)); }