mulesoft / osprey-cli

The Command Line Interface (CLI) scaffolding tool to generate Osprey-based applications, ideally from a pre-defined RAML API spec, with just a single command.
Other
18 stars 8 forks source link

There should be a command line command that lists all routes in the project #41

Closed dmartinezg closed 10 years ago

dmartinezg commented 10 years ago

running something like apikit-node routes should print something like:

GET /resources
POST /resources
GET /resources/{resourceId}
...
dmartinezg commented 10 years ago

Something like this:

raml.loadFile('api.raml').then( function(data) {
  printResources(data.resources, '');
}, function(error) {
  console.log('Error parsing: ' + error);
});

function printResources (resources, resourceUri) {
  if (!!resources) {
    resources.forEach(function(resource){
      var relativeUri = resourceUri + resource.relativeUri;
      resource.methods.forEach(function(method){
        console.log(method.method.toUpperCase() + "             " + relativeUri);
      });
      if(!!resource.resources) {
        printResources(resource.resources, relativeUri);
      }
    });
  }
}
jcenturion commented 10 years ago

Thanks for Code Snippets