Rebuild data replacement strategy to use input from OpenAPI schema #211
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously, the data replacer worked by taking input request and output
response data, and replacing values if the types matched up. This generally
worked, but would result in some inappropriate replacements for more
complex data types like arrays, as seen in [1].
In this patch we upgrade the replacement strategy so that we perform
replacements if the type of incoming request data matches what we expected
in the response based on the OpenAPI schema. This allows us, for example,
to not only check that a type is an array, but also what sort of elements
that array is supposed to contain, even if the value from our fixtures is
an empty array (which is often the case).
Fixes #210.
r? @ob-stripe
cc @stripe/api-libraries
[1] #210