Skip to content

Instantly share code, notes, and snippets.

@netmilk
netmilk / curl_trace_format
Created Jul 21, 2013
Example cUrl trace from command: curl -s -o /dev/null --trace tracefile http://httpbin.org/headers
View curl_trace_format
== 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
View curl-trace-parser-post-example
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: */*
View curl-trace-to-blueprint
$ 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 Dec 23, 2015
Travis dotfile for testing with DREDD
View .travis.yml
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 Sep 20, 2013
Script for testing Express.js backend API application written in Coffee with Dredd
View test
#!/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
View query_parameters.md

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 Oct 8, 2013
Shell script to run express app on background, run API test and, kill app and return exit status from the test runnure
View test
#!/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 Oct 8, 2013
Example Travis CI dotfile for testing APIs with Dredd
View .travis.yml
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 Oct 8, 2013
Super simple example API Blueprint for testing REST APIs demo
View apiary.md

FORMAT: X-1A

Machines API

The Example API for Dredd API Blueprint testing tool

Group Machines

Machines collection [/machines]