-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reflect an object's primary ID from a path back in the response
When requesting a path from `stripe-mock` with an object's primary ID in the URL: ``` GET /v1/charges/ch_idFromURL ``` Previously, we'd return the ID from the bundled fixtures. This patch changes the behavior to try and detect when the path contains an object's primary ID and reflect that back into the respond instead: ``` { "id": "ch_idFromURL", } ``` (Previously, this would have been `ch_123` or whatever the fixtures contained.) We also tweak things in a few other places for consistency. If we find a string value in our generated response with the same value as the ID we replaced, we replace it as well. This allows an embedded resource with an ID field that references its parent to reference it with a sane ID (e.g., the `charge` field on a refund that's embedded in a charge's `refunds` sublist). We also modify URLs in embedded sublists to contain the right ID. e.g., ``` { "url": "/v1/charges/ch_idFromURL" } ``` This is necessary because those URLs are used by our client libraries to determine where they should make calls to (e.g., in `stripe-ruby` calling `charge.refunds.create(...)` uses that `url` values to know where to post). All of this is designed to get our test suite working again with the latest OpenAPI fixtures. In particular, this will allow us to return the right `id` for any deleted object, which will allow `stripe-ruby`'s web mock checks to pass correctly.
- Loading branch information
Showing
5 changed files
with
219 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.