From e3800fb85359d315ab9319e2b9a2a6dd7f3f50be Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Fri, 10 Jul 2020 11:03:51 +0200 Subject: [PATCH] api-macro: test using return schemas within return objects Signed-off-by: Wolfgang Bumiller --- proxmox-api-macro/tests/ext-schema.rs | 28 +++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/proxmox-api-macro/tests/ext-schema.rs b/proxmox-api-macro/tests/ext-schema.rs index a82768c8..e9f847db 100644 --- a/proxmox-api-macro/tests/ext-schema.rs +++ b/proxmox-api-macro/tests/ext-schema.rs @@ -103,3 +103,31 @@ fn get_data_schema_test() { assert_eq!(TEST_METHOD, API_METHOD_GET_DATA); } + +#[api( + returns: { + type: String, + } +)] +/// Get some text. +/// +/// Returns: some text. +pub fn get_some_text() -> Result { + Ok("Hello".to_string()) +} + +#[api( + returns: { + properties: { + "text": { + schema: API_RETURN_SCHEMA_GET_SOME_TEXT + }, + }, + }, +)] +/// Get some text data. +/// +/// Returns: data withsome text. +pub fn get_some_text_data() -> Result { + Ok(json!({ "text": get_some_text()? })) +}