{"id":13433000,"url":"https://github.com/raml-org/raml-js-parser","last_synced_at":"2025-03-17T10:33:03.168Z","repository":{"id":9171312,"uuid":"10970624","full_name":"raml-org/raml-js-parser","owner":"raml-org","description":"(deprecated) A RAML parser based on PyYAML written in CoffeScript and available for use as NodeJs module or in-browser.","archived":true,"fork":false,"pushed_at":"2018-03-10T00:21:04.000Z","size":4161,"stargazers_count":195,"open_issues_count":22,"forks_count":53,"subscribers_count":36,"default_branch":"master","last_synced_at":"2024-05-21T21:04:42.671Z","etag":null,"topics":["javascript","nodejs","raml","raml-parser","raml-tooling"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/raml-org.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-06-26T14:49:42.000Z","updated_at":"2023-12-27T05:54:51.000Z","dependencies_parsed_at":"2022-07-07T22:41:36.107Z","dependency_job_id":null,"html_url":"https://github.com/raml-org/raml-js-parser","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raml-org%2Framl-js-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raml-org%2Framl-js-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raml-org%2Framl-js-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raml-org%2Framl-js-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/raml-org","download_url":"https://codeload.github.com/raml-org/raml-js-parser/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244016903,"owners_count":20384232,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","nodejs","raml","raml-parser","raml-tooling"],"created_at":"2024-07-31T02:01:19.621Z","updated_at":"2025-03-17T10:33:02.581Z","avatar_url":"https://github.com/raml-org.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","API Design Tooling"],"sub_categories":["RAML"],"readme":"# RAML Parser\n[![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/raml-org/raml-js-parser?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n\n[![Build Status](https://travis-ci.org/raml-org/raml-js-parser.png)](https://travis-ci.org/raml-org/raml-js-parser)\n[![Dependency Status](https://david-dm.org/raml-org/raml-js-parser.png)](https://david-dm.org/raml-org/raml-js-parser)\n\nThis 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)\n\nA 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.\n\n### Contributing\nIf 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).\n\nTo 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/).\n\n## Usage for NodeJS\n\n### Load\n\nLoading a RAML file is as easy as follows:\n\n```javascript\n  var raml = require('raml-parser');\n\n  raml.loadFile('myAPI.raml').then( function(data) {\n    console.log(data);\n  }, function(error) {\n    console.log('Error parsing: ' + error);\n  });\n```\n\nYou can alternatively load from a string containing the api definition:\n\n```javascript\n  var raml = require('raml-parser');\n\n  var definition = [\n    '#%RAML 0.8',\n    '---',\n    'title: MyApi',\n    'baseUri: http://myapi.com',\n    '/Root:'\n  ].join('\\n');\n\n  raml.load(definition).then( function(data) {\n    console.log(data);\n  }, function(error) {\n    console.log('Error parsing: ' + error);\n  });\n```\n\nThe shape of the returned object is (unofficially) documented in this [Typescript interface](https://github.com/aldonline/raml-typescript).\n\n### Abstract Syntax Tree\n\nGenerating an AST from a RAML file is as easy as follows:\n\n```javascript\n  var raml = require('raml-parser');\n\n  var myAPI;\n  raml.composeFile('myAPI.raml').then( function(rootNode) {\n    console.log('Root Node: ' + rootNode)\n  }, function(error) {\n    console.log('Error parsing: ' + error);\n  });\n```\n\nyou can also alternatively generate an AST from a string containing the api definition:\n\n```javascript\n  var raml = require('raml-parser');\n\n  var definition = [\n    '#%RAML 0.8',\n    '---',\n    'title: MyApi',\n    'baseUri: http://myapi.com',\n    '/Root:'\n  ].join('\\n');\n\n  raml.compose(definition).then( function(rootNode) {\n    console.log('Root Node: ' + rootNode)\n  }, function(error) {\n    console.log('Error parsing: ' + error);\n  });\n```\n\n## Usage for In-Browser\n\nUsing the RAML parser from inside the browser requires the user to actually\ninclude the RAML javascript file in a script tag as follows:\n\n```html\n\u003cscript src=\"raml-parser.min.js\"\u003e\u003c/script\u003e\n```\n\nfrom there on the usage is pretty much the same as NodeJS, the script\ndefines a *RAML.Parser* object globally which can be used as follows:\n\n```javascript\nRAML.Parser.loadFile('http://localhost:9001/myAPI.raml').then( function(data) {\n  console.log(data)\n}, function(error) {\n  console.log('Error parsing: ' + error);\n});\n```\n\nNotice that the in-browser version can fetch remote API definitions via XHR.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Framl-org%2Framl-js-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Framl-org%2Framl-js-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Framl-org%2Framl-js-parser/lists"}