Reverse generation RAML file


#1

HI,
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);
	System.out.println("========");
	System.out.println(output);
	System.out.println("========");

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 :
  /somePath
    actions : 
        get :

While i was rather expecting more like

version : ..
baseUri : ...
    /somePath:
      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.


#2

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); 

#3

Thanks for That . I have already found it .