Skip to content

Instantly share code, notes, and snippets.

kolotoc:~ netmilk$ git clone git://github.com/apiaryio/snowcrash.git
Cloning into 'snowcrash'...
remote: Counting objects: 2090, done.
remote: Compressing objects: 100% (702/702), done.
remote: Total 2090 (delta 1434), reused 1965 (delta 1311)
Receiving objects: 100% (2090/2090), 951.94 KiB | 700.00 KiB/s, done.
Resolving deltas: 100% (1434/1434), done.
Checking connectivity... done
kolotoc:~ netmilk$ cd snowcrash
kolotoc:snowcrash netmilk$ git submodule update --init --recursive

My API

Fish [/fish]

Catch [GET]

  • Response 404

    Whip!

@netmilk
netmilk / git_tag_npm_versions.sh
Last active December 27, 2015 04:09
Oneliner used to find version bumps in package.json and output commands for tagging particular commits
#!/bin/bash
for i in `git log package.json | grep -e "^commit" | awk '{print $2}'`; do git diff $i^1 $i package.json 2>/dev/null | grep -e "\+ \"version\"" | sed s/,// | xargs echo $i | awk '{print "git tag -a v" $4 " " $1 " -m \"Bumped to version " $4 "\"" }'; done

FORMAT: 1A

HOST: http://www.google.com

Parameters API

In this installement of the API Blueprint tutorial we will discuss how to describe API parameters. But first let's add more messages to our system. For that we would need introduce an message identifier – id. This id will be our parameter when communicating with our API about messages.

API Blueprint Tutorial

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 February 13, 2015 15:42
Example for support of JSON schema draft v3 and v4 in Apiary

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)

FORMAT: 1A

Httpbin API

GET /ip

  • Response 200 (application/json)

       {
         "origin": "89.22.64.131"
       }
    
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

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 June 4, 2015 13:01
Example API with attributes
FORMAT: 1A
HOST: https://cryptic-badlands-8184.herokuapp.com/
# Life saving API
# Emergency [/912]
# Request first aid [POST]
+ Request (application/json)