arlyon/async-stripe

(next) Enums not being properly serialized

Closed this issue · 1 comments

Describe the bug

On the stable branch we have enums like UpTo manually defined on the types crate, but that's not the case for next branch, and some autogenerated enums ends up serializing incorrectly.

To Reproduce

Try to create a price with up_to: CreatePriceTiersUpTo::Inf on any tier.

Expected behavior

The price should be created, but instead it fails with an error:

You passed an empty string for 'tiers[0][up_to]'. We assume empty values are an attempt to unset a parameter; however 'tiers[0][up_to]' cannot be unset. You should remove 'tiers[0][up_to]' from your request or supply a non-empty value.

Code snippets

No response

OS

all

Rust version

1.74.0

Library version

next

API version

2024-04-10

Additional context

Taking as an example this enum:

#[derive(Copy, Clone, Debug, serde::Serialize)]
#[serde(untagged)]
pub enum CreatePriceTiersUpTo {
    Inf,
    I64(i64),
}

Inf variant is incorrectly serialized to null, instead of "inf", as explained here.

The correct enum would be:

#[derive(Copy, Clone, Debug, serde::Serialize)]
#[serde(rename_all = "snake_case")]
pub enum CreatePriceTiersUpTo {
    Inf,
    #[serde(untagged)]
    I64(i64),
}

Closing as fixed by #605, not sure why didn't happen automatically