RAML 1.0 JavaScript Parser

1.1.68 · deprecated · verified Tue Apr 21

The `fork-raml-1-parser` package is a JavaScript parser for RAML 0.8 and 1.0 API specifications. It reached its end-of-life and is officially deprecated as of its latest stable version, 1.1.68. Development on this package has ceased, with the recommendation to migrate to `@raml-org/webapi-parser` for ongoing support, security updates, and new features. While it ships with TypeScript types, providing better integration in typed environments, its primary quickstart examples and usage patterns often leverage CommonJS `require` syntax. Its release cadence was irregular towards its deprecation, primarily focusing on critical dependency and security fixes rather than new RAML specification features. A key differentiator was its ability to directly interpret RAML specification structures and produce a high-level Abstract Syntax Tree (AST), unlike generic YAML/JSON parsers.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to synchronously load and parse a local RAML 1.0 file using the `raml-1-parser` library.

const raml = require("raml-1-parser");
const fs = require('fs');
const path = require('path');

// Create a dummy RAML file for the example
const ramlFileName = path.join(__dirname, 'my-api.raml');
const ramlContent = `#%RAML 1.0\ntitle: My Example API\nversion: v1\nbaseUri: https://api.example.com`;
fs.writeFileSync(ramlFileName, ramlContent);

console.log(`Parsing RAML file: ${ramlFileName}`);

try {
  // The 'load' method can often work synchronously for local files.
  const apiJSON = raml.load(ramlFileName);
  console.log("Parsed RAML API JSON:");
  console.log(JSON.stringify(apiJSON, null, 2));
} catch (error) {
  console.error("Error parsing RAML file:", error);
}

// Clean up the dummy file
fs.unlinkSync(ramlFileName);

view raw JSON →