Skip to content

Instantly share code, notes, and snippets.

@netmilk
netmilk / curl_trace_format
Created July 21, 2013 13:11
Example cUrl trace from command: curl -s -o /dev/null --trace tracefile http://httpbin.org/headers
== Info: About to connect() to httpbin.org port 80 (#0)
== Info: Trying 54.225.138.124...
== Info: connected
== Info: Connected to httpbin.org (54.225.138.124) port 80 (#0)
=> Send header, 149 bytes (0x95)
0000: 47 45 54 20 2f 68 65 61 64 65 72 73 20 48 54 54 GET /headers HTT
0010: 50 2f 31 2e 31 0d 0a 55 73 65 72 2d 41 67 65 6e P/1.1..User-Agen
0020: 74 3a 20 63 75 72 6c 2f 37 2e 32 34 2e 30 20 28 t: curl/7.24.0 (
0030: 78 38 36 5f 36 34 2d 61 70 70 6c 65 2d 64 61 72 x86_64-apple-dar
0040: 77 69 6e 31 32 2e 30 29 20 6c 69 62 63 75 72 6c win12.0) libcurl
kolotoc:~ netmilk$ curl --header "Content-Type: application/json" \
--silent --request POST \
--data-binary "{ \"product\":\"1AB23ORM\", \"quantity\": 2 }" \
"http://curltraceparser.apiary.io/shopping-cart" \
--trace - | \
curl-trace-parser
> POST /shopping-cart HTTP/1.1
> User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8x zlib/1.2.5
> Host: curltraceparser.apiary.io
> Accept: */*
$ npm install -g curl-trace-parser
$ brew install --HEAD \
https://raw.github.com/apiaryio/snowcrash/master/tools/homebrew/snowcrash.rb
$ curl --trace - --header "Content-Type: application/json" \
--request POST \
--data-binary "{ \"product\":\"1AB23ORM\", \"quantity\": 2 }" \
"http://curltraceparser.apiary.io/shopping-cart" \
| curl-trace-parser --blueprint \
| snowcrash
name:
@netmilk
netmilk / .travis.yml
Last active December 23, 2015 12:49
Travis dotfile for testing with DREDD
language: node_js
node_js:
- 0.8
- 0.10
before_install:
- npm install -g dredd
script: ./scripts/test
notifications:
email:
recipients:
@netmilk
netmilk / test
Created September 20, 2013 13:22
Script for testing Express.js backend API application written in Coffee with Dredd
#!/bin/sh
./node_modules/coffee-script/bin/coffee app.coffee &
sleep 1
PID=$!
dredd apiary.apib http://localhost:3000/
RESULT=$?
kill -9 $PID
exit $RESULT

FORMAT: X-1A

URI Parameters API

This API demonstrates & tests various URI parameter description.

PUT /1/{id}

  • Parameters

    • id ... id of a post
  • Response 204

@netmilk
netmilk / test
Created October 8, 2013 13:52
Shell script to run express app on background, run API test and, kill app and return exit status from the test runnure
#!/bin/sh
./node_modules/coffee-script/bin/coffee app.coffee &
sleep 5
PID=$!
dredd apiary.apib http://localhost:3000/
RESULT=$?
kill -9 $PID
exit $RESULT
@netmilk
netmilk / .travis.yml
Created October 8, 2013 14:02
Example Travis CI dotfile for testing APIs with Dredd
language: node_js
node_js:
- 0.8
- 0.10
before_install:
- npm install -g dredd
script: ./scripts/test
services:
- mongodb
before_script:
@netmilk
netmilk / apiary.md
Created October 8, 2013 14:08
Super simple example API Blueprint for testing REST APIs demo

FORMAT: X-1A

Machines API

The Example API for Dredd API Blueprint testing tool

Group Machines

Machines collection [/machines]