cozumel

0.8.1 • Public • Published

Cozumel

NPM version

Installation

Cozumel requires node v7.10.1 or higher for ES6 and async function support.

yarn global add cozumel

or

npm install -g cozumel

Usage

cozumel [options] <path>

Options

Run this command to see a list of all available options:

cozumel -h

Mirror

Coming soon

The mirror mode will test the api definition against the provided host, it will measure the response time and report any errors that occurred in the process.

cozumel -m api.example.com <path>

Adapters

Currently supported adapters:

Feel free to add your own by opening a pull request.

Gist

cozumel <gist-id>

The gist adapter makes use of the other file adapters. In case you want to use a specific revision, you can do so by doing the following:

cozumel <gist-id>:<sha>

JSON

{
  "hello-world": {
    "GET": {
      "response": {
        "type": "json",
        "content": "{\"message\"\"hello world!\"}"
      }
    }
  }
}

YAML

hello-world:
  GET:
    response:
      type: json
      content: "{\"message\"\"hello world!\"}"

Markdown

Custom Adapter

import {Adapter, App} from "../core"
 
export class MyAdapter extends Adapter
{
  isMatch(key: string)
  {
    return /^ya?ml/i.test(key);
  }
 
  async load (app: App, data: string)
  {
    ...
    return data;
  }
}

Your adapter has to return an object like the following

{
  'users': {
    GET: {
      params: [
        { name: 'id', type: 'number', required: false }
      ],
      response: {
        type?: string,
        content?: string
      }
    },
 
    POST: {
      params: [
        { name: 'login', type: 'string', required: true },
        { name: 'password', type: 'string', required: true }
      ],
      response: {
        type?: string,
        content?: string
      }
    }
  },
  'users/block': {
    POST: {
      params: [
        { name: 'id', type: 'number', required: true }
      ],
      response: {
        type?: string,
        content?: string
      }
    }
  }
}

Package Sidebar

Install

npm i cozumel

Weekly Downloads

6

Version

0.8.1

License

MIT

Unpacked Size

196 kB

Total Files

63

Last publish

Collaborators

  • mauricetmeyer