RAML is a language for modeling RESTful APIs. By design,
it does not enforce any style rules on how to consistently document APIs,
because not all projects will require the same level of rule enforcement.
However, it can often be useful to enforce uniform rules and standards across a
group of related APIs to ensure consistency and uniformity across multiple teams
or business units.
RAML Linter is a static analysis, linter-like,
utility that will enforce rules (optionally) on a given RAML document, ensuring
consistency and quality.
Contributing
- Fork this repository
git clone
npm install
npm run coverage
(optional)- Create a working branch
- Write code
- Submit Pull Request
Contributions
This project aims to maintain a high level of unit test code coverage. All pull
requests must be accompanied by appropriate test cases, and all tests must pass
in order to be considered for merge.
For detailed rules on contributions, please refer to CONTRIBUTING.md.
(npm
) Scripts
Below is a list of commands available via npm (package.json
).
npm run coverage
- runs all unit tests (Mocha) with code coverage (Istanbul)npm run doc
- generate documentation pages (JSDoc)npm run example
- runs a single example RAML document through the linternpm run hint
- static code analysis (JSHint)npm run lint
- static code analysis and code style linting (ESLint)npm run quality
- runs lint and coveragenpm test
- runs unit tests (Mocha)npm run test-w
- runs tests with additional flags, including --watch
Running
@TODO: example using the CLI
Using the Linter
There are two ways to use the RAML Linter. either as a library, or as a command
line utility.
Library
Using the library in code provides the most flexibility, including error
handling and the ability to parse the full results for: error
, warning
, and
info
log entries.
var ramllint = require('ramllint'),
ramlDocument = require('./path/to/api.raml');
ramllint(ramlDocument, function (results) {
// NOTE: results will only contain 'error' and will exclude 'warning' and 'info'
// to get an array of all log entries use: `ramllint.results()`
if (!results.length) {
// no errors, all rules are satisfied
} else {
// errors
}
});
Command Line
This is a work in progress.
ramllint src/api.raml
GH-Pages
Some information about the code is hosted on the gh-pages branch and served:
- Code Documentation
- Code Coverage Report
- Static Code Analysis