mmock
mmock copied to clipboard
[Feature Request] Parse external streams (file.contents at least) for variable tags
Hi, I think it would be useful to parse external files for variable tags. This way it would be possible to have the response contents outside the mock definition files and still be able to populate it with fake data.
If this is already possible, I can't seem to find how to do it.
An example:
MMock definition:
request:
method: GET
path: "/"
response:
statusCode: 200
headers:
Content-Type:
- application/json
body: "{{file.contents(test_payload.json)}}"
test_payload.json:
{"test": "{{fake.Brand}}"}
response:
{"test": "Zoozzy"}
Right now this is the response:
{"test": "{{fake.Brand}}"}
Hi, is this still available?
I am a newbie in Go but I will try to implement this feature, although I was thinking that maybe makes more sense to use another key, eg:
request:
method: GET
path: "/"
response:
statusCode: 200
headers:
Content-Type:
- application/json
bodyFilePath: test_payload.json
What do you think?
It would be very nice to have this. Stringified JSON values for the body are hard to work with.
Fixed in https://github.com/jmartin82/mmock/pull/139
Thanks for reporting it!