Skip to content

Commit

Permalink
Add enum field to boolean types (#71)
Browse files Browse the repository at this point in the history
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?
  • Loading branch information
obmarg committed Oct 20, 2023
1 parent 6118b13 commit 9d7d07f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ pub enum Type {
Integer(IntegerType),
Object(ObjectType),
Array(ArrayType),
Boolean {},
Boolean(BooleanType),
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
Expand Down Expand Up @@ -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<Option<bool>>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "lowercase")]
pub enum NumberFormat {
Expand Down

0 comments on commit 9d7d07f

Please sign in to comment.