Skip to content

Instantly share code, notes, and snippets.

View netmilk's full-sized avatar

Adam Kliment netmilk

View GitHub Profile
@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
HOST: http://localhost
# example api
Is example api
# Group Users
Users related resources of the **Users API**
## Users Collection [/users]

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

@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

My API

Fish [/fish]

Catch [GET]

  • Response 404

    Whip!

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
@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]

@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 / 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

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