Reverse generation RAML file


Assuming the I have justified scenario to build from some meta model again the Raml in-memory model structure in order to generate the flat raml file representation.

I have created very simple code to render me the raml content

	final Raml raml = .... load here RAML file via RamlDocumentBuilder

	final DumperOptions options = new DumperOptions();

	final Yaml yaml = new Yaml(options);
	final String output = yaml.dump(raml);

It looks like it generates ‘almost’ what i was expecting for e.g. (excuse the formatting issue)
I got the resources, actions attribute while I was expecting to have them anonymous

version : ...
baseUri : ...
resources :
    actions : 
        get :

While i was rather expecting more like

version : ..
baseUri : ...
      get : 

I know that I can deal low level with putting into model plain Maps (with String as the Key), Lists - but isn’t there more object oriented solution.


The Raml java parser includes a custom emitter that you can use like this:

final Raml raml = .... load here RAML file via RamlDocumentBuilder

RamlEmitter emitter = new RamlEmitter();
String dumpFromRaml = emitter.dump(raml); 


Thanks for That . I have already found it .