Closed paulcadman closed 4 years ago
@paulcadman Overall, this change sounds great to me. Concerning the design, my only point of feedback would be that it would be ideal if bodyType
were optional so that it didn't need to be specified every time. I figure lots of test suites will only use a single bodyType
.
I'd be fine with either defaulting to JSON
when it's not specified, or even accepting something like a defaults.bodyType
at the top level of the test spec, what do you think? I assume the former is easier to implement.
Hi @aviaviavi - thanks for the feedback.
I agree that bodyType
should be optional. The current implementation does default to JSON
if no bodyType
is specified. So most existing specifications (except ones that contain a bodyType
key) will continue to work as before.
Of course, if a JSON
payload does contain a bodyType
key itself - it can still be specified by using the bodyType: json
and contents:
option.
Ok cool sounds good then! I might be misreading the parser code slightly, will add a comment there directly.
Ahh ok, I was mistaken. I was thinking we'd want
requestData:
content:
a: b
c: d
e: f
to parse the same as
requestData:
a: b
c: d
e: f
but when I thought through it more fully, realized we definitely dont want that. so I'm fully on board with what you have! Let me know when you get the tests and docs in, and I'll do a full review again.
Hi @aviaviavi - could you have a look at this again? I've added documentation and tests.
To set a URLEncoded body set bodyType to urlencoded:
To set a JSON body set bodyType to json:
In either case the body is formed from the value of the content key.
The change is backwards compatible so that the following:
will send a JSON body formed from the value of the requestData key.
I'd welcome comments on the design. I'd like to add some tests and update the examples before merging.