Giter VIP home page Giter VIP logo

blueprint-parser's Introduction

Apiary Blueprint Parser

A JavaScript parser of Apiary API blueprints.

Installation

Node.js

$ npm install apiary-blueprint-parser

Do not install the parser globally (using the -g option), otherwise you won’t be able to use the API.

Browser

Download the latest browser version of the parser.

Usage

In Node.js, require the module:

var ApiaryBlueprintParser = require("apiary-blueprint-parser");

In browser, include the browser version of the parser in your web page or application using the <script> tag. The parser will be available in the ApiaryBlueprintParser global object.

To parse an API blueprint, just call the parse method and pass the blueprint as a parameter. The method will return an object representing the parsed blueprint or throw an exception if the input is invalid:

var blueprint = ApiaryBlueprintParser.parse([
  "Root resource",
  "GET /",
  "< 200"
].join("\n"));

var resource = blueprint.sections[0].resources[0];
console.log(resource.description)     // prints "Root resource"
console.log(resource.method)          // prints "GET"
console.log(resource.url)             // prints "/"
console.log(resource.response.status) // prints "200"

See the src/ast.coffee file to get an idea about returned objects and their capabilities.

The exception thrown in case of error will contain offset, line, column, expected, found and message properties with more details about the error.

Compatibility

The parser should run well in the following environments:

  • Node.js 0.6.18+
  • IE 9+
  • Firefox
  • Chrome
  • Safari
  • Opera

The parser should also work in IE 8, but this is not fully tested because the test suite runs correctly only in IE 9+.

blueprint-parser's People

Contributors

almad avatar dmajda avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.