1.0.0 • Published 6 years ago

@ianwalter/peregrin v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
6 years ago

Peregrin

Toolkit for converting API Blueprint files to JSON and consuming that JSON

Installation

npm install @ianwalter/peregrin --save-dev

Usage

Example of generating API Blueprint JSON files using the CLI:

npx peregrin src/docs docs

  👍 Generated API Blueprint JSON!

Example of consuming an API Blueprint JSON file and asserting that one of the request properties has a certain value:

const Blueprint = require('@ianwalter/peregrin')

const accountJson = require('./docs/account.json')

const creatAccountRequest = new Blueprint(accountJson)
  .group('Account') // Returns the Resource Group named Account.
  .resource('/account') // Returns the Resource with a uriTemplate of /account.
  .action('POST') // Returns the Action with a method of POST.
  .example(0) // Returns the first example object.
  .request(0) // Returns the first request object in the example.
  .body() // Returns the JSON-parsed request body.

expect(creatAccountRequest.email).toEqual('user@test.io')