-
Notifications
You must be signed in to change notification settings - Fork 123
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
Uncertainty on when invoice.subscription is to be expanded. #61
Comments
Sorry, after re-reading the spec, I got this wrong, but I'm still confused. |
@rdarder Would you be able to provide a bit more details about how you are testing this exactly? What do you use to fetch the Invoice that leads to you seeing the |
Hi Remi,
Here's a sample anonymized customer I get back as part of the response. Below are some questions regarding some specific patterns: address: anyOf([address]), nullable: true, marked as expandable default_source: anyOf(str, ... polymorphic entities), is nullable, is expandable. invoice_settings. ref(invoice_settings_customer_setting), not nullable, marked as expandable. sources: this is a "page-like" object of a polymorphic entity (payment sources). non nullable and expandable. Also within the object, the "data" attribute is also marked as expandable. subscriptions: equivalent case to sources: I get back the whole thing without asking for expansion. Could you help me figure out how expansion works in these scenarios? |
@rdarder I usually recommend referring more to our API Reference than the openapi for questions like this honestly but here's a detailed answer. In all the examples you gave, there are 4 separate and different situations:
|
Thanks for the quick response! I opted to ask here since I'm trying to make sense of your openapi spec extensions rather than individual cases. In other words, I'm pursuing statically typing the resources I get back from stripe's API. |
@rdarder How are you getting that raw JSON exactly? I just tried quickly on the default test account for our docs and as long as I force the latest API version explicitly in the call then Here's what I get:
|
I'm listing all customers through |
Nevermind, I wasn't setting the right api version. If I use the 2020-08-27, I get exactly what you said. Thank you! |
Could you help me figure out if there's anything on your openapi spec that would help me determine that this is "auto-expanded"? Cause it's marked as an expandable field. |
Whether it is auto-expanded or not depends on whether it's optional and what is the shape described. For
and later On the other hand for |
@rdarder Really sorry for the delays. I checked in internally on this ask and unfortunately there is no reliable way right now to know for sure if a property is automatically expanded or not in openapi. It's definitely something we'd like to improve upon in the future but it won't happen immediately. cc @richardm-stripe who is looking into this. |
Hi there!
I'm wrapping my head around x-expandableFields and x-expansionResources. I thought I got this right but there's a case that confuses me.
Let's take invoice.subscription. it's not an expandableFIeld and it's still
anyOf(str, ref(subscription))
. So far, every time I get an invoice, I see the subscription automatically expanded. So my questions are:I notice that the field is hinted with an x-expansionResources, which if I understand correctly, hints that the id form of this field is a reference to the indicated (subscription) resource. I'm just unsure if I'm missing something here.
My intention is to reduce the type ambiguity of the return types, so consumers don't need to check whether -- in this case -- the subscription is an id or the actual object. I can deal with expandableFields most of the times, but this one seems off.
Thank you!!
The text was updated successfully, but these errors were encountered: