arlyon / async-stripe

Async (and blocking!) Rust bindings for the Stripe API
https://payments.rs
Apache License 2.0
436 stars 127 forks source link

fix: resource updated_price currency_options field type #427

Closed ernestas-poskus closed 7 months ago

ernestas-poskus commented 1 year ago

Fixing resource update_price currency_options field type.

It should be optional currency with update options as a value

Screenshot 2023-08-19 at 08 20 34

Docs: https://stripe.com/docs/api/prices/update

Codegen: https://github.com/arlyon/async-stripe/blob/master/openapi/src/codegen.rs#L1280

Checklist

ernestas-poskus commented 1 year ago

cc @arlyon

arlyon commented 1 year ago

Hi! Unfortunately I cannot accept changes to the generated code since each week it is overwritten by the open api spec. There are two places this could be incorrect. First, the spec may be wrong (please check out the stripe open api repo to confirm). If the open api is correct, then it must be that our codegen is wrong and we will have to look deeper into it. Let me know what you would like to do.

ernestas-poskus commented 1 year ago

Thanks will check the spec

ernestas-poskus commented 1 year ago

I haven't found any conditional difference between CreatePrice and UpdatePrice in stripe.json spec

However codegen generates:

/// The parameters for `Price::create`.
#[derive(Clone, Debug, Serialize)]
pub struct CreatePrice<'a> {
    /// Prices defined in each available currency option.
    ///
    /// Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub currency_options: Option<CurrencyMap<CreatePriceCurrencyOptions>>,

and UpdatePrice

/// The parameters for `Price::update`.
#[derive(Clone, Debug, Serialize, Default)]
pub struct UpdatePrice<'a> {
    /// Prices defined in each available currency option.
    ///
    /// Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub currency_options: Option<CurrencyMap<Option<CurrencyMap<UpdatePriceCurrencyOptions>>>>,

The former is incorrect because it requires one to supply an optional map that has keys defined as an optional currency map with keys and then a price update struct.