Skip to content

Instantly share code, notes, and snippets.

View apiary.apib
FORMAT: 1A
HOST: http://localhost
# example api
Is example api
# Group Users
Users related resources of the **Users API**
## Users Collection [/users]
@netmilk
netmilk / blueprint.md
Created Feb 13, 2015
Example for support of JSON schema draft v3 and v4 in Apiary
View blueprint.md

FORMAT: 1A

JSON Schema example API

API Exmample for demonstration of different versions of JSON schema

Valid schema v4 [/schema_v4_valid]

Create [POST]

  • Request (application/json)
View httpbin.md

FORMAT: 1A

Httpbin API

GET /ip

  • Response 200 (application/json)

       {
         "origin": "89.22.64.131"
       }
    
View ruby_dredd.md
kolotoc:dredd-rack-sinatra-example netmilk$ bundle exec rake blueprint:verify 
Verify the API conformance against its blueprint.
dredd doc/*.apib doc/*.apib.md  --hookfiles doc/hooks/hooks-worker-client.coffee

info: Beginning Dredd testing...
info: Found Hookfiles: doc/hooks/hooks-worker-client.coffee
Spawning ruby worker
Dredd Ruby hooks worker is running
View reveal_agenda.md

Testing reveal agenda

  • Failing Dredd transactions programatically in hooks
  • Dredd hooks chai integration
  • Headers values are tested only for content-negotiation headers
  • Dredd documentation & tutorials kickoff
  • Writing Dredd hooks in Ruby
  • "Cloud Dredd" production API testing - proof of concept
  • Libpcap based HTTP interceptor (a.k.a SHAIN)
@netmilk
netmilk / lifesaving.apib
Created Jun 4, 2015
Example API with attributes
View lifesaving.apib
FORMAT: 1A
HOST: https://cryptic-badlands-8184.herokuapp.com/
# Life saving API
# Emergency [/912]
# Request first aid [POST]
+ Request (application/json)
@netmilk
netmilk / apiary.apib
Last active Dec 15, 2015
Workaround for nullable MSON attributes in Dredd Ruby and Node.js hooks
View apiary.apib
# My API
# My Resource [/my_resource]
# Its Action [GET]
+ Response 200 (application/json)
+ Attributes (My Structure)
@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: */*