stripe / openapi

An OpenAPI specification for the Stripe API.
MIT License
394 stars 123 forks source link

Invalid fields on subscription fixture #6

Closed mjadczak closed 7 years ago

mjadczak commented 7 years ago

I'm working on an Elixir library for Stripe and using stripe-mock for testing. Stripe-mock pulls from these fixtures for data. Since the library is quite out-of-date, I've written some code which checks for fields returned from the API which are unexpected (most of the time, this means the library is out of date with the newest API version).

However, I just noticed that subscriptions have several fields which they definitely should not have:

17:59:04.553 [error] Extra keys were received but ignored when converting Stripe object subscription: [:account_balance, :billing, :days_until_due, :max_occurrences, :on_behalf_of, :retains_own_balance]

I've double checked with the published API docs and these are clearly fields from other objects. Was this intentional or just a copy-paste typo? If unintentional, I'm happy to do a quick PR to remove these from the fixtures.

These are the offending lines: https://github.com/stripe/openapi/blob/dea2739322c0833ff3cb2c9cf9e1ab9fd26066be/openapi/fixtures.yaml#L1201-L1262

brandur-stripe commented 7 years ago

Hi @mjadczak, thanks for trying OpenAPI + stripe-mock!

The extra fields you're seeing are from special-cased behavior gates. We generate all those fixtures from our API's code and there should be a system in place to sanitize that output before putting it in the fixtures file, but apparently there isn't.

Thanks for the offer for a PR! That won't fully address the problem since your changes would probably be blown away by a future refresh. Let me see if I can address this internally instead. Thanks!

mjadczak commented 7 years ago

Awesome, thanks! I'm not sure what you mean by "behavior gates"—does that mean in certain special cases those fields will indeed be returned by the API?

brandur-stripe commented 7 years ago

I'm not sure what you mean by "behavior gates"—does that mean in certain special cases those fields will indeed be returned by the API?

Ah, it's kind of an internal thing. In some cases we'll gate legacy behavior that we want to get rid of, or abnormal behavior that we're assigning for a few particular merchants.

brandur-stripe commented 7 years ago

Alright, I just pushed an internal fix and updated those fixtures in 1eb339068e24ad92afc68a2ee5e4e63c516828a2. A new version of stripe-mock is available with the new data in 0.1.15.

Thanks again for reporting. Keep 'em coming!