Slackbot
11/28/2023, 12:42 PMTom
11/28/2023, 12:50 PMeach
, if
and other conditional helpers are all available.Victor Baulac
11/28/2023, 1:02 PMTom
11/28/2023, 1:14 PMVictor Baulac
11/28/2023, 1:16 PM{
"request": {
"method": "GET",
"url": "/conditional/stuff"
},
"response": {
"status": 200,
"body": "{{#if (contains 'abcde' 'abc')}}
YES
{{/if}}",
"transformers": ["response-template"],
"headers": {
"Content-Type": "text/json"
}
}
}
As simple as that 🙂 When runing the docker I get :Victor Baulac
11/28/2023, 1:17 PMVictor Baulac
11/28/2023, 1:29 PM"body": "{{#if (contains 'abcde' 'abc')}}
Tom
11/28/2023, 1:29 PMTom
11/28/2023, 1:31 PMTom
11/28/2023, 1:32 PM{
"request": {
"method": "GET",
"url": "/conditional/stuff"
},
"response": {
"status": 200,
"body": "{{#if (contains 'abcde' 'abc')}}\nYES\n{{/if}}",
"transformers": [
"response-template"
],
"headers": {
"Content-Type": "text/json"
}
}
}
Victor Baulac
11/28/2023, 1:34 PMVictor Baulac
11/28/2023, 1:35 PMVictor Baulac
11/28/2023, 1:35 PMTom
11/28/2023, 1:41 PMVictor Baulac
11/28/2023, 1:42 PMTom
11/28/2023, 1:43 PMVictor Baulac
11/28/2023, 1:43 PMTom
11/28/2023, 1:43 PMmy-response-body.json
under __files
then reference it "bodyFileName": "my-response-body.json"
in your stub instead of body
Victor Baulac
11/28/2023, 1:44 PM"body": "[ {{#each (jsonPath request.body '$') as |todo|}}
{ \"todo_id\":
{{#if (todo.todo_id == null) }}
1{{randomValue length=1 type='NUMERIC'}}
{{else}}
{{todo.todo_id}}
{{/if}}
},
{{/each}} ]"
On multi-line so it can be on source control, and be reviewedTom
11/28/2023, 1:44 PMTom
11/28/2023, 1:44 PMmappings
and __files
Tom
11/28/2023, 1:44 PMVictor Baulac
11/28/2023, 1:44 PMTom
11/28/2023, 1:45 PMTom
11/28/2023, 1:45 PMbody
valueVictor Baulac
11/28/2023, 1:45 PMTom
11/28/2023, 1:45 PMContent-Type
response header is what actually determines the type, as far as your calling client is concernedVictor Baulac
11/28/2023, 1:50 PMVictor Baulac
11/28/2023, 1:50 PMTom
11/28/2023, 1:50 PM