# raml-parser

> A RAML parser based on PyYAML written in CoffeScript and available for use as NodeJs module or in-browser.

Latest version **0.8.18** (published 2016-05-26) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install raml-parser
pnpm add raml-parser
yarn add raml-parser
bun add raml-parser
```

Provides the command `raml-parser`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.8.18 |
| Published | 2016-05-26 |
| First published | 2013-10-23 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 7 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 193 |
| Maintainers | aldobucchi, blakeembrey, dmartinezg, xaka |

## Links

- npm: https://www.npmjs.com/package/raml-parser
- Repository: https://github.com/raml-org/raml-js-parser
- Homepage: https://github.com/raml-org/raml-js-parser#readme
- Issues: https://github.com/raml-org/raml-js-parser/issues
- npm.io page: https://npm.io/package/raml-parser

## Dependencies (7)

- [q](https://npm.io/package/q.md) 0.9.7
- [got](https://npm.io/package/got.md) ~2.4.0
- [jju](https://npm.io/package/jju.md) ~1.2.0
- [pluralize](https://npm.io/package/pluralize.md) ~1.1.1
- [uritemplate](https://npm.io/package/uritemplate.md) ~0.3.4
- [object-assign](https://npm.io/package/object-assign.md) ^4.1.0
- [json-schema-ref-parser](https://npm.io/package/json-schema-ref-parser.md) ^3.1.2

## Recent versions

- 0.8.18 (latest) — 2016-05-26
- 0.8.17 — 2016-04-27
- 0.8.16 — 2016-03-31
- 0.8.15 — 2016-01-08
- 0.8.14 — 2015-11-22
- 0.8.12 — 2015-10-21
- 0.8.11 — 2015-05-02
- 0.8.10 — 2015-01-21
- 0.8.9 — 2014-12-29
- 0.8.8 — 2014-12-02
- 0.8.7 — 2014-04-15
- 0.8.6 — 2014-04-15
- 0.8.5 — 2013-12-23
- 0.8.4 — 2013-11-18
- 0.8.3 — 2013-11-08
- … 2 more at https://npm.io/package/raml-parser/versions

## README

# RAML Parser
[![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/raml-org/raml-js-parser?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

[![Build Status](https://travis-ci.org/raml-org/raml-js-parser.png)](https://travis-ci.org/raml-org/raml-js-parser)
[![Dependency Status](https://david-dm.org/raml-org/raml-js-parser.png)](https://david-dm.org/raml-org/raml-js-parser)

This is a JavaScript parser for [RAML](http://raml.org) version 0.8 as defined in the [0.8 RAML specification](https://github.com/raml-org/raml-spec/blob/master/raml-0.8.md)

A newer [version](https://github.com/raml-org/raml-js-parser-2) is now available as a beta. It supports RAML 1.0 as well as RAML 0.8.

### Contributing
If you are interested in contributing some code to this project, thanks! Please first [read and accept the Contributors Agreement](https://api-notebook.anypoint.mulesoft.com/notebooks#bc1cf75a0284268407e4).

To discuss this project, please use its [github issues](https://github.com/raml-org/raml-js-parser/issues) or the [RAML forum](http://forums.raml.org/).

## Usage for NodeJS

### Load

Loading a RAML file is as easy as follows:

```javascript
  var raml = require('raml-parser');

  raml.loadFile('myAPI.raml').then( function(data) {
    console.log(data);
  }, function(error) {
    console.log('Error parsing: ' + error);
  });
```

You can alternatively load from a string containing the api definition:

```javascript
  var raml = require('raml-parser');

  var definition = [
    '#%RAML 0.8',
    '---',
    'title: MyApi',
    'baseUri: http://myapi.com',
    '/Root:'
  ].join('\n');

  raml.load(definition).then( function(data) {
    console.log(data);
  }, function(error) {
    console.log('Error parsing: ' + error);
  });
```

The shape of the returned object is (unofficially) documented in this [Typescript interface](https://github.com/aldonline/raml-typescript).

### Abstract Syntax Tree

Generating an AST from a RAML file is as easy as follows:

```javascript
  var raml = require('raml-parser');

  var myAPI;
  raml.composeFile('myAPI.raml').then( function(rootNode) {
    console.log('Root Node: ' + rootNode)
  }, function(error) {
    console.log('Error parsing: ' + error);
  });
```

you can also alternatively generate an AST from a string containing the api definition:

```javascript
  var raml = require('raml-parser');

  var definition = [
    '#%RAML 0.8',
    '---',
    'title: MyApi',
    'baseUri: http://myapi.com',
    '/Root:'
  ].join('\n');

  raml.compose(definition).then( function(rootNode) {
    console.log('Root Node: ' + rootNode)
  }, function(error) {
    console.log('Error parsing: ' + error);
  });
```

## Usage for In-Browser

Using the RAML parser from inside the browser requires the user to actually
include the RAML javascript file in a script tag as follows:

```html
<script src="raml-parser.min.js"></script>
```

from there on the usage is pretty much the same as NodeJS, the script
defines a *RAML.Parser* object globally which can be used as follows:

```javascript
RAML.Parser.loadFile('http://localhost:9001/myAPI.raml').then( function(data) {
  console.log(data)
}, function(error) {
  console.log('Error parsing: ' + error);
});
```

Notice that the in-browser version can fetch remote API definitions via XHR.

---
_Source: https://npm.io/package/raml-parser · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
