Code Monkey home page Code Monkey logo

raml-generator's Introduction

RAML Generator

Greenkeeper badge

NPM version NPM downloads Build status Test coverage

Generate files from a RAML document and templates.

Installation

npm install raml-generator --save

Usage

The module accepts a map of functions (usually compiled templates, such as Handlebars), and returns a function that will generate files given an instance of the RAML 1 parser JSON.

For an example module, take a look at the raml-javascript-generator.

Why use this? It's just a simple, high level API for creating generators with a standard API.

JavaScript Usage

Create the generator function from config. The returned object accepts two arguments, the RAML object and user config.

var fs = require('fs')
var Handlebars = require('handlebars')
var generator = require('raml-generator')

module.exports = generator({
  templates: {
    'index.js': Handlebars.compile(fs.readFileSync(__dirname + '/templates/index.js.hbs', 'utf8'))
  }
}) //=> [Function]

Bin Script

A bin script is provided for you to use with your custom generator. Just require raml-generator/bin and pass in the generator function (from above), package information (package.json) and process.argv.

#!/usr/bin/env node

var bin = require('raml-generator/bin')

var generator = /* The generator function */

bin(generator, require('./package.json'), process.argv)

Generated CLI:

generator --out [directory]

  --data, -d     Path to JSON configuration file
  --include, -i  Include additional RAML files (E.g. extensions)

License

Apache License 2.0

raml-generator's People

Contributors

blakeembrey avatar greenkeeper[bot] avatar nachoesmite avatar sichvoge avatar svc-scm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

raml-generator's Issues

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because it uses your CI build statuses to figure out when to notify you about breaking changes.

Since we didn’t receive a CI status on the greenkeeper/initial branch, it’s possible that you don’t have CI set up yet. We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

If you have already set up a CI for this repository, you might need to check how it’s configured. Make sure it is set to run on all new branches. If you don’t want it to run on absolutely every branch, you can whitelist branches starting with greenkeeper/.

Once you have installed and configured CI on this repository correctly, you’ll need to re-trigger Greenkeeper’s initial pull request. To do this, please delete the greenkeeper/initial branch in this repository, and then remove and re-add this repository to the Greenkeeper App’s white list on Github. You'll find this list on your repo or organization’s settings page, under Installed GitHub Apps.

Provide a better README

The README is lacking quite a bit of detail to offer more examples and such of how to use raml-generator. It would be nice to show some content on how to use the handlebars templates, as well as using the RAML 1.0 JS parser to parse any RAML 1.0 document, how to navigate through libraries, types, and more.

mkdirp is required

If you create a project and include raml-generator/bin into it - you'll run into a dependency problem. mkdirp is missing. Adding it to your package.json should solve the issue. I'll create a pull request for it.

The final solution should look like:

"dependencies": {
    ...,
    "mkdirp": "^0.5.0"
  }

Support additional configuration file formats

We should be able to make use of existing "config" modules as support YAML and JS, not just JSON. YAML would provide a much more readable way to do long text configuration like descriptions, etc.

Include Schemas in raml context

Currently, the schemas defined in the root of a raml file, as well as schemas embedded within the raml file are not accessible in any way via the raml context object.

It would be ideal to have a allSchemas (like allResources) option that would be a flat list of all schema files. This should be some form of object though.. because in some cases the schemas are include files, and in others they are inlined. I'd argue against loading up all the include schemas into memory and work towards not using inlined schemas at all, but it is what it is now, so I'd urge that we keep the flat list that includes the type (inline or file) and the actual value (the path/file, or the string of inlined schema).

Then perhaps for each resource, we have the schema option so that as we iterate a resource, we can access the schema if need be (maybe this is there now? I haven't looked to see if that is possible).

Merge configuration objects

The generator should be able to set the default configuration object and have it extended with user options.

Document context object format

Right now it's discover it for yourself. I'd love to see some, even incomplete, documentation for the context object.

Update outdated raml-parser

Currently the raml-generator uses the version 0.1.x of the raml-1-parser

The most recent version is 1.1.4 which resolves a lot of issues especially with reference resolution inside json schemas.

I just had overwritten locally the used parser version using shrinkwrap.json and the generator is working with 1.1.4 as well as now correctly resolving json schema references without OOM exceptions.

Update to latest RAML 1.0

I see the last update was several months ago to over a year ago. It is not clear if this now supports the latest RAML 1.0 completely or not? Can I parse any RAML 1.0 document, including those with libraries, extensions and more? If not, what will it take to update this project to support RAML 1.0 completely?

Loading RAML spec fails

Loading the RAML fails as ramlParser.loadFile(argv[0]) takes the first argument argv[0] which usually is node. It has to be changed to ramlParser.loadFile(argv[2]) inside the raml-generator.js file.

Tag a new release candidate

With the recently merged pull request for the updated raml-parser, it would be good to also tag a new release candidate in order to be able to update down stream dependencies.

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because it uses your CI build statuses to figure out when to notify you about breaking changes.

Since we didn’t receive a CI status on the greenkeeper/initial branch, it’s possible that you don’t have CI set up yet. We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

If you have already set up a CI for this repository, you might need to check how it’s configured. Make sure it is set to run on all new branches. If you don’t want it to run on absolutely every branch, you can whitelist branches starting with greenkeeper/.

Once you have installed and configured CI on this repository correctly, you’ll need to re-trigger Greenkeeper’s initial pull request. To do this, please delete the greenkeeper/initial branch in this repository, and then remove and re-add this repository to the Greenkeeper App’s white list on Github. You'll find this list on your repo or organization’s settings page, under Installed GitHub Apps.

Cannot find module './lib/helpers'

If I execute my app using the raml-generator module - I get this exception:

Error: Cannot find module './lib/helpers'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/Users/christianmule/node_modules/raml-generator/raml-generator.js:4:18)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)

Can it be that it tries to find the module inside the execution folder?

Global install?

So, this is cool - but I was expecting a simple renderer that outputs the HTML/etc. Possibly a way to make this npm install -g raml-generator?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.