This contract is set up to respond to POST
requests to the /person
endpoint with a 201
.
The body of the response will reflect the values passed in the request.
name: Post person
request:
method: POST
urlPath: /person
headers:
Content-Type: application/json
body:
name: Joe
someBool: true
matchers:
body:
- path: $.name
type: by_regex
predefined: non_blank
- path: $.someBool
type: by_regex
predefined: any_boolean
response:
status: 201
body:
name: "{{{ jsonpath this '$.name' }}}"
someBool: "{{{ jsonpath this '$.someBool' }}}"
matchers:
body:
- path: $.someBool
type: by_regex
predefined: any_boolean
regexType: as_boolean <---- Proposed change by Marcin
POST localhost:5555/Person
{
"name": "Marcin",
"someBool": true
}
This is the reponse I get from the stub when making the example post request
{
"name": "Marcin",
"someBool": "true" <--- STRING
}
This is what I want the stub to respond with when making the example post request
{
"name": "Marcin",
"someBool": true <--- BOOLEAN
}