Added support for generating curl commands

495 views
Skip to first unread message

JP

unread,
May 4, 2014, 3:49:27 PM5/4/14
to rest-a...@googlegroups.com
Hi Johan,

I didn't want to throw this into the issues list as an enhancement just yet without allowing you / the community to offer insight...

Is it possible currently to generate repeatable curl commands from Rest Assured?  Is there a "proper" way or solution you can suggest outside of Rest Assured?

My thoughts on the RA side of things:

given().
log().all().
outputCurl().
get("/myAPI");

The idea is that as my request is being logged to the console I would also like to be able to automagically log a curl string that would repeat the request.  Whether that is log().all() // includes curl output, or log().request() // only logs request data etc I'm not certain.

What do you think?

Thanks,
JP

Johan Haleby

unread,
May 5, 2014, 7:08:26 AM5/5/14
to rest-a...@googlegroups.com
Hi, 

I'm not sure if I want to integrate something like this into REST Assured itself since it seems quite a specific use case. If you want to implement this I would suggest you to create a filter. A filter has access to all parameters, URL, body etc so it should theoretically be possible to create curl requests from this data. Logging is also implemented using filters under the hood, check out Request- and/or ResponseLoggingFilter in the source code for example. If you create a filter like this I'll be more than happy to include it in REST Assured as an optional module (such as JSON schema validation).

Regards,
/Johan


--
You received this message because you are subscribed to the Google Groups "REST assured" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rest-assured...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Maciej Gawinecki

unread,
Apr 27, 2016, 1:58:28 AM4/27/16
to REST assured
Hi,

Now there's a standalone project that does this, see here: https://github.com/dzieciou/curl-logger. It's available in Maven central as well: http://goo.gl/0trW13

More precisely curl-logger generates curl command from actual requests sent by RestAssured not from request specification. For instance, if in the request specification you don't have a cookie defined but there's a cookie in CookieStore and is being sent by HTTP client then curl-logger will put that cookie in the curl  command.

Disclaimer: I'm the author of the project.

/Maciej

Johan Haleby

unread,
Apr 27, 2016, 2:19:02 AM4/27/16
to rest-a...@googlegroups.com
Cool! Looks good and useful, thanks for sharing.
Reply all
Reply to author
Forward
0 new messages