krakenjs / swaggerize-routes

Swagger document driven route builder.
Other
58 stars 57 forks source link

do not limit readhandlers to js / make it public #1

Open hans-d opened 10 years ago

hans-d commented 10 years ago

See:

These limit the require to only js files. Would be nice if, eg via an optional parameter, also other files could be included, eg coffee (only make extension configurable, being able to use coffee should be done outside this lib)

Perhaps even better if also the function could be made public, so that it could be used in construction of the handler object. Eg to do

swaggerize = require 'swaggerize-express'
builder = require 'swaggerize-builder'
yaml = require 'js-yaml'
fs = require 'fs'
_ = require 'lodash'

readApi = (file) ->
    raw = fs.readFileSync file
    yaml.safeLoad raw

buildHandler = (dir) ->
    _.merge {}, [
        builder.constructHandler dir, 'js'
        builder.constructHandler dir, 'coffee'
    ]

module.exports = (options) ->
    swaggerize
        api: readApi options.spec
        docspath: options.docUrl
        handlers: buildHandlers './controllers'
tlivings commented 10 years ago

Fair enough.

hans-d commented 10 years ago

flexible reader in #8