Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
Signed-off-by: Jess Frazelle <github@jessfraz.com>
  • Loading branch information
jessfraz committed Apr 11, 2024
1 parent ba7b8ef commit 81157b9
Show file tree
Hide file tree
Showing 12 changed files with 107 additions and 174 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2.66
0.2.67
4 changes: 2 additions & 2 deletions kittycad.rs.patch.json
Original file line number Diff line number Diff line change
Expand Up @@ -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\""
}
},
{
Expand Down Expand Up @@ -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"
}
},
Expand Down
2 changes: 1 addition & 1 deletion kittycad/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion kittycad/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion kittycad/src/ai.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion kittycad/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
//!
//! ```toml
//! [dependencies]
//! kittycad = "0.2.66"
//! kittycad = "0.2.67"
//! ```
//!
//! ## Basic example
Expand Down
110 changes: 33 additions & 77 deletions kittycad/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3487,8 +3487,8 @@ pub struct Coupon {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub amount_off: Option<f64>,
#[doc = "Always true for a deleted object."]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub deleted: Option<bool>,
#[serde(default)]
pub deleted: bool,
#[doc = "Unique identifier for the object."]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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<bool>,
#[serde(default)]
pub delinquent: bool,
#[doc = "The customer's email address."]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub email: Option<String>,
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -4951,8 +4943,8 @@ pub struct ExtendedUser {
pub block: Option<BlockReason>,
#[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<bool>,
#[serde(default)]
pub can_train_on_data: bool,
#[doc = "The user's company."]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub company: Option<String>,
Expand Down Expand Up @@ -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<bool>,
#[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<String>,
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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<bool>,
#[serde(default)]
pub attempted: bool,
#[doc = "Time at which the object was created."]
pub created_at: chrono::DateTime<chrono::Utc>,
#[doc = "Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), \
Expand Down Expand Up @@ -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<bool>,
#[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<String>,
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -7652,8 +7628,8 @@ pub struct KclCodeCompletionParams {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub suffix_tokens: Option<u32>,
#[doc = "If we should trim by indentation."]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub trim_by_indentation: Option<bool>,
#[serde(default)]
pub trim_by_indentation: bool,
}

impl std::fmt::Display for KclCodeCompletionParams {
Expand Down Expand Up @@ -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(),
]
}

Expand Down Expand Up @@ -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<bool>,
#[serde(default)]
pub stream: bool,
#[doc = "The suffix for the model."]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub suffix: Option<String>,
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -9719,8 +9687,8 @@ pub struct Org {
pub block: Option<BlockReason>,
#[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<bool>,
#[serde(default)]
pub can_train_on_data: bool,
#[doc = "The date and time the org was created."]
pub created_at: chrono::DateTime<chrono::Utc>,
#[doc = "The org's domain."]
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -14682,8 +14646,8 @@ pub struct User {
pub block: Option<BlockReason>,
#[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<bool>,
#[serde(default)]
pub can_train_on_data: bool,
#[doc = "The user's company."]
#[serde(default, skip_serializing_if = "Option::is_none")]
pub company: Option<String>,
Expand All @@ -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<bool>,
#[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<String>,
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
9 changes: 9 additions & 0 deletions openapitor/src/types/example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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")
Expand Down
Loading

0 comments on commit 81157b9

Please sign in to comment.