From 9d7d07fcaabd289c75a9b7161120c1a3b1d2ace5 Mon Sep 17 00:00:00 2001 From: Graeme Coupar Date: Fri, 20 Oct 2023 22:05:07 +0100 Subject: [PATCH] Add enum field to boolean types (#71) I'm using this library with the stripe API, and they've got a few places where they use the enum field on a boolean to indicate that a field will always be either true or false. This PR updates the types in this crate to support that. It's a small change, but still probably counts as a breaking change, so not sure how you want to handle that? --- src/schema.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/schema.rs b/src/schema.rs index 75995d3..8035935 100644 --- a/src/schema.rs +++ b/src/schema.rs @@ -68,7 +68,7 @@ pub enum Type { Integer(IntegerType), Object(ObjectType), Array(ArrayType), - Boolean {}, + Boolean(BooleanType), } #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] @@ -214,6 +214,13 @@ pub struct ArrayType { pub unique_items: bool, } +#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)] +#[serde(rename_all = "camelCase")] +pub struct BooleanType { + #[serde(rename = "enum", default, skip_serializing_if = "Vec::is_empty")] + pub enumeration: Vec>, +} + #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] #[serde(rename_all = "lowercase")] pub enum NumberFormat {