api-macro: allow skipping input
schema
when there are no parameters Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
bead1e6b13
commit
263b943287
@ -274,6 +274,7 @@ impl SchemaItem {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
/// Contains a sorted list of properties:
|
||||
struct SchemaObject {
|
||||
properties: Vec<(String, bool, Schema)>,
|
||||
|
@ -16,10 +16,15 @@ use crate::util::{BareAssignment, JSONObject, SimpleIdent};
|
||||
///
|
||||
/// See the top level macro documentation for a complete example.
|
||||
pub fn handle_method(mut attribs: JSONObject, mut func: syn::ItemFn) -> Result<TokenStream, Error> {
|
||||
let mut input_schema: Schema = attribs
|
||||
.remove_required_element("input")?
|
||||
.into_object("input schema definition")?
|
||||
.try_into()?;
|
||||
let mut input_schema: Schema = match attribs.remove("input") {
|
||||
Some(input) => input.into_object("input schema definition")?.try_into()?,
|
||||
None => Schema {
|
||||
span: Span::call_site(),
|
||||
description: None,
|
||||
item: super::SchemaItem::Object(Default::default()),
|
||||
properties: Vec::new(),
|
||||
},
|
||||
};
|
||||
|
||||
let mut returns_schema: Option<Schema> = attribs
|
||||
.remove("returns")
|
||||
|
@ -101,13 +101,8 @@ pub fn some_call(verbose: bool) -> Result<(), Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[api(
|
||||
input: {
|
||||
properties: {}
|
||||
},
|
||||
)]
|
||||
#[api]
|
||||
/// Basic function
|
||||
pub fn basic_function() -> Result<(), Error> {
|
||||
let _ = verbose;
|
||||
Ok(())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user