swaggerize-routes
Advanced tools
Comparing version 1.0.9 to 1.0.10
@@ -0,1 +1,6 @@ | ||
### 1.0.10 | ||
- Fallback security to root api if missing in verb or path specification #62 | ||
- `defaulthandler` option to override the handler file of a route to use a common handler for all the routes. #71 | ||
### 1.0.9 | ||
@@ -2,0 +7,0 @@ |
@@ -16,6 +16,7 @@ 'use strict'; | ||
function buildroutes(options) { | ||
var api, routes, handlers, validator; | ||
var api, routes, handlers, defaulthandler, validator; | ||
api = options.api; | ||
handlers = readhandlers(options.handlers); | ||
defaulthandler = options.defaulthandler; | ||
validator = validation(options); | ||
@@ -41,5 +42,5 @@ routes = []; | ||
method: verb, | ||
security: buildSecurity(options, api.securityDefinitions, operation.security || def.security), | ||
security: buildSecurity(options, api.securityDefinitions, operation.security || def.security || api.security), | ||
validators: [], | ||
handler : undefined, | ||
handler : defaulthandler || undefined, | ||
consumes: operation.consumes || api.consumes, | ||
@@ -78,3 +79,5 @@ produces: operation.produces || api.produces, | ||
route.handler = handlers && (pathnames[0] ? matchpath('$' + verb, pathnames, handlers[pathnames[0]]) : handlers['$' + verb]); | ||
if (!route.handler) { | ||
route.handler = handlers && (pathnames[0] ? matchpath('$' + verb, pathnames, handlers[pathnames[0]]) : handlers['$' + verb]); | ||
} | ||
@@ -81,0 +84,0 @@ if (!route.handler) { |
{ | ||
"name": "swaggerize-routes", | ||
"version": "1.0.9", | ||
"version": "1.0.10", | ||
"author": "Trevor Livingston <trlivingston@paypal.com>", | ||
"contributors": [ | ||
"Trevor Livingston <trlivingston@paypal.com>", | ||
"Subeesh Chothendavida <subeeshcbabu@yahoo.co.in>" | ||
{ | ||
"name": "Francois-Guillaume Ribreau", | ||
"email": "npm@fgribreau.com", | ||
"url": "http://fgribreau.com/" | ||
} | ||
], | ||
@@ -19,7 +22,2 @@ "description": "Swagger based route building.", | ||
}, | ||
"contributors":[{ | ||
"name" : "Francois-Guillaume Ribreau", | ||
"email" : "npm@fgribreau.com", | ||
"url" : "http://fgribreau.com/" | ||
}], | ||
"dependencies": { | ||
@@ -26,0 +24,0 @@ "caller": "^1.0.1", |
@@ -33,2 +33,3 @@ swaggerize-routes (formerly swaggerize-builder) | ||
- `handlers` - either a directory structure for route handlers or a premade object (see *Handlers Object* below). | ||
- `defaulthandler` - a handler function appropriate to the target framework, if used this will be the default handler for all generated routes (see *Default handler* below). | ||
- `basedir` - base directory to search for `handlers` path (defaults to `dirname` of caller). | ||
@@ -114,3 +115,3 @@ - `schemas` - an array of `{name: string, schema: string|object}` representing additional schemas to add to validation. | ||
If the `options.handlers` is empty, then they will be used exclusively. | ||
If the `options.handlers` and `options.defaulthandler` is empty, then they will be used exclusively. | ||
@@ -167,2 +168,16 @@ ### Handlers File | ||
### Default handler | ||
The `options.defaulthandler` will set the handler function for all generated routes to one default handler. | ||
``` javascript | ||
var routes = builder({ | ||
api: require('./api.json'), | ||
defaulthandler: function (req, reply) { | ||
reply('something'); | ||
} | ||
}); | ||
``` | ||
### Route Object | ||
@@ -169,0 +184,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
31159
554
273
0