diff --git a/generated/stripe_core/src/customer/requests.rs b/generated/stripe_core/src/customer/requests.rs index b30bc5334..e71c4ca5e 100644 --- a/generated/stripe_core/src/customer/requests.rs +++ b/generated/stripe_core/src/customer/requests.rs @@ -630,14 +630,14 @@ impl<'a> RetrieveCustomer<'a> { &self, client: &stripe::Client, customer: &stripe_shared::CustomerId, - ) -> stripe::Response { + ) -> stripe::Response { client.get_query(&format!("/customers/{customer}"), self) } } #[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -#[serde(tag = "object")] -pub enum RetrieveReturned { - #[serde(rename = "customer")] +#[serde(untagged)] +pub enum RetrieveCustomerReturned { + Customer(stripe_shared::Customer), DeletedCustomer(stripe_shared::DeletedCustomer), } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] diff --git a/generated/stripe_payment/src/bank_account/requests.rs b/generated/stripe_payment/src/bank_account/requests.rs index 0c33eb8e4..a30a3b820 100644 --- a/generated/stripe_payment/src/bank_account/requests.rs +++ b/generated/stripe_payment/src/bank_account/requests.rs @@ -155,7 +155,7 @@ impl<'a> UpdateCustomerBankAccount<'a> { client: &stripe::Client, customer: &stripe_shared::CustomerId, id: &str, - ) -> stripe::Response { + ) -> stripe::Response { client.send_form( &format!("/customers/{customer}/sources/{id}"), self, @@ -165,7 +165,7 @@ impl<'a> UpdateCustomerBankAccount<'a> { } #[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] #[serde(tag = "object")] -pub enum UpdateCustomerReturned { +pub enum UpdateCustomerBankAccountReturned { #[serde(rename = "card")] Card(stripe_shared::Card), #[serde(rename = "bank_account")] @@ -191,7 +191,7 @@ impl<'a> DeleteCustomerBankAccount<'a> { client: &stripe::Client, customer: &stripe_shared::CustomerId, id: &str, - ) -> stripe::Response { + ) -> stripe::Response { client.send_form( &format!("/customers/{customer}/sources/{id}"), self, @@ -201,7 +201,7 @@ impl<'a> DeleteCustomerBankAccount<'a> { } #[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] #[serde(untagged)] -pub enum DeleteCustomerReturned { +pub enum DeleteCustomerBankAccountReturned { PaymentSource(stripe_shared::PaymentSource), DeletedPaymentSource(stripe_shared::DeletedPaymentSource), } diff --git a/generated/stripe_payment/src/card/requests.rs b/generated/stripe_payment/src/card/requests.rs index 8f2edb6a2..8e10f5e4d 100644 --- a/generated/stripe_payment/src/card/requests.rs +++ b/generated/stripe_payment/src/card/requests.rs @@ -155,7 +155,7 @@ impl<'a> UpdateCustomerCard<'a> { client: &stripe::Client, customer: &stripe_shared::CustomerId, id: &str, - ) -> stripe::Response { + ) -> stripe::Response { client.send_form( &format!("/customers/{customer}/sources/{id}"), self, @@ -165,7 +165,7 @@ impl<'a> UpdateCustomerCard<'a> { } #[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] #[serde(tag = "object")] -pub enum UpdateCustomerReturned { +pub enum UpdateCustomerCardReturned { #[serde(rename = "card")] Card(stripe_shared::Card), #[serde(rename = "bank_account")] @@ -191,7 +191,7 @@ impl<'a> DeleteCustomerCard<'a> { client: &stripe::Client, customer: &stripe_shared::CustomerId, id: &str, - ) -> stripe::Response { + ) -> stripe::Response { client.send_form( &format!("/customers/{customer}/sources/{id}"), self, @@ -201,7 +201,7 @@ impl<'a> DeleteCustomerCard<'a> { } #[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] #[serde(untagged)] -pub enum DeleteCustomerReturned { +pub enum DeleteCustomerCardReturned { PaymentSource(stripe_shared::PaymentSource), DeletedPaymentSource(stripe_shared::DeletedPaymentSource), } diff --git a/generated/stripe_payment/src/source/requests.rs b/generated/stripe_payment/src/source/requests.rs index ce7c5efdd..72c228715 100644 --- a/generated/stripe_payment/src/source/requests.rs +++ b/generated/stripe_payment/src/source/requests.rs @@ -16,7 +16,7 @@ impl<'a> DetachSource<'a> { client: &stripe::Client, customer: &stripe_shared::CustomerId, id: &str, - ) -> stripe::Response { + ) -> stripe::Response { client.send_form( &format!("/customers/{customer}/sources/{id}"), self, @@ -26,7 +26,7 @@ impl<'a> DetachSource<'a> { } #[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] #[serde(untagged)] -pub enum DetachReturned { +pub enum DetachSourceReturned { PaymentSource(stripe_shared::PaymentSource), DeletedPaymentSource(stripe_shared::DeletedPaymentSource), } diff --git a/generated/stripe_terminal/src/terminal_configuration/requests.rs b/generated/stripe_terminal/src/terminal_configuration/requests.rs index 4336de8e2..d2d5aa8a8 100644 --- a/generated/stripe_terminal/src/terminal_configuration/requests.rs +++ b/generated/stripe_terminal/src/terminal_configuration/requests.rs @@ -113,14 +113,14 @@ impl<'a> RetrieveTerminalConfiguration<'a> { &self, client: &stripe::Client, configuration: &stripe_terminal::TerminalConfigurationId, - ) -> stripe::Response { + ) -> stripe::Response { client.get_query(&format!("/terminal/configurations/{configuration}"), self) } } #[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -#[serde(tag = "object")] -pub enum RetrieveReturned { - #[serde(rename = "terminal.configuration")] +#[serde(untagged)] +pub enum RetrieveTerminalConfigurationReturned { + TerminalConfiguration(stripe_terminal::TerminalConfiguration), DeletedTerminalConfiguration(stripe_terminal::DeletedTerminalConfiguration), } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] @@ -176,7 +176,7 @@ impl<'a> UpdateTerminalConfiguration<'a> { &self, client: &stripe::Client, configuration: &stripe_terminal::TerminalConfigurationId, - ) -> stripe::Response { + ) -> stripe::Response { client.send_form( &format!("/terminal/configurations/{configuration}"), self, @@ -185,9 +185,9 @@ impl<'a> UpdateTerminalConfiguration<'a> { } } #[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -#[serde(tag = "object")] -pub enum UpdateReturned { - #[serde(rename = "terminal.configuration")] +#[serde(untagged)] +pub enum UpdateTerminalConfigurationReturned { + TerminalConfiguration(stripe_terminal::TerminalConfiguration), DeletedTerminalConfiguration(stripe_terminal::DeletedTerminalConfiguration), } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] diff --git a/generated/stripe_terminal/src/terminal_location/requests.rs b/generated/stripe_terminal/src/terminal_location/requests.rs index f8dedddd7..d5f1f739e 100644 --- a/generated/stripe_terminal/src/terminal_location/requests.rs +++ b/generated/stripe_terminal/src/terminal_location/requests.rs @@ -15,14 +15,14 @@ impl<'a> RetrieveTerminalLocation<'a> { &self, client: &stripe::Client, location: &stripe_terminal::TerminalLocationId, - ) -> stripe::Response { + ) -> stripe::Response { client.get_query(&format!("/terminal/locations/{location}"), self) } } #[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -#[serde(tag = "object")] -pub enum RetrieveReturned { - #[serde(rename = "terminal.location")] +#[serde(untagged)] +pub enum RetrieveTerminalLocationReturned { + TerminalLocation(stripe_terminal::TerminalLocation), DeletedTerminalLocation(stripe_terminal::DeletedTerminalLocation), } #[derive(Copy, Clone, Debug, serde::Serialize)] @@ -145,14 +145,14 @@ impl<'a> UpdateTerminalLocation<'a> { &self, client: &stripe::Client, location: &stripe_terminal::TerminalLocationId, - ) -> stripe::Response { + ) -> stripe::Response { client.send_form(&format!("/terminal/locations/{location}"), self, http_types::Method::Post) } } #[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -#[serde(tag = "object")] -pub enum UpdateReturned { - #[serde(rename = "terminal.location")] +#[serde(untagged)] +pub enum UpdateTerminalLocationReturned { + TerminalLocation(stripe_terminal::TerminalLocation), DeletedTerminalLocation(stripe_terminal::DeletedTerminalLocation), } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] diff --git a/generated/stripe_terminal/src/terminal_reader/requests.rs b/generated/stripe_terminal/src/terminal_reader/requests.rs index 0f841b964..5c9106f02 100644 --- a/generated/stripe_terminal/src/terminal_reader/requests.rs +++ b/generated/stripe_terminal/src/terminal_reader/requests.rs @@ -25,14 +25,14 @@ impl<'a> UpdateTerminalReader<'a> { &self, client: &stripe::Client, reader: &stripe_terminal::TerminalReaderId, - ) -> stripe::Response { + ) -> stripe::Response { client.send_form(&format!("/terminal/readers/{reader}"), self, http_types::Method::Post) } } #[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -#[serde(tag = "object")] -pub enum UpdateReturned { - #[serde(rename = "terminal.reader")] +#[serde(untagged)] +pub enum UpdateTerminalReaderReturned { + TerminalReader(stripe_terminal::TerminalReader), DeletedTerminalReader(stripe_terminal::DeletedTerminalReader), } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] @@ -52,14 +52,14 @@ impl<'a> RetrieveTerminalReader<'a> { &self, client: &stripe::Client, reader: &stripe_terminal::TerminalReaderId, - ) -> stripe::Response { + ) -> stripe::Response { client.get_query(&format!("/terminal/readers/{reader}"), self) } } #[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -#[serde(tag = "object")] -pub enum RetrieveReturned { - #[serde(rename = "terminal.reader")] +#[serde(untagged)] +pub enum RetrieveTerminalReaderReturned { + TerminalReader(stripe_terminal::TerminalReader), DeletedTerminalReader(stripe_terminal::DeletedTerminalReader), } #[derive(Copy, Clone, Debug, serde::Serialize)] diff --git a/openapi/src/requests.rs b/openapi/src/requests.rs index 7f56e7c31..c96f3c1f8 100644 --- a/openapi/src/requests.rs +++ b/openapi/src/requests.rs @@ -183,12 +183,12 @@ fn build_request( method_name: &str, path_id_map: &HashMap, ) -> anyhow::Result { - let return_ident = RustIdent::joined(method_name, "returned"); + let params_ident = RustIdent::joined(&method_name, parent_ident); + let return_ident = RustIdent::joined(¶ms_ident, "returned"); let return_type = Inference::new(&return_ident, ObjectKind::RequestReturned) .required(true) .infer_schema_or_ref_type(req.returned); - let params_ident = RustIdent::joined(method_name, parent_ident); let param_inference = Inference::new(¶ms_ident, ObjectKind::RequestParam).can_borrow(true).required(true); diff --git a/openapi/src/rust_object.rs b/openapi/src/rust_object.rs index e9a8c4127..a050ba0c5 100644 --- a/openapi/src/rust_object.rs +++ b/openapi/src/rust_object.rs @@ -235,7 +235,11 @@ pub fn as_enum_of_objects<'a>( let path = variant.rust_type.as_ref().and_then(|t| t.as_component_path())?; let obj = components.get(path); let name = obj.data.object_name.as_deref()?; - object_map.insert(name, ObjectRef { path: path.clone(), feature_gate: None }); + + // If we have duplicate object names, we cannot distinguish by the object tag, so give up here + if object_map.insert(name, ObjectRef { path: path.clone(), feature_gate: None }).is_some() { + return None; + } } Some(object_map) } diff --git a/tests/tests/it/blocking/customer.rs b/tests/tests/it/blocking/customer.rs index 48710c94f..ec6717947 100644 --- a/tests/tests/it/blocking/customer.rs +++ b/tests/tests/it/blocking/customer.rs @@ -1,4 +1,6 @@ -use stripe_core::customer::{CreateCustomer, DeleteCustomer}; +use stripe_core::customer::{ + CreateCustomer, DeleteCustomer, RetrieveCustomer, RetrieveCustomerReturned, +}; use crate::mock; @@ -26,3 +28,19 @@ fn customer_create_and_delete_with_account() { customer_create_and_delete(&client); }); } + +#[test] +fn retrieve_customer() { + mock::with_client(|client| { + let id = "cus_123".parse().unwrap(); + let ret = RetrieveCustomer::new().send(client, &id).unwrap(); + match ret { + RetrieveCustomerReturned::Customer(cust) => { + assert_eq!(cust.id, id); + assert_eq!(cust.invoice_prefix, Some("D331735".into())); + assert_eq!(cust.created, 1234567890); + } + RetrieveCustomerReturned::DeletedCustomer(_) => panic!("expected non-deleted response"), + } + }) +}