Skip to content

Commit

Permalink
Use bigdecimal04 feature of schemars (bigdecimal on its own is 0.3)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamchalmers committed Sep 20, 2023
1 parent 5208e18 commit 7e45dec
Show file tree
Hide file tree
Showing 20 changed files with 258 additions and 1,603 deletions.
22 changes: 16 additions & 6 deletions Cargo.lock

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

16 changes: 0 additions & 16 deletions kittycad.rs.patch.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,22 +191,6 @@
"libDocsLink": "https://docs.rs/kittycad/latest/kittycad/hidden/struct.Hidden.html#method.logout"
}
},
{
"op": "add",
"path": "/paths/~1modeling~1cmd/post/x-rust",
"value": {
"example": "/// Submit one modeling operation.\n/// \n/// Response depends on which command was submitted, so unfortunately the OpenAPI schema can't generate the right response type.\nuse std::str::FromStr;\nasync fn example_modeling_cmd() -> anyhow::Result<()> {\n let client = kittycad::Client::new_from_env();\n let result: kittycad::types::OkModelingCmdResponse = client\n .modeling()\n .cmd(&kittycad::types::ModelingCmdReq {\n cmd: kittycad::types::ModelingCmd::CameraDragEnd {\n interaction: kittycad::types::CameraDragInteractionType::Zoom,\n window: kittycad::types::Point2D {\n x: 3.14 as f64,\n y: 3.14 as f64,\n },\n },\n cmd_id: uuid::Uuid::from_str(\"d9797f8d-9ad6-4e08-90d7-2ec17e13471c\")?,\n })\n .await?;\n println!(\"{:?}\", result);\n Ok(())\n}\n",
"libDocsLink": "https://docs.rs/kittycad/latest/kittycad/modeling/struct.Modeling.html#method.cmd"
}
},
{
"op": "add",
"path": "/paths/~1modeling~1cmd-batch/post/x-rust",
"value": {
"example": "/// Submit many modeling operations.\nuse std::str::FromStr;\nasync fn example_modeling_cmd_batch() -> anyhow::Result<()> {\n let client = kittycad::Client::new_from_env();\n let result: kittycad::types::ModelingOutcomes = client\n .modeling()\n .cmd_batch(&kittycad::types::ModelingCmdReqBatch {\n cmds: std::collections::HashMap::from([(\n \"some-key\".to_string(),\n kittycad::types::ModelingCmdReq {\n cmd: kittycad::types::ModelingCmd::CameraDragEnd {\n interaction: kittycad::types::CameraDragInteractionType::Zoom,\n window: kittycad::types::Point2D {\n x: 3.14 as f64,\n y: 3.14 as f64,\n },\n },\n cmd_id: uuid::Uuid::from_str(\"d9797f8d-9ad6-4e08-90d7-2ec17e13471c\")?,\n },\n )]),\n })\n .await?;\n println!(\"{:?}\", result);\n Ok(())\n}\n",
"libDocsLink": "https://docs.rs/kittycad/latest/kittycad/modeling/struct.Modeling.html#method.cmd_batch"
}
},
{
"op": "add",
"path": "/paths/~1oauth2~1device~1auth/post/x-rust",
Expand Down
3 changes: 2 additions & 1 deletion kittycad/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ license = "MIT"
anyhow = "1"
async-trait = { version = "^0.1.53", optional = true }
base64 = "0.21"
bigdecimal = { version = "0.4", features = ["serde"] }
bytes = { version = "1", features = ["serde"] }
clap = { version = "4.2.4", features = ["cargo", "derive", "env", "unicode"], optional = true }
chrono = { version = "0.4", default-features = false, features = ["serde", "std"] }
Expand All @@ -30,7 +31,7 @@ reqwest-conditional-middleware = { version = "0.2.1", optional = true }
reqwest-middleware = { version = "0.2.2", optional = true }
reqwest-retry = { version = "0.2.2", optional = true }
reqwest-tracing = { version = "0.4.4", features = ["opentelemetry_0_17"], optional = true }
schemars = { version = "0.8", features = ["bytes", "chrono", "url", "uuid1"] }
schemars = { version = "0.8.15", features = ["bigdecimal04", "bytes", "chrono", "url", "uuid1"] }
serde = { version = "1", features = ["derive"] }
serde_bytes = "0.11"
serde_json = "1"
Expand Down
8 changes: 5 additions & 3 deletions kittycad/src/ai.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ impl Ai {
) -> Result<crate::types::Mesh, crate::types::error::Error> {
let mut req = self.client.client.request(
http::Method::POST,
format!(
&format!(
"{}/{}",
self.client.base_url,
"ai/image-to-3d/{input_format}/{output_format}"
Expand All @@ -41,6 +41,7 @@ impl Ai {
format_serde_error::SerdeError::new(text.to_string(), err),
status,
)
.into()
})
} else {
Err(crate::types::error::Error::UnexpectedResponse(resp))
Expand All @@ -56,15 +57,15 @@ impl Ai {
) -> Result<crate::types::Mesh, crate::types::error::Error> {
let mut req = self.client.client.request(
http::Method::POST,
format!(
&format!(
"{}/{}",
self.client.base_url,
"ai/text-to-3d/{output_format}"
.replace("{output_format}", &format!("{}", output_format))
),
);
req = req.bearer_auth(&self.client.token);
let query_params = vec![("prompt", prompt.to_string())];
let query_params = vec![("prompt", format!("{}", prompt))];
req = req.query(&query_params);
let resp = req.send().await?;
let status = resp.status();
Expand All @@ -75,6 +76,7 @@ impl Ai {
format_serde_error::SerdeError::new(text.to_string(), err),
status,
)
.into()
})
} else {
Err(crate::types::error::Error::UnexpectedResponse(resp))
Expand Down
46 changes: 29 additions & 17 deletions kittycad/src/api_calls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl ApiCalls {
) -> Result<Vec<crate::types::ApiCallQueryGroup>, crate::types::error::Error> {
let mut req = self.client.client.request(
http::Method::GET,
format!("{}/{}", self.client.base_url, "api-call-metrics"),
&format!("{}/{}", self.client.base_url, "api-call-metrics"),
);
req = req.bearer_auth(&self.client.token);
let query_params = vec![("group_by", format!("{}", group_by))];
Expand All @@ -34,6 +34,7 @@ impl ApiCalls {
format_serde_error::SerdeError::new(text.to_string(), err),
status,
)
.into()
})
} else {
Err(crate::types::error::Error::UnexpectedResponse(resp))
Expand All @@ -50,7 +51,7 @@ impl ApiCalls {
) -> Result<crate::types::ApiCallWithPriceResultsPage, crate::types::error::Error> {
let mut req = self.client.client.request(
http::Method::GET,
format!("{}/{}", self.client.base_url, "api-calls"),
&format!("{}/{}", self.client.base_url, "api-calls"),
);
req = req.bearer_auth(&self.client.token);
let mut query_params = vec![];
Expand All @@ -76,6 +77,7 @@ impl ApiCalls {
format_serde_error::SerdeError::new(text.to_string(), err),
status,
)
.into()
})
} else {
Err(crate::types::error::Error::UnexpectedResponse(resp))
Expand Down Expand Up @@ -105,7 +107,7 @@ impl ApiCalls {
async {
let mut req = self.client.client.request(
http::Method::GET,
format!("{}/{}", self.client.base_url, "api-calls"),
&format!("{}/{}", self.client.base_url, "api-calls"),
);
req = req.bearer_auth(&self.client.token);
let mut request = req.build()?;
Expand All @@ -122,6 +124,7 @@ impl ApiCalls {
),
status,
)
.into()
})
} else {
Err(crate::types::error::Error::UnexpectedResponse(resp))
Expand Down Expand Up @@ -153,10 +156,10 @@ impl ApiCalls {
) -> Result<crate::types::ApiCallWithPrice, crate::types::error::Error> {
let mut req = self.client.client.request(
http::Method::GET,
format!(
&format!(
"{}/{}",
self.client.base_url,
"api-calls/{id}".replace("{id}", id)
"api-calls/{id}".replace("{id}", &id)
),
);
req = req.bearer_auth(&self.client.token);
Expand All @@ -169,6 +172,7 @@ impl ApiCalls {
format_serde_error::SerdeError::new(text.to_string(), err),
status,
)
.into()
})
} else {
Err(crate::types::error::Error::UnexpectedResponse(resp))
Expand All @@ -186,7 +190,7 @@ impl ApiCalls {
) -> Result<crate::types::AsyncApiCallResultsPage, crate::types::error::Error> {
let mut req = self.client.client.request(
http::Method::GET,
format!("{}/{}", self.client.base_url, "async/operations"),
&format!("{}/{}", self.client.base_url, "async/operations"),
);
req = req.bearer_auth(&self.client.token);
let mut query_params = vec![];
Expand Down Expand Up @@ -216,6 +220,7 @@ impl ApiCalls {
format_serde_error::SerdeError::new(text.to_string(), err),
status,
)
.into()
})
} else {
Err(crate::types::error::Error::UnexpectedResponse(resp))
Expand Down Expand Up @@ -245,7 +250,7 @@ impl ApiCalls {
async {
let mut req = self.client.client.request(
http::Method::GET,
format!("{}/{}", self.client.base_url, "async/operations"),
&format!("{}/{}", self.client.base_url, "async/operations"),
);
req = req.bearer_auth(&self.client.token);
let mut request = req.build()?;
Expand All @@ -262,6 +267,7 @@ impl ApiCalls {
),
status,
)
.into()
})
} else {
Err(crate::types::error::Error::UnexpectedResponse(resp))
Expand Down Expand Up @@ -303,10 +309,10 @@ impl ApiCalls {
) -> Result<crate::types::AsyncApiCallOutput, crate::types::error::Error> {
let mut req = self.client.client.request(
http::Method::GET,
format!(
&format!(
"{}/{}",
self.client.base_url,
"async/operations/{id}".replace("{id}", id)
"async/operations/{id}".replace("{id}", &id)
),
);
req = req.bearer_auth(&self.client.token);
Expand All @@ -319,6 +325,7 @@ impl ApiCalls {
format_serde_error::SerdeError::new(text.to_string(), err),
status,
)
.into()
})
} else {
Err(crate::types::error::Error::UnexpectedResponse(resp))
Expand All @@ -335,7 +342,7 @@ impl ApiCalls {
) -> Result<crate::types::ApiCallWithPriceResultsPage, crate::types::error::Error> {
let mut req = self.client.client.request(
http::Method::GET,
format!("{}/{}", self.client.base_url, "user/api-calls"),
&format!("{}/{}", self.client.base_url, "user/api-calls"),
);
req = req.bearer_auth(&self.client.token);
let mut query_params = vec![];
Expand All @@ -361,6 +368,7 @@ impl ApiCalls {
format_serde_error::SerdeError::new(text.to_string(), err),
status,
)
.into()
})
} else {
Err(crate::types::error::Error::UnexpectedResponse(resp))
Expand Down Expand Up @@ -390,7 +398,7 @@ impl ApiCalls {
async {
let mut req = self.client.client.request(
http::Method::GET,
format!("{}/{}", self.client.base_url, "user/api-calls"),
&format!("{}/{}", self.client.base_url, "user/api-calls"),
);
req = req.bearer_auth(&self.client.token);
let mut request = req.build()?;
Expand All @@ -407,6 +415,7 @@ impl ApiCalls {
),
status,
)
.into()
})
} else {
Err(crate::types::error::Error::UnexpectedResponse(resp))
Expand Down Expand Up @@ -445,10 +454,10 @@ impl ApiCalls {
) -> Result<crate::types::ApiCallWithPrice, crate::types::error::Error> {
let mut req = self.client.client.request(
http::Method::GET,
format!(
&format!(
"{}/{}",
self.client.base_url,
"user/api-calls/{id}".replace("{id}", id)
"user/api-calls/{id}".replace("{id}", &id)
),
);
req = req.bearer_auth(&self.client.token);
Expand All @@ -461,6 +470,7 @@ impl ApiCalls {
format_serde_error::SerdeError::new(text.to_string(), err),
status,
)
.into()
})
} else {
Err(crate::types::error::Error::UnexpectedResponse(resp))
Expand All @@ -478,10 +488,10 @@ impl ApiCalls {
) -> Result<crate::types::ApiCallWithPriceResultsPage, crate::types::error::Error> {
let mut req = self.client.client.request(
http::Method::GET,
format!(
&format!(
"{}/{}",
self.client.base_url,
"users/{id}/api-calls".replace("{id}", id)
"users/{id}/api-calls".replace("{id}", &id)
),
);
req = req.bearer_auth(&self.client.token);
Expand All @@ -508,6 +518,7 @@ impl ApiCalls {
format_serde_error::SerdeError::new(text.to_string(), err),
status,
)
.into()
})
} else {
Err(crate::types::error::Error::UnexpectedResponse(resp))
Expand Down Expand Up @@ -538,10 +549,10 @@ impl ApiCalls {
async {
let mut req = self.client.client.request(
http::Method::GET,
format!(
&format!(
"{}/{}",
self.client.base_url,
"users/{id}/api-calls".replace("{id}", id)
"users/{id}/api-calls".replace("{id}", &id)
),
);
req = req.bearer_auth(&self.client.token);
Expand All @@ -559,6 +570,7 @@ impl ApiCalls {
),
status,
)
.into()
})
} else {
Err(crate::types::error::Error::UnexpectedResponse(resp))
Expand Down
Loading

0 comments on commit 7e45dec

Please sign in to comment.