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

Replace data in response with data from request #74

Merged
merged 1 commit into from
May 17, 2018

Conversation

brandur-stripe
Copy link
Contributor

@brandur-stripe brandur-stripe commented May 16, 2018

Here we try to to some additional enrichment on response data by
replacing what we found in fixtures with data that came in from the
request.

The algorithm is quite simple: we walk the decoded request object and
the generated response object, replace any scalars that we see where the
key name is the same, and recurse in when we see two keys with the same
names that are both maps.

In addition, I realized that we are no longer vetting that incorrect
keys are not being passed to stripe-mock, which appears to be a
regression from a change passed some time ago. This patch also adds back
a check on additionalProperties: false.

cc @tmaxwell-stripe Any thoughts on this?
cc @stripe/api-libraries

Here we try to to some additional enrichment on response data by
replacing what we found in fixtures with data that came in from the
request.

The algorithm is quite simple: we walk the decoded request object and
the generated response object, replace any scalars that we see where the
key name is the same, and recurse in when we see two keys with the same
names that are both maps.

In addition, I realized that we are no longer vetting that incorrect
keys are not being passed to stripe-mock, which appears to be a
regression from a change passed some time ago. This patch also adds back
a check on `additionalProperties: false`.
@tmaxwell-stripe
Copy link
Contributor

👍 in general, but I think we should look at the response schema type when deciding whether or not to replace data, in addition to or instead of looking at the fixture data type.

@brandur-stripe
Copy link
Contributor Author

@tmaxwell-stripe Thanks Tim! And yes, totally agreed. With this framework in place, I'm going to add that on as the next incremental step.

@brandur-stripe
Copy link
Contributor Author

Alright, going to pull this in for now, and keep iterating.

@brandur-stripe brandur-stripe merged commit ad06541 into master May 17, 2018
@brandur-stripe brandur-stripe deleted the brandur-data-replacement branch May 17, 2018 08:56
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.

3 participants