Description
Problem to solve
Driving hurl from a test runner I need to pass a json request body variable into the hurl script. I wrap the value in single quotes so as not to break the command string, but there is no native way to tell hurl that the variable is of type json and to be able to use that json in the request body.
At the moment the workaround is to write:
my-test.hurl
GET ...
content-type: application/json
{{ body }}
Proposal
A. Allow one to type variables more explicitly
- add types into the option name e.g instead of --variable we could have --variable-json, --variable-int, ..
- add the ability to specify a conversion function within template replacement sites e.g. {{ to_json(variable) }}
B. Use above typing to infer content type for the request body so there does not need to be any workaround in the hurl file e.g. give that the variable is of type json then the above hurlfile could just be:
Option A:
hurl --test my-test.hurl --variable-json body='{ "name": "xxx" }'
my-test.hurl
GET ...
{{ body }}
Option B
hurl --test my-test.hurl --variable body='{ "name": "xxx" }'
my-test.hurl
GET ...
{{ to_json(body) }}