async-stripe icon indicating copy to clipboard operation
async-stripe copied to clipboard

Add `utoipa` feature which derives `ToSchema`

Open nuzzles opened this issue 11 months ago • 5 comments

Is your feature request related to a problem? Please describe.

Similar to https://github.com/juhaku/utoipa/issues/1347 , the types such as Product don't derive ToSchema which makes running an OpenAPI swagger doc hard to model.

Describe the solution you'd like

Derive ToSchema with the utoipa feature.

Describe alternatives you've considered

No response

Additional context

No response

nuzzles avatar Mar 25 '25 22:03 nuzzles

I don't mind doing this on this side. I'll take a look.

arlyon avatar Apr 08 '25 12:04 arlyon

Thank you!

nuzzles avatar Apr 08 '25 14:04 nuzzles

I can do it if needed @arlyon !

EvolveArt avatar Apr 11 '25 16:04 EvolveArt

I don't think async-stripe need support utoipa, you can use #[schema()] attribute to specify the field type. See https://docs.rs/utoipa/latest/utoipa/derive.ToSchema.html, hope this helpful to you.

use stripe::ProductId;
use utoipa::ToSchema;

#[derive(Deserialize, ToSchema)]
pub(crate) struct CreateProduct {
    #[schema(value_type = Vec<String>)]
    stripe_product_ids: Vec<ProductId>,
    name: String,
    icon: Option<String>,
    description: Option<String>,
}

Folyd avatar Apr 18 '25 14:04 Folyd

I don't want to separately duplicate and maintain all type definitions. That's why I created this issue.

nuzzles avatar Apr 19 '25 13:04 nuzzles

I think I am going to reject this simply because of the many many hours I spend fielding reports of API breakages. The last thing you want is a change to the format the stripe produces causing your public APIs to change (and break). Stripe very much likes to do this. I would encourage you to publish your own domain specific data structures (DTOs) with conversions. Claude should make writing this conversion code pretty straight forward.

It also reduces maintenance burden 😏

Thanks for using async-stripe!

arlyon avatar Dec 03 '25 17:12 arlyon