diff --git a/Cargo.lock b/Cargo.lock index ebed0a47..4da895cb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -961,7 +961,7 @@ dependencies = [ [[package]] name = "kittycad" -version = "0.2.66" +version = "0.2.67" dependencies = [ "anyhow", "async-trait", diff --git a/VERSION.txt b/VERSION.txt index 69d48bba..9fd6a773 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -0.2.66 +0.2.67 diff --git a/kittycad.rs.patch.json b/kittycad.rs.patch.json index 7a04f1fd..a36eb03a 100644 --- a/kittycad.rs.patch.json +++ b/kittycad.rs.patch.json @@ -4,7 +4,7 @@ "path": "/info/x-rust", "value": { "client": "// Authenticate via an API token.\nlet client = kittycad::Client::new(\"$TOKEN\");\n\n// - OR -\n\n// Authenticate with your token and host parsed from the environment variables:\n// `KITTYCAD_API_TOKEN`.\nlet client = kittycad::Client::new_from_env();", - "install": "[dependencies]\nkittycad = \"0.2.66\"" + "install": "[dependencies]\nkittycad = \"0.2.67\"" } }, { @@ -51,7 +51,7 @@ "op": "add", "path": "/paths/~1ai~1kcl~1completions/post/x-rust", "value": { - "example": "/// Generate code completions for KCL.\nasync fn example_ai_create_kcl_code_completions() -> anyhow::Result<()> {\n let client = kittycad::Client::new_from_env();\n let result: kittycad::types::KclCodeCompletionResponse = client\n .ai()\n .create_kcl_code_completions(&kittycad::types::KclCodeCompletionRequest {\n extra: Some(kittycad::types::KclCodeCompletionParams {\n language: Some(\"some-string\".to_string()),\n next_indent: Some(4 as u8),\n prompt_tokens: Some(4 as u32),\n suffix_tokens: Some(4 as u32),\n trim_by_indentation: Some(false),\n }),\n max_tokens: Some(4 as u16),\n n: Some(4 as u8),\n nwo: Some(\"some-string\".to_string()),\n prompt: Some(\"some-string\".to_string()),\n stop: Some(vec![\"some-string\".to_string()]),\n stream: Some(false),\n suffix: Some(\"some-string\".to_string()),\n temperature: Some(3.14 as f64),\n top_p: Some(3.14 as f64),\n })\n .await?;\n println!(\"{:?}\", result);\n Ok(())\n}\n", + "example": "/// Generate code completions for KCL.\nasync fn example_ai_create_kcl_code_completions() -> anyhow::Result<()> {\n let client = kittycad::Client::new_from_env();\n let result: kittycad::types::KclCodeCompletionResponse = client\n .ai()\n .create_kcl_code_completions(&kittycad::types::KclCodeCompletionRequest {\n extra: Some(kittycad::types::KclCodeCompletionParams {\n language: Some(\"some-string\".to_string()),\n next_indent: Some(4 as u8),\n prompt_tokens: Some(4 as u32),\n suffix_tokens: Some(4 as u32),\n trim_by_indentation: false,\n }),\n max_tokens: Some(4 as u16),\n n: Some(4 as u8),\n nwo: Some(\"some-string\".to_string()),\n prompt: Some(\"some-string\".to_string()),\n stop: Some(vec![\"some-string\".to_string()]),\n stream: false,\n suffix: Some(\"some-string\".to_string()),\n temperature: Some(3.14 as f64),\n top_p: Some(3.14 as f64),\n })\n .await?;\n println!(\"{:?}\", result);\n Ok(())\n}\n", "libDocsLink": "https://docs.rs/kittycad/latest/kittycad/ai/struct.Ai.html#method.create_kcl_code_completions" } }, diff --git a/kittycad/Cargo.toml b/kittycad/Cargo.toml index f5d0efb3..86015019 100644 --- a/kittycad/Cargo.toml +++ b/kittycad/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "kittycad" description = "A fully generated & opinionated API client for the KittyCAD API." -version = "0.2.66" +version = "0.2.67" documentation = "https://docs.rs/kittycad" readme = "README.md" repository = "https://github.com/KittyCAD/kittycad.rs/tree/main/kittycad" diff --git a/kittycad/README.md b/kittycad/README.md index 9b80e75b..dd61ff00 100644 --- a/kittycad/README.md +++ b/kittycad/README.md @@ -31,7 +31,7 @@ To install the library, add the following to your `Cargo.toml` file. ```toml [dependencies] -kittycad = "0.2.66" +kittycad = "0.2.67" ``` ## Basic example diff --git a/kittycad/src/ai.rs b/kittycad/src/ai.rs index 16acc55e..c9cfdbf2 100644 --- a/kittycad/src/ai.rs +++ b/kittycad/src/ai.rs @@ -170,7 +170,7 @@ impl Ai { } } - #[doc = "Generate code completions for KCL.\n\n```rust,no_run\nasync fn example_ai_create_kcl_code_completions() -> anyhow::Result<()> {\n let client = kittycad::Client::new_from_env();\n let result: kittycad::types::KclCodeCompletionResponse = client\n .ai()\n .create_kcl_code_completions(&kittycad::types::KclCodeCompletionRequest {\n extra: Some(kittycad::types::KclCodeCompletionParams {\n language: Some(\"some-string\".to_string()),\n next_indent: Some(4 as u8),\n prompt_tokens: Some(4 as u32),\n suffix_tokens: Some(4 as u32),\n trim_by_indentation: Some(false),\n }),\n max_tokens: Some(4 as u16),\n n: Some(4 as u8),\n nwo: Some(\"some-string\".to_string()),\n prompt: Some(\"some-string\".to_string()),\n stop: Some(vec![\"some-string\".to_string()]),\n stream: Some(false),\n suffix: Some(\"some-string\".to_string()),\n temperature: Some(3.14 as f64),\n top_p: Some(3.14 as f64),\n })\n .await?;\n println!(\"{:?}\", result);\n Ok(())\n}\n```"] + #[doc = "Generate code completions for KCL.\n\n```rust,no_run\nasync fn example_ai_create_kcl_code_completions() -> anyhow::Result<()> {\n let client = kittycad::Client::new_from_env();\n let result: kittycad::types::KclCodeCompletionResponse = client\n .ai()\n .create_kcl_code_completions(&kittycad::types::KclCodeCompletionRequest {\n extra: Some(kittycad::types::KclCodeCompletionParams {\n language: Some(\"some-string\".to_string()),\n next_indent: Some(4 as u8),\n prompt_tokens: Some(4 as u32),\n suffix_tokens: Some(4 as u32),\n trim_by_indentation: false,\n }),\n max_tokens: Some(4 as u16),\n n: Some(4 as u8),\n nwo: Some(\"some-string\".to_string()),\n prompt: Some(\"some-string\".to_string()),\n stop: Some(vec![\"some-string\".to_string()]),\n stream: false,\n suffix: Some(\"some-string\".to_string()),\n temperature: Some(3.14 as f64),\n top_p: Some(3.14 as f64),\n })\n .await?;\n println!(\"{:?}\", result);\n Ok(())\n}\n```"] #[tracing::instrument] pub async fn create_kcl_code_completions<'a>( &'a self, diff --git a/kittycad/src/lib.rs b/kittycad/src/lib.rs index 1a7d038c..c04ca2d2 100644 --- a/kittycad/src/lib.rs +++ b/kittycad/src/lib.rs @@ -29,7 +29,7 @@ //! //! ```toml //! [dependencies] -//! kittycad = "0.2.66" +//! kittycad = "0.2.67" //! ``` //! //! ## Basic example diff --git a/kittycad/src/types.rs b/kittycad/src/types.rs index d556de1a..d4914c47 100644 --- a/kittycad/src/types.rs +++ b/kittycad/src/types.rs @@ -3487,8 +3487,8 @@ pub struct Coupon { #[serde(default, skip_serializing_if = "Option::is_none")] pub amount_off: Option, #[doc = "Always true for a deleted object."] - #[serde(default, skip_serializing_if = "Option::is_none")] - pub deleted: Option, + #[serde(default)] + pub deleted: bool, #[doc = "Unique identifier for the object."] #[serde(default, skip_serializing_if = "Option::is_none")] pub id: Option, @@ -3526,11 +3526,7 @@ impl tabled::Tabled for Coupon { } else { String::new().into() }, - if let Some(deleted) = &self.deleted { - format!("{:?}", deleted).into() - } else { - String::new().into() - }, + format!("{:?}", self.deleted).into(), if let Some(id) = &self.id { format!("{:?}", id).into() } else { @@ -3743,8 +3739,8 @@ pub struct Customer { invoice is billed by sending an invoice, `delinquent` is `true` if the invoice isn't \ paid by its due date. If an invoice is marked uncollectible by dunning, \ `delinquent` doesn't get reset to `false`."] - #[serde(default, skip_serializing_if = "Option::is_none")] - pub delinquent: Option, + #[serde(default)] + pub delinquent: bool, #[doc = "The customer's email address."] #[serde(default, skip_serializing_if = "Option::is_none")] pub email: Option, @@ -3793,11 +3789,7 @@ impl tabled::Tabled for Customer { } else { String::new().into() }, - if let Some(delinquent) = &self.delinquent { - format!("{:?}", delinquent).into() - } else { - String::new().into() - }, + format!("{:?}", self.delinquent).into(), if let Some(email) = &self.email { format!("{:?}", email).into() } else { @@ -4951,8 +4943,8 @@ pub struct ExtendedUser { pub block: Option, #[doc = "If we can train on the user's data. If the user is a member of an organization, the \ organization's setting will override this."] - #[serde(default, skip_serializing_if = "Option::is_none")] - pub can_train_on_data: Option, + #[serde(default)] + pub can_train_on_data: bool, #[doc = "The user's company."] #[serde(default, skip_serializing_if = "Option::is_none")] pub company: Option, @@ -4981,8 +4973,8 @@ pub struct ExtendedUser { #[doc = "The image avatar for the user. This is a URL."] pub image: String, #[doc = "If the user is tied to a service account."] - #[serde(default, skip_serializing_if = "Option::is_none")] - pub is_service_account: Option, + #[serde(default)] + pub is_service_account: bool, #[doc = "The user's last name."] #[serde(default, skip_serializing_if = "Option::is_none")] pub last_name: Option, @@ -5024,11 +5016,7 @@ impl tabled::Tabled for ExtendedUser { } else { String::new().into() }, - if let Some(can_train_on_data) = &self.can_train_on_data { - format!("{:?}", can_train_on_data).into() - } else { - String::new().into() - }, + format!("{:?}", self.can_train_on_data).into(), if let Some(company) = &self.company { format!("{:?}", company).into() } else { @@ -5067,11 +5055,7 @@ impl tabled::Tabled for ExtendedUser { }, format!("{:?}", self.id).into(), self.image.clone().into(), - if let Some(is_service_account) = &self.is_service_account { - format!("{:?}", is_service_account).into() - } else { - String::new().into() - }, + format!("{:?}", self.is_service_account).into(), if let Some(last_name) = &self.last_name { format!("{:?}", last_name).into() } else { @@ -6818,8 +6802,8 @@ pub struct Invoice { #[doc = "Whether an attempt has been made to pay the invoice.\n\nAn invoice is not attempted \ until 1 hour after the `invoice.created` webhook, for example, so you might not want \ to display that invoice as unpaid to your users."] - #[serde(default, skip_serializing_if = "Option::is_none")] - pub attempted: Option, + #[serde(default)] + pub attempted: bool, #[doc = "Time at which the object was created."] pub created_at: chrono::DateTime, #[doc = "Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), \ @@ -6861,8 +6845,8 @@ pub struct Invoice { #[doc = "Whether payment was successfully collected for this invoice.\n\nAn invoice can be \ paid (most commonly) with a charge or with credit from the customer's account \ balance."] - #[serde(default, skip_serializing_if = "Option::is_none")] - pub paid: Option, + #[serde(default)] + pub paid: bool, #[doc = "The link to download the PDF for the invoice."] #[serde(default, skip_serializing_if = "Option::is_none")] pub pdf: Option, @@ -6928,11 +6912,7 @@ impl tabled::Tabled for Invoice { } else { String::new().into() }, - if let Some(attempted) = &self.attempted { - format!("{:?}", attempted).into() - } else { - String::new().into() - }, + format!("{:?}", self.attempted).into(), format!("{:?}", self.created_at).into(), if let Some(currency) = &self.currency { format!("{:?}", currency).into() @@ -6984,11 +6964,7 @@ impl tabled::Tabled for Invoice { } else { String::new().into() }, - if let Some(paid) = &self.paid { - format!("{:?}", paid).into() - } else { - String::new().into() - }, + format!("{:?}", self.paid).into(), if let Some(pdf) = &self.pdf { format!("{:?}", pdf).into() } else { @@ -7652,8 +7628,8 @@ pub struct KclCodeCompletionParams { #[serde(default, skip_serializing_if = "Option::is_none")] pub suffix_tokens: Option, #[doc = "If we should trim by indentation."] - #[serde(default, skip_serializing_if = "Option::is_none")] - pub trim_by_indentation: Option, + #[serde(default)] + pub trim_by_indentation: bool, } impl std::fmt::Display for KclCodeCompletionParams { @@ -7691,11 +7667,7 @@ impl tabled::Tabled for KclCodeCompletionParams { } else { String::new().into() }, - if let Some(trim_by_indentation) = &self.trim_by_indentation { - format!("{:?}", trim_by_indentation).into() - } else { - String::new().into() - }, + format!("{:?}", self.trim_by_indentation).into(), ] } @@ -7738,8 +7710,8 @@ pub struct KclCodeCompletionRequest { #[doc = "If set, partial message deltas will be sent, like in ChatGPT or OpenAPI. Tokens will \ be sent as data-only server-sent events as they become available, with the stream \ terminated by a data: [DONE] message."] - #[serde(default, skip_serializing_if = "Option::is_none")] - pub stream: Option, + #[serde(default)] + pub stream: bool, #[doc = "The suffix for the model."] #[serde(default, skip_serializing_if = "Option::is_none")] pub suffix: Option, @@ -7796,11 +7768,7 @@ impl tabled::Tabled for KclCodeCompletionRequest { } else { String::new().into() }, - if let Some(stream) = &self.stream { - format!("{:?}", stream).into() - } else { - String::new().into() - }, + format!("{:?}", self.stream).into(), if let Some(suffix) = &self.suffix { format!("{:?}", suffix).into() } else { @@ -9719,8 +9687,8 @@ pub struct Org { pub block: Option, #[doc = "If we can train on the orgs's data. This value overrides any individual user's \ `can_train_on_data` value if they are a member of the org."] - #[serde(default, skip_serializing_if = "Option::is_none")] - pub can_train_on_data: Option, + #[serde(default)] + pub can_train_on_data: bool, #[doc = "The date and time the org was created."] pub created_at: chrono::DateTime, #[doc = "The org's domain."] @@ -9781,11 +9749,7 @@ impl tabled::Tabled for Org { } else { String::new().into() }, - if let Some(can_train_on_data) = &self.can_train_on_data { - format!("{:?}", can_train_on_data).into() - } else { - String::new().into() - }, + format!("{:?}", self.can_train_on_data).into(), format!("{:?}", self.created_at).into(), if let Some(domain) = &self.domain { format!("{:?}", domain).into() @@ -14682,8 +14646,8 @@ pub struct User { pub block: Option, #[doc = "If we can train on the user's data. If the user is a member of an organization, the \ organization's setting will override this."] - #[serde(default, skip_serializing_if = "Option::is_none")] - pub can_train_on_data: Option, + #[serde(default)] + pub can_train_on_data: bool, #[doc = "The user's company."] #[serde(default, skip_serializing_if = "Option::is_none")] pub company: Option, @@ -14709,8 +14673,8 @@ pub struct User { #[doc = "The image avatar for the user. This is a URL."] pub image: String, #[doc = "If the user is tied to a service account."] - #[serde(default, skip_serializing_if = "Option::is_none")] - pub is_service_account: Option, + #[serde(default)] + pub is_service_account: bool, #[doc = "The user's last name."] #[serde(default, skip_serializing_if = "Option::is_none")] pub last_name: Option, @@ -14746,11 +14710,7 @@ impl tabled::Tabled for User { } else { String::new().into() }, - if let Some(can_train_on_data) = &self.can_train_on_data { - format!("{:?}", can_train_on_data).into() - } else { - String::new().into() - }, + format!("{:?}", self.can_train_on_data).into(), if let Some(company) = &self.company { format!("{:?}", company).into() } else { @@ -14784,11 +14744,7 @@ impl tabled::Tabled for User { }, format!("{:?}", self.id).into(), self.image.clone().into(), - if let Some(is_service_account) = &self.is_service_account { - format!("{:?}", is_service_account).into() - } else { - String::new().into() - }, + format!("{:?}", self.is_service_account).into(), if let Some(last_name) = &self.last_name { format!("{:?}", last_name).into() } else { diff --git a/openapitor/src/types/example.rs b/openapitor/src/types/example.rs index e3f3a7aa..b577ab53 100644 --- a/openapitor/src/types/example.rs +++ b/openapitor/src/types/example.rs @@ -505,6 +505,12 @@ pub fn generate_example_rust_from_schema( let inner_name_rendered = inner_name.strip_option()?.rendered()?; let inner_schema = v.get_schema_from_reference(&type_space.spec, true)?; + let type_name = crate::types::get_type_name_for_schema( + &k, + &inner_schema, + &type_space.spec, + true, + )?; let example = generate_example_rust_from_schema( type_space, @@ -517,6 +523,9 @@ pub fn generate_example_rust_from_schema( // Check if this type is required. if !o.required.contains(k) + && !type_space + .clone() + .is_default_property(&type_name, &inner_schema.schema_data)? && !example .rendered()? .starts_with("crate::types::phone_number::PhoneNumber") diff --git a/openapitor/src/types/mod.rs b/openapitor/src/types/mod.rs index 0b930f52..5a09ec1e 100644 --- a/openapitor/src/types/mod.rs +++ b/openapitor/src/types/mod.rs @@ -702,13 +702,13 @@ impl TypeSpace { // Get the type name for the schema. let type_name = get_type_name_for_schema(&prop, &inner_schema, &self.spec, true)?; // Check if this type is required. - if o.required.contains(k) && type_name.is_string()? { + let required = o.required.contains(k) + || self.is_default_property(&type_name, &inner_schema.schema_data)?; + if required && type_name.is_string()? { fields.push(quote!( self.#prop_ident.clone().into() )); - } else if !o.required.contains(k) - && type_name.rendered()? != "phone_number::PhoneNumber" - { + } else if !required && type_name.rendered()? != "phone_number::PhoneNumber" { fields.push(quote!( if let Some(#prop_ident) = &self.#prop_ident { format!("{:?}", #prop_ident).into() @@ -851,7 +851,9 @@ impl TypeSpace { }; // Check if this type is required. - if !o.required.contains(k) && !type_name.is_option()? { + let required = o.required.contains(k) + || self.is_default_property(&type_name, &inner_schema.schema_data)?; + if !required && !type_name.is_option()? { // Make the type optional. type_name = quote!(Option<#type_name>); } @@ -879,6 +881,12 @@ impl TypeSpace { serde_props.push(quote!(default)); serde_props.push(quote!(skip_serializing_if = "Option::is_none")); } + if !o.required.contains(k) + && self.is_default_property(&type_name, &inner_schema.schema_data)? + && !type_name.is_option()? + { + serde_props.push(quote!(default)); + } if type_name.rendered()? == "Vec" { serde_props.push(quote!( @@ -936,6 +944,14 @@ impl TypeSpace { Ok(values) } + fn is_default_property( + &mut self, + type_name: &proc_macro2::TokenStream, + data: &openapiv3::SchemaData, + ) -> Result { + Ok(data.default.is_some() && type_name.rendered()? == "bool") + } + /// Render a string type. fn render_string_type( &mut self, diff --git a/openapitor/tests/types/kittycad.rs.gen b/openapitor/tests/types/kittycad.rs.gen index e5bcf360..8378beb7 100644 --- a/openapitor/tests/types/kittycad.rs.gen +++ b/openapitor/tests/types/kittycad.rs.gen @@ -3447,8 +3447,8 @@ pub struct Coupon { #[serde(default, skip_serializing_if = "Option::is_none")] pub amount_off: Option, #[doc = "Always true for a deleted object."] - #[serde(default, skip_serializing_if = "Option::is_none")] - pub deleted: Option, + #[serde(default)] + pub deleted: bool, #[doc = "Unique identifier for the object."] #[serde(default, skip_serializing_if = "Option::is_none")] pub id: Option, @@ -3483,11 +3483,7 @@ impl tabled::Tabled for Coupon { } else { String::new().into() }, - if let Some(deleted) = &self.deleted { - format!("{:?}", deleted).into() - } else { - String::new().into() - }, + format!("{:?}", self.deleted).into(), if let Some(id) = &self.id { format!("{:?}", id).into() } else { @@ -3689,8 +3685,8 @@ pub struct Customer { #[serde(default, skip_serializing_if = "Option::is_none")] pub currency: Option, #[doc = "When the customer's latest invoice is billed by charging automatically, `delinquent` is `true` if the invoice's latest charge failed.\n\nWhen the customer's latest invoice is billed by sending an invoice, `delinquent` is `true` if the invoice isn't paid by its due date. If an invoice is marked uncollectible by dunning, `delinquent` doesn't get reset to `false`."] - #[serde(default, skip_serializing_if = "Option::is_none")] - pub delinquent: Option, + #[serde(default)] + pub delinquent: bool, #[doc = "The customer's email address."] #[serde(default, skip_serializing_if = "Option::is_none")] pub email: Option, @@ -3739,11 +3735,7 @@ impl tabled::Tabled for Customer { } else { String::new().into() }, - if let Some(delinquent) = &self.delinquent { - format!("{:?}", delinquent).into() - } else { - String::new().into() - }, + format!("{:?}", self.delinquent).into(), if let Some(email) = &self.email { format!("{:?}", email).into() } else { @@ -4875,8 +4867,8 @@ pub struct ExtendedUser { #[serde(default, skip_serializing_if = "Option::is_none")] pub block: Option, #[doc = "If we can train on the user's data. If the user is a member of an organization, the organization's setting will override this."] - #[serde(default, skip_serializing_if = "Option::is_none")] - pub can_train_on_data: Option, + #[serde(default)] + pub can_train_on_data: bool, #[doc = "The user's company."] #[serde(default, skip_serializing_if = "Option::is_none")] pub company: Option, @@ -4905,8 +4897,8 @@ pub struct ExtendedUser { #[doc = "The image avatar for the user. This is a URL."] pub image: String, #[doc = "If the user is tied to a service account."] - #[serde(default, skip_serializing_if = "Option::is_none")] - pub is_service_account: Option, + #[serde(default)] + pub is_service_account: bool, #[doc = "The user's last name."] #[serde(default, skip_serializing_if = "Option::is_none")] pub last_name: Option, @@ -4946,11 +4938,7 @@ impl tabled::Tabled for ExtendedUser { } else { String::new().into() }, - if let Some(can_train_on_data) = &self.can_train_on_data { - format!("{:?}", can_train_on_data).into() - } else { - String::new().into() - }, + format!("{:?}", self.can_train_on_data).into(), if let Some(company) = &self.company { format!("{:?}", company).into() } else { @@ -4989,11 +4977,7 @@ impl tabled::Tabled for ExtendedUser { }, format!("{:?}", self.id).into(), self.image.clone().into(), - if let Some(is_service_account) = &self.is_service_account { - format!("{:?}", is_service_account).into() - } else { - String::new().into() - }, + format!("{:?}", self.is_service_account).into(), if let Some(last_name) = &self.last_name { format!("{:?}", last_name).into() } else { @@ -6704,8 +6688,8 @@ pub struct Invoice { #[serde(default, skip_serializing_if = "Option::is_none")] pub attempt_count: Option, #[doc = "Whether an attempt has been made to pay the invoice.\n\nAn invoice is not attempted until 1 hour after the `invoice.created` webhook, for example, so you might not want to display that invoice as unpaid to your users."] - #[serde(default, skip_serializing_if = "Option::is_none")] - pub attempted: Option, + #[serde(default)] + pub attempted: bool, #[doc = "Time at which the object was created."] pub created_at: chrono::DateTime, #[doc = "Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase."] @@ -6739,8 +6723,8 @@ pub struct Invoice { #[serde(default, skip_serializing_if = "Option::is_none")] pub number: Option, #[doc = "Whether payment was successfully collected for this invoice.\n\nAn invoice can be paid (most commonly) with a charge or with credit from the customer's account balance."] - #[serde(default, skip_serializing_if = "Option::is_none")] - pub paid: Option, + #[serde(default)] + pub paid: bool, #[doc = "The link to download the PDF for the invoice."] #[serde(default, skip_serializing_if = "Option::is_none")] pub pdf: Option, @@ -6802,11 +6786,7 @@ impl tabled::Tabled for Invoice { } else { String::new().into() }, - if let Some(attempted) = &self.attempted { - format!("{:?}", attempted).into() - } else { - String::new().into() - }, + format!("{:?}", self.attempted).into(), format!("{:?}", self.created_at).into(), if let Some(currency) = &self.currency { format!("{:?}", currency).into() @@ -6858,11 +6838,7 @@ impl tabled::Tabled for Invoice { } else { String::new().into() }, - if let Some(paid) = &self.paid { - format!("{:?}", paid).into() - } else { - String::new().into() - }, + format!("{:?}", self.paid).into(), if let Some(pdf) = &self.pdf { format!("{:?}", pdf).into() } else { @@ -7525,8 +7501,8 @@ pub struct KclCodeCompletionParams { #[serde(default, skip_serializing_if = "Option::is_none")] pub suffix_tokens: Option, #[doc = "If we should trim by indentation."] - #[serde(default, skip_serializing_if = "Option::is_none")] - pub trim_by_indentation: Option, + #[serde(default)] + pub trim_by_indentation: bool, } impl std::fmt::Display for KclCodeCompletionParams { @@ -7564,11 +7540,7 @@ impl tabled::Tabled for KclCodeCompletionParams { } else { String::new().into() }, - if let Some(trim_by_indentation) = &self.trim_by_indentation { - format!("{:?}", trim_by_indentation).into() - } else { - String::new().into() - }, + format!("{:?}", self.trim_by_indentation).into(), ] } @@ -7607,8 +7579,8 @@ pub struct KclCodeCompletionRequest { #[serde(default, skip_serializing_if = "Option::is_none")] pub stop: Option>, #[doc = "If set, partial message deltas will be sent, like in ChatGPT or OpenAPI. Tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a data: [DONE] message."] - #[serde(default, skip_serializing_if = "Option::is_none")] - pub stream: Option, + #[serde(default)] + pub stream: bool, #[doc = "The suffix for the model."] #[serde(default, skip_serializing_if = "Option::is_none")] pub suffix: Option, @@ -7665,11 +7637,7 @@ impl tabled::Tabled for KclCodeCompletionRequest { } else { String::new().into() }, - if let Some(stream) = &self.stream { - format!("{:?}", stream).into() - } else { - String::new().into() - }, + format!("{:?}", self.stream).into(), if let Some(suffix) = &self.suffix { format!("{:?}", suffix).into() } else { @@ -9521,8 +9489,8 @@ pub struct Org { #[serde(default, skip_serializing_if = "Option::is_none")] pub block: Option, #[doc = "If we can train on the orgs's data. This value overrides any individual user's `can_train_on_data` value if they are a member of the org."] - #[serde(default, skip_serializing_if = "Option::is_none")] - pub can_train_on_data: Option, + #[serde(default)] + pub can_train_on_data: bool, #[doc = "The date and time the org was created."] pub created_at: chrono::DateTime, #[doc = "The org's domain."] @@ -9583,11 +9551,7 @@ impl tabled::Tabled for Org { } else { String::new().into() }, - if let Some(can_train_on_data) = &self.can_train_on_data { - format!("{:?}", can_train_on_data).into() - } else { - String::new().into() - }, + format!("{:?}", self.can_train_on_data).into(), format!("{:?}", self.created_at).into(), if let Some(domain) = &self.domain { format!("{:?}", domain).into() @@ -14426,8 +14390,8 @@ pub struct User { #[serde(default, skip_serializing_if = "Option::is_none")] pub block: Option, #[doc = "If we can train on the user's data. If the user is a member of an organization, the organization's setting will override this."] - #[serde(default, skip_serializing_if = "Option::is_none")] - pub can_train_on_data: Option, + #[serde(default)] + pub can_train_on_data: bool, #[doc = "The user's company."] #[serde(default, skip_serializing_if = "Option::is_none")] pub company: Option, @@ -14453,8 +14417,8 @@ pub struct User { #[doc = "The image avatar for the user. This is a URL."] pub image: String, #[doc = "If the user is tied to a service account."] - #[serde(default, skip_serializing_if = "Option::is_none")] - pub is_service_account: Option, + #[serde(default)] + pub is_service_account: bool, #[doc = "The user's last name."] #[serde(default, skip_serializing_if = "Option::is_none")] pub last_name: Option, @@ -14488,11 +14452,7 @@ impl tabled::Tabled for User { } else { String::new().into() }, - if let Some(can_train_on_data) = &self.can_train_on_data { - format!("{:?}", can_train_on_data).into() - } else { - String::new().into() - }, + format!("{:?}", self.can_train_on_data).into(), if let Some(company) = &self.company { format!("{:?}", company).into() } else { @@ -14526,11 +14486,7 @@ impl tabled::Tabled for User { }, format!("{:?}", self.id).into(), self.image.clone().into(), - if let Some(is_service_account) = &self.is_service_account { - format!("{:?}", is_service_account).into() - } else { - String::new().into() - }, + format!("{:?}", self.is_service_account).into(), if let Some(last_name) = &self.last_name { format!("{:?}", last_name).into() } else { diff --git a/openapitor/tests/types/oxide.rs.gen b/openapitor/tests/types/oxide.rs.gen index a6c11686..833fef54 100644 --- a/openapitor/tests/types/oxide.rs.gen +++ b/openapitor/tests/types/oxide.rs.gen @@ -2894,8 +2894,8 @@ pub struct NetworkInterfaceUpdate { #[serde(default, skip_serializing_if = "Option::is_none")] pub description: Option, #[doc = "Make a secondary interface the instance's primary interface.\n\nIf applied to a secondary interface, that interface will become the primary on the next reboot of the instance. Note that this may have implications for routing between instances, as the new primary interface will be on a distinct subnet from the previous primary interface.\n\nNote that this can only be used to select a new primary interface for an instance. Requests to change the primary interface into a secondary will return an error."] - #[serde(default, skip_serializing_if = "Option::is_none")] - pub make_primary: Option, + #[serde(default)] + pub make_primary: bool, #[serde(default, skip_serializing_if = "Option::is_none")] pub name: Option, } @@ -2920,11 +2920,7 @@ impl tabled::Tabled for NetworkInterfaceUpdate { } else { String::new().into() }, - if let Some(make_primary) = &self.make_primary { - format!("{:?}", make_primary).into() - } else { - String::new().into() - }, + format!("{:?}", self.make_primary).into(), if let Some(name) = &self.name { format!("{:?}", name).into() } else {