feat: made unrecognized enum values default to a "Unsupported" value

This commit is contained in:
Bram Dingelstad 2024-11-17 14:28:31 +01:00
parent ec6c8c789a
commit cb2295e780

View file

@ -691,6 +691,9 @@ pub enum CodeLanguage {
YAML, YAML,
#[serde(rename = "java/c/c++/c#")] #[serde(rename = "java/c/c++/c#")]
JavaCCppCSharp, JavaCCppCSharp,
#[serde(other)]
Unsupported,
} }
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
@ -1200,10 +1203,21 @@ where
#[serde(tag = "type")] #[serde(tag = "type")]
#[serde(rename_all = "snake_case")] #[serde(rename_all = "snake_case")]
pub enum Formula { pub enum Formula {
Boolean { boolean: Option<bool> }, Boolean {
Date { date: Option<Date> }, boolean: Option<bool>,
Number { number: Option<f32> }, },
String { string: Option<String> }, Date {
date: Option<Date>,
},
Number {
number: Option<f32>,
},
String {
string: Option<String>,
},
#[serde(other)]
Unsupported,
} }
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
@ -1257,6 +1271,9 @@ pub enum RichText {
href: Option<String>, href: Option<String>,
annotations: Annotations, annotations: Annotations,
}, },
#[serde(other)]
Unsupported,
} }
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
@ -1269,11 +1286,24 @@ pub struct Text {
#[serde(tag = "type")] #[serde(tag = "type")]
#[serde(rename_all = "lowercase")] #[serde(rename_all = "lowercase")]
pub enum Mention { pub enum Mention {
Database { database: PartialDatabase }, Database {
Date { date: Date }, database: PartialDatabase,
LinkPreview { link_preview: LinkPreview }, },
Page { page: PartialPage }, Date {
User { user: PartialUser }, date: Date,
},
LinkPreview {
link_preview: LinkPreview,
},
Page {
page: PartialPage,
},
User {
user: PartialUser,
},
#[serde(other)]
Unsupported,
} }
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
@ -1399,33 +1429,60 @@ pub enum Color {
PurpleBackground, PurpleBackground,
PinkBackground, PinkBackground,
RedBackground, RedBackground,
#[serde(other)]
Unsupported,
} }
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
#[serde(tag = "type")] #[serde(tag = "type")]
#[serde(rename_all = "snake_case")] #[serde(rename_all = "snake_case")]
pub enum Parent { pub enum Parent {
PageId { page_id: String }, PageId {
DatabaseId { database_id: String }, page_id: String,
BlockId { block_id: String }, },
DatabaseId {
database_id: String,
},
BlockId {
block_id: String,
},
Workspace, Workspace,
#[serde(other)]
Unsupported,
} }
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
#[serde(tag = "type")] #[serde(tag = "type")]
#[serde(rename_all = "lowercase")] #[serde(rename_all = "lowercase")]
pub enum File { pub enum File {
File { file: NotionFile }, File {
External { external: ExternalFile }, file: NotionFile,
},
External {
external: ExternalFile,
},
#[serde(other)]
Unsupported,
} }
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
#[serde(tag = "type")] #[serde(tag = "type")]
#[serde(rename_all = "lowercase")] #[serde(rename_all = "lowercase")]
pub enum Icon { pub enum Icon {
Emoji { emoji: String }, Emoji {
File { file: NotionFile }, emoji: String,
External { external: ExternalFile }, },
File {
file: NotionFile,
},
External {
external: ExternalFile,
},
#[serde(other)]
Unsupported,
} }
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
@ -1446,4 +1503,7 @@ pub enum DatabaseFormulaType {
Date, Date,
Number, Number,
String, String,
#[serde(other)]
Unsupported,
} }