RAML to WADL programmatically using JAVA langauge


Hi ,

For Integration with legacy systems i need to convert RAML to WADL . I am new to RAML and going through RAML documentation .

Is there any framework available to accomplish this ?

Since i could not find one, thought of parsing RAML in JAVA. Luckily found a JAVA parser in “http://raml.org/projects.html” that already does the job and provides RAML object .

How can i obtain jar for “raml-java-parser” to include in my project?



Hi @Paul - you can generate it via Maven. The github repository + README should give the hints on how you do it. For a fully packed jar with all the dependencies you have to run

mvn clean package -P jar-with-dependencies

You can find the jar in the produced target folder.


Thank you for the quick reply , yes i did it and on my way to parse my first RAML file :blush:


Great - let me know if there is anything else I can help with :wink:


After including the jar in my project , i used the below code to convert it raml object.

String ramlLocation = "\\Sample1.raml";
Raml raml = new RamlDocumentBuilder().build(ramlLocation);

It Gives me below exception

Exception in thread "main" java.lang.NullPointerException
	at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1792)
	at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1769)
	at org.apache.commons.io.IOUtils.copy(IOUtils.java:1744)
	at org.apache.commons.io.IOUtils.toByteArray(IOUtils.java:462)
	at org.raml.parser.utils.StreamUtils.reader(StreamUtils.java:45)
	at org.raml.parser.visitor.YamlDocumentBuilder.build(YamlDocumentBuilder.java:102)
	at org.raml.parser.visitor.YamlDocumentBuilder.build(YamlDocumentBuilder.java:78)
at com.avia.parser.RamlParser.main(RamlParser.java:11)

I am using the below raml.

#%RAML 1.0
title: Example of a RAML 1.0 API
version: v1
baseUrl: http://api.example.com/{version}                # candidate #72
mediaType: application/json
types:                                                   # candidate #96
    validationPattern: ^\w{16}$                          # candidate #97
    type: file
    fileTypes: [ 'text/plain', 'text/richtext' ]         # candidate #94
    maximumLength: 1048576                               # candidate #94
    type: file
    fileTypes: [ 'image/jpeg', 'image/png' ]             # candidate #94
    maximumLength: 10485760                              # candidate #94
        description: filter by name
        description: filter by email
        description: filter by the given custom property # candidate #79
      schema:                                            # candidate #116
        type: json-schema/draft-04                       # candidate #81, #107
          type: object
              type: string
              type: string
              type: string
              format: date-time
          required: [ name, email ]
      examples:                                          # candidate #107
        minimal:                                         # candidate #116
          name: James Bonde
          email: james.bonde@example.com
        full:                                            # candidate #116
          name: James Bonde
          email: james.bonde@example.com
          birthday: 11-11-1920
      displayName: Update                                # candidate #74
                type: textDocument                       # candidate #96
                type: largeImage                         # candidate #96


Can you check if you point to the correct file path! If the RAML file is in the project folder of your Java project (the running directory) - you could try Sample1.raml w/o the leading \\


One thing i have to mention here is my project is a standalone java project , it not deployed on web/app server.
The file path is correct, below code printed the proper file name.

File f = new File(ramlLocation);


the below API works .

new RamlDocumentBuilder().build(Reader content, String resourceLocation);

When i validate the raml file using

String ramlLocation = "D:\\CodeCafe\\ParseRAML\\RamlFiles\\Sample1.raml";
File f = new File(ramlLocation);
FileReader fr = new FileReader(f);
List<ValidationResult> results = RamlValidationService.createDefault().validate(fr , ramlLocation);

I get below validation errors

ValidationResult{level=ERROR, message='Unknown key: baseUrl'}
ValidationResult{level=ERROR, message='Unknown key: validationPattern'}

But Online yaml parser works fine Online Yaml Parser


Hi Just figured out that the java parser complains if there is a comment along side the definition like below.

baseUrl: http://api.example.com/{version}                # candidate #72
mediaType: application/json
types:                                                   # candidate #96
    validationPattern: ^\w{16}$                          # candidate #97

So all the lines having " # candidate #xx" throws error :flushed:


@christian_vogel thank you for the hint.


Thanks @Paul - I think I know what your problem is about. You’re using language styles which WILL be available in 1.0. The current version of RAML is 0.8 and all parsers working based on it. All the lines with the candidate comment are actually new updates and not yet implemented. Please use the http://raml.org/spec and http://raml.org/docs.html to see examples of the current version. :wink:


Awesome , thank you for that clarification on versions.


QQ to avoid future confusion: Where did you get the RAML code?


I downloaded it from git hub https://github.com/svacas/raml-java-parser . I believe its the right one , please point out if theirs some other official java RAML parser.


@Paul: What I mean is the RAML spec with 1.0 and where you got it. Not the parser code :wink:


It was from this forum , You had provided a sample . it is here


OK cool - this post was initially made bc someone ask about the new features :wink: thanks Paul



I see @christian_vogel already got back to you but was going to tell you the current RAML parser only works for .8. I am still waiting with baited breath for any info regarding the 1.0 spec, when it will be ready and when RAML parser, JS parser, etc will support 1.0!! I am also hoping they will add the “relations” capability to support HATEOAS based links and such in 1.0 so that existing HATEOAS based APIs might have a chance to convert to using RAML.

If you have other questions, I’ll try to help as well as I am using the RAML java object myself.


Thank you @justjacksonn , i am still at the novice stage of parsing RAML , it would be helpful if you could share a comprehensive raml. I am looking at some samples provide in mulesoft apiplatform which @christian_vogel pointed out .but could not resolve the dependencies like schema includes , due to which the Java parser fails.


Hi @Paul - please see those two examples:


They are made by MuleSoft again. Simple download them as they don’t have any includes as far as I know.