Berenger Zina
10/24/2024, 1:26 PM{
"mappings": [
{
"priority": 6,
"request": {
"method": "ANY",
"urlPattern": "/sample/.*"
},
"response": {
"transformers": [
"proxy-template"
],
"proxyBaseUrl": "${env.url}"
}
}
]
}
Lee Turner
10/24/2024, 1:43 PMresponse-template
transformer. This will allow you to use the handlebars templating.
Then, for the proxyBaseUrl
you might be able to use the systemValue
helper. I have never tried this but it should work like any other helper in this instance:
{{systemValue type='ENVIRONMENT' key='URL'}}
So you will be looking at a stub like the following:
{
"mappings": [
{
"priority": 6,
"request": {
"method": "ANY",
"urlPattern": "/sample/.*"
},
"response": {
"transformers": [
"response-template"
],
"proxyBaseUrl": "{{systemValue type='ENVIRONMENT' key='URL'}}"
}
}
]
}
https://wiremock.org/docs/response-templating/#system-property-helperBerenger Zina
10/24/2024, 3:32 PMLee Turner
10/24/2024, 3:42 PMLee Turner
10/24/2024, 3:44 PMwiremock.url
and then update your stub accordingly:
{
"mappings": [
{
"priority": 6,
"request": {
"method": "ANY",
"urlPattern": "/sample/.*"
},
"response": {
"transformers": [
"response-template"
],
"proxyBaseUrl": "{{systemValue type='ENVIRONMENT' key='wiremock.url'}}"
}
}
]
}
Lee Turner
10/24/2024, 3:51 PM--permitted-system-keys: Comma-separated list of regular expressions for names of permitted environment variables and system properties accessible from response templates. Only has any effect when templating is enabled. Defaults to wiremock.*.
Berenger Zina
10/24/2024, 4:55 PMLee Turner
10/24/2024, 5:09 PM