This is a Java parser for RAML version 0.8 as defined in the 0.8 RAML specification The parser depends on SnakeYAML, a Java YAML parser.
The version of this parser supporting RAML 1.0 is in the master branch.
mvn clean package
mvn clean package -P jar-with-dependencies
Run standalone validator
java -jar raml-parser-{version}.jar raml-file ...
In order to provide more flexibility, users can set different system properties when parsing different RAML files. Here we list all the system properties you can use right now:
Argument | Description | Default Value |
---|---|---|
raml.parser.encoding |
Defines the charset being used by the parser | UTF-8 |
raml.verifyRaml |
Verify the RAML file for YAML reference abuses | true |
raml.verifyReferenceCycle |
Specifically verify YAML reference cycles | true |
raml.maxDepth |
Limit depth of YAML references | 2000 |
raml.maxReferences |
Limit number of YAML references in expansions | 10000 |
The RAML parser's XML parsing components also respect Java XML entity properties.
The validator allows you to check whether a RAML resource is valid or not, and in the case is not valid it provides a List of validation results:
List<ValidationResult> results = RamlValidationService.createDefault().validate(ramlLocation);
The parser returns a Raml object and can be invoked using a String with the RAML file location:
Raml raml = new RamlDocumentBuilder().build(ramlLocation);
If you do any change to the Raml object model and you want to get the updated RAML descriptor you can use RamlEmitter class:
Raml raml = new RamlDocumentBuilder().build(ramlLocation);
// modify the raml object
RamlEmitter emitter = new RamlEmitter();
String dumpFromRaml = emitter.dump(raml);