From ca846972c144eb1aca23c3aacc738c6e856dd1bb Mon Sep 17 00:00:00 2001 From: Quaternions Date: Thu, 19 Dec 2024 17:48:58 -0800 Subject: [PATCH] submissions-api: openapi expects optional fields to be omitted The default serde configuration is to serialize optional values as "null" --- validation/api/src/types.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/validation/api/src/types.rs b/validation/api/src/types.rs index 8c0cb32..4f9369b 100644 --- a/validation/api/src/types.rs +++ b/validation/api/src/types.rs @@ -74,9 +74,13 @@ pub struct GetScriptRequest{ pub struct GetScriptsRequest<'a>{ pub Page:u32, pub Limit:u32, + #[serde(skip_serializing_if="Option::is_none")] pub Name:Option<&'a str>, + #[serde(skip_serializing_if="Option::is_none")] pub Hash:Option<&'a str>, + #[serde(skip_serializing_if="Option::is_none")] pub Source:Option<&'a str>, + #[serde(skip_serializing_if="Option::is_none")] pub SubmissionID:Option, } pub struct HashRequest<'a>{ @@ -96,6 +100,7 @@ pub struct ScriptResponse{ pub struct CreateScriptRequest<'a>{ pub Name:&'a str, pub Source:&'a str, + #[serde(skip_serializing_if="Option::is_none")] pub SubmissionID:Option, } #[allow(nonstandard_style)] @@ -119,8 +124,11 @@ pub enum Policy{ pub struct GetScriptPoliciesRequest<'a>{ pub Page:u32, pub Limit:u32, + #[serde(skip_serializing_if="Option::is_none")] pub FromScriptHash:Option<&'a str>, + #[serde(skip_serializing_if="Option::is_none")] pub ToScriptID:Option, + #[serde(skip_serializing_if="Option::is_none")] pub Policy:Option, } #[allow(nonstandard_style)] @@ -148,8 +156,11 @@ pub struct ScriptPolicyIDResponse{ #[derive(serde::Serialize)] pub struct UpdateScriptPolicyRequest{ pub ScriptPolicyID:ScriptPolicyID, + #[serde(skip_serializing_if="Option::is_none")] pub FromScriptID:Option, + #[serde(skip_serializing_if="Option::is_none")] pub ToScriptID:Option, + #[serde(skip_serializing_if="Option::is_none")] pub Policy:Option, }