APIGW: fix requestOverride not being present in responseTemplates #11799
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.
Motivation
As reported in our Community Slack, having a similar flow as the one added in this test in a VTL template did not work currently.
The idea is to get some data from the incoming request, maybe transform it and set it in the
context.requestOverride
.Then, the response template can access it and transform it/do conditional logic on it.
As we don't want to directly mutate the passed context, we deep copy it before sending it down for rendering (as we don't fully control the rendering logic and what is protected or not).
We then need to attach the
requestOverride
data back to the context so that it is available in thecontext
in the response template to execute logic on it.Changes
requestOverride
to the context variablesrequestOverride
, then parse the JSON back in the response template and execute logic on it