Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix always-failing Invoice::upcoming(...) #131

Merged
merged 1 commit into from
May 16, 2020
Merged

Fix always-failing Invoice::upcoming(...) #131

merged 1 commit into from
May 16, 2020

Conversation

bryanburgers
Copy link
Contributor

Invoice::upcoming(...) would always fail. The API call returns an
invoice that doesn't actually exist, and because it doesn't exist, it
doesn't have an "id" field in the response.

Note that when you are viewing an upcoming invoice, you are simply
viewing a preview – the invoice has not yet been created. As such, the
upcoming invoice will not show up in invoice listing calls, and you
cannot use the API to pay or edit the invoice. If you want to change the
amount that your customer will be billed, you can add, remove, or update
pending invoice items, or update the customer’s discount.

The lack of an "id" field causes the parsing of an Invoice to fail.

We can't do struct Invoice { id: Option<InvoiceId> } because the
Object trait expects the ID of the object to not be an option.

It seems like the least terrible option is to set #[serde(default)] on
the ID field and provide an empty string as an ID. While this isn't
great, it seems like the best of the bad options.

`Invoice::upcoming(...)` would always fail. The API call returns an
invoice that doesn't actually exist, and because it doesn't exist, it
doesn't have an `"id"` field in the response.

> Note that when you are viewing an upcoming invoice, you are simply
> viewing a preview – the invoice has not yet been created. As such, the
> upcoming invoice will not show up in invoice listing calls, and you
> cannot use the API to pay or edit the invoice. If you want to change the
> amount that your customer will be billed, you can add, remove, or update
> pending invoice items, or update the customer’s discount.

The lack of an `"id"` field causes the parsing of an `Invoice` to fail.

We can't do `struct Invoice { id: Option<InvoiceId> }` because the
`Object` trait expects the ID of the object to not be an option.

It seems like the least terrible option is to set `#[serde(default)]` on
the ID field and provide an empty string as an ID. While this isn't
great, it seems like the best of the bad options.
@bryanburgers
Copy link
Contributor Author

Note: I also logged this over at stripe/openapi#56 (comment) and Stripe is looking into what to do about this from an openapi standpoint.

@kestred
Copy link
Collaborator

kestred commented May 16, 2020

Thanks for logging an issue with stripe's openapi 😅 .

I'll merge this into both release/v0.12.x branch and the master (v0.13.0-dev) branch

@kestred kestred changed the base branch from master to release/v0.12.x May 16, 2020 22:52
@kestred kestred merged commit 0634005 into wyyerd:release/v0.12.x May 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants