RAML to angular2 services and type script objects Code Generator


#1

I’m newbie to RAML, I am looking some code generator tool to generate angular2 compatible type scripts from RAML.

/notices:
  get:
    description: Returns all active notices for the compartment for the user
  responses:
      200 :
        body:
          application/json:
            schema: notices
            example: !include examples/notices-example.json

For the above RAML need to generate a type script service method

 noticeService.prototype.getAll = function () {
        return this.http
            .get(this.baseUrl + 'notices', { headers: this.getHeaders() })
            .map(function (res) { return res.json(); })
            .catch(handleError);
    };

and from schema

{
"required": true,
"$schema": "http://json-schema.org/draft-03/schema",
"type": "object",
"properties": {
    "notice_id": {
        "description":"Id will be ignored during post",
        "type": "string",
        "required": true
    },
    "orgin_compartment": {
        "type": "string",
        "required": true
      } 
  }
} 

need to gernerate a TypeScript POJO Model like

  export class Notice{
     notice_id: string;
     orgin_compartment;
  }

Is there any existing code generator api available for RAML.


#2

The very Javascript library that the Atom IDE with RAML plugin uses is available for you to use to parse RAML with. I dont have the link to it, but it is on the RAML projects page. It is pretty full featured with RAML 1.0 support I believe. Give it a look see, see if that fits your needs.