hapi-swagger
Advanced tools
Comparing version 0.0.6 to 0.1.1
@@ -50,5 +50,5 @@ var Hoek = require('hoek'), | ||
}, | ||
handler: function (request) { | ||
handler: function (request, reply) { | ||
var routes = request.server.routingTable(), | ||
var routes = (request.server.routingTable)? request.server.routingTable(): request.server.table(), | ||
resourceName = request.query.path; | ||
@@ -72,3 +72,3 @@ | ||
if (!routes.length) { | ||
return request.reply(Boom.notFound()); | ||
return reply(Boom.notFound()); | ||
} | ||
@@ -79,3 +79,5 @@ | ||
routes.sort(function (route1, route2) { | ||
return route1.path > route2.path; | ||
if (route1.path < route2.path) return -1; | ||
if (route1.path > route2.path) return 1; | ||
return 0; | ||
}); | ||
@@ -88,3 +90,3 @@ | ||
apiData.path = routes[0] ? routes[0].path : '/'; | ||
return request.reply(internals.buildAPIInfo( settings, apiData, request.query.path)).type('application/json; charset=utf-8'); | ||
return reply(internals.buildAPIInfo( settings, apiData, request.query.path)).type('application/json; charset=utf-8'); | ||
} | ||
@@ -94,3 +96,3 @@ | ||
// build documentation API discovery endpoint | ||
return request.reply(internals.buildAPIDiscovery( settings, routes )).type('application/json; charset=utf-8'); | ||
return reply(internals.buildAPIDiscovery( settings, routes )).type('application/json; charset=utf-8'); | ||
@@ -264,12 +266,26 @@ }, | ||
var param = params[key]; | ||
paramsData.push({ | ||
name: key, | ||
description: typeof param.description === 'function' ? '' : param.description, | ||
notes: typeof param.notes === 'function' ? '' : param.notes, | ||
tags: typeof param.tags === 'function' ? '' : param.tags, | ||
type: param.type, | ||
required: param.__modifiers && param.__modifiers._values ? param.__modifiers._values.some(internals.isRequiredParam) : null, | ||
allowedValues: param.__valids ? internals.getExistsValues(param.__valids._exists) : null, | ||
disallowedValues: param.__invalids ? internals.getExistsValues(param.__invalids._exists) : null | ||
}); | ||
if(param.describe){ | ||
// version 2.x of HAPI | ||
var describe = param.describe(); | ||
paramsData.push({ | ||
name: key, | ||
description: typeof param._description === 'function' ? '' : param._description, | ||
notes: typeof param._notes === 'function' ? '' : param._notes, | ||
tags: typeof param._tags === 'function' ? '' : param._tags, | ||
type: param._type, | ||
required: (describe.valids && describe.valids.indexOf(undefined) !== -1)? false : true | ||
}); | ||
}else{ | ||
// pre version 2.x of HAPI | ||
paramsData.push({ | ||
name: key, | ||
description: typeof param.description === 'function' ? '' : param.description, | ||
notes: typeof param.notes === 'function' ? '' : param.notes, | ||
tags: typeof param.tags === 'function' ? '' : param.tags, | ||
type: param.type, | ||
required: param.__modifiers && param.__modifiers._values ? param.__modifiers._values.some(internals.isRequiredParam) : null, | ||
}); | ||
} | ||
} | ||
@@ -276,0 +292,0 @@ return paramsData; |
{ | ||
"name": "hapi-swagger", | ||
"description": "A swagger documentation UI generator plugin for hapi", | ||
"version": "0.0.6", | ||
"version": "0.1.1", | ||
"author": "Glenn Jones", | ||
"repository": { | ||
"type" : "git", | ||
"url" : "http://github.com/glennjones/hapi-swagger.git" | ||
"repository": { | ||
"type": "git", | ||
"url": "http://github.com/glennjones/hapi-swagger.git" | ||
}, | ||
@@ -20,6 +20,6 @@ "main": "index", | ||
"dependencies": { | ||
"hoek": "0.8.x", | ||
"boom": "0.4.x", | ||
"joi": "0.3.x", | ||
"handlebars": "1.0.x" | ||
"handlebars": "1.0.x", | ||
"boom": "~2.0.0", | ||
"hoek": "~1.4.1", | ||
"joi": "~2.3.1" | ||
}, | ||
@@ -34,4 +34,4 @@ "devDependencies": { | ||
"peerDependencies": { | ||
"hapi": "1.x.x" | ||
"hapi": "~2.1.1" | ||
} | ||
} |
@@ -6,3 +6,5 @@ # hapi-swagger | ||
__UPDATED__: now works with version 2 of HAPI | ||
## Install | ||
@@ -25,3 +27,3 @@ | ||
server.pack.allow({ ext: true }).require('hapi-swagger', swaggerOptions, function (err) { | ||
server.pack.require('hapi-swagger', swaggerOptions, function (err) { | ||
if (!err && err !== null) { | ||
@@ -128,2 +130,4 @@ server.log(['error'], 'Plugin "hapi-swagger" load error: ' + err) | ||
* David Waterston (https://github.com/davidwaterston) | ||
* Jozz (https://github.com/jozzhart) | ||
* John Oliva (https://github.com/joliva) | ||
@@ -130,0 +134,0 @@ |
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
433990
6236
133
+ Addedboom@2.0.0(transitive)
+ Addedcryptiles@2.0.5(transitive)
+ Addedhapi@2.1.2(transitive)
+ Addedhoek@1.4.1(transitive)
+ Addediron@2.1.3(transitive)
+ Addedjoi@2.3.1(transitive)
+ Addedlru-cache@2.5.2(transitive)
+ Addedmultiparty@3.1.2(transitive)
+ Addednipple@2.5.6(transitive)
+ Addedqs@0.6.6(transitive)
+ Addedsemver@2.2.1(transitive)
- Removedalce@1.0.0(transitive)
- Removedboom@0.4.21.2.1(transitive)
- Removedconfidence@0.8.1(transitive)
- Removedcryptiles@1.0.1(transitive)
- Removedesprima@1.0.4(transitive)
- Removedestraverse@1.3.2(transitive)
- Removedhapi@1.20.0(transitive)
- Removedhawk@1.1.2(transitive)
- Removedhoek@0.8.50.9.11.5.2(transitive)
- Removediron@1.0.0(transitive)
- Removedjoi@0.3.62.9.0(transitive)
- Removedjoi-v1@1.2.5(transitive)
- Removedlru-cache@2.3.1(transitive)
- Removedmultiparty@3.0.0(transitive)
- Removedsemver@2.0.11(transitive)
- Removedsntp@1.0.9(transitive)
Updatedboom@~2.0.0
Updatedhoek@~1.4.1
Updatedjoi@~2.3.1