• This repository has been archived on 13/Feb/2022
  • Stars
    star
    195
  • Rank 199,374 (Top 4 %)
  • Language
    JavaScript
  • Created over 11 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

RAML Parser

![Gitter](https://badges.gitter.im/Join Chat.svg)

Build Status Dependency Status

This is a JavaScript parser for RAML version 0.8 as defined in the 0.8 RAML specification

A newer version 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.

To discuss this project, please use its github issues or the RAML forum.

Usage for NodeJS

Load

Loading a RAML file is as easy as follows:

  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:

  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.

Abstract Syntax Tree

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

  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:

  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:

<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:

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.

More Repositories

1

raml-spec

RAML Specification
3,867
star
2

raml-php-parser

Community-maintained RAML parser for php
PHP
200
star
3

raml-examples

This repository contains valid RAML 1.0 examples. These examples are not only part of the spec, but also represent RAML features in different scenarios.
RAML
191
star
4

raml-java-parser

(deprecated) A RAML parser based on SnakeYAML written in Java
Java
174
star
5

raml-js-parser-2

(deprecated)
RAML
138
star
6

webapi-parser

API Spec parser based on AMF. Currently supports RAML 0.8, RAML 1.0, OAS 2.0 and OAS 3.0(beta).
Scala
68
star
7

ramldt2jsonschema

CLI & Library to convert a RAML 1.0 data type to a JSON Schema, and back
JavaScript
59
star
8

api-modeling-framework

DEPRECATED - This project has been moved
Clojure
27
star
9

raml-dotnet-parser

Community-maintained .NET parser for RAML
C#
22
star
10

raml-java-parser-2

JavaScript
19
star
11

raml-dotnet-parser-2

RAML
18
star
12

raml-typesystem

(deprecated) Typescript implementation of RAML type system
TypeScript
15
star
13

raml-org

Project website
SCSS
14
star
14

raml-cli

A handy command-line tool for RAML enthusiasts.
TypeScript
11
star
15

raml-tutorial-08

DEPRECATED - This repository contains the content for the RAML tutorial on raml.org.
9
star
16

playground

RAML Playground (WIP)
TypeScript
8
star
17

raml-tck

Test Compatibility Kit for RAML 1.0
RAML
8
star
18

raml-by-example

Series of examples leveraging tools of the RAML community
RAML
6
star
19

datatype-expansion

(deprecated) Utility tool to expand a given RAML type and create a canonical form
JavaScript
6
star
20

raml-definition-system

(deprecated) Definition System for RAML 0.8/1.0
TypeScript
3
star
21

raml-annotations

This repository contains a number of annotations that we, as a community, agreed on and share for others to use.
RAML
2
star
22

raml-tck-runner

Run several RAML parsers against RAML TCK
JavaScript
1
star