arlyon / async-stripe

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

Enum generated FromStr improvements #537

Closed mzeitlin11 closed 2 months ago

mzeitlin11 commented 2 months ago

After using this, I realized a couple issues

There's another question which doesn't need to be answered here around usage of Unknown as a fallback so that added enum variants are not a breaking change for parsing.

The openapi code currently uses the completely unscientific value of 12 variants for determining when Unknown should be inserted - there's probably an argument for using Unknown on smaller enums than that (or always, but that might start to hurt ergonomics for pretty stable enums).

arlyon commented 2 months ago

There's another question which doesn't need to be answered here around usage of Unknown as a fallback so that added enum variants are not a breaking change for parsing.

I have no strong opinions here. I am tempted to say that if you update your stripe API version you should make sure this library is updated to handle it but I don't think that adding variants is considered a breaking change... I think we could bring the threshhold down a little, perhaps down to 4 or 6, or maybe always insert Unknown for 'regular' enums (as opposed to tagged variants with associated data). I have a feeling most of the churn will come from 'this field has n string values' rather than fundamental differences in response type.

arlyon commented 2 months ago

I will open a ticket on the project and lets move on.