diff --git a/lib/expressroutes.js b/lib/expressroutes.js index 77b9f1a..024b6de 100644 --- a/lib/expressroutes.js +++ b/lib/expressroutes.js @@ -26,7 +26,7 @@ function expressroutes(router, options) { basepath = url.parse(resource.api.basePath); mountpath = basepath.pathname; resourcepath = utils.prefix(resource.api.resourcePath, '/'); - routes = options.routes[mountpath]; + routes = options.routes[resourcepath]; routes && router.get(docspath + resourcepath, function (req, res) { res.json(resource.api); diff --git a/lib/index.js b/lib/index.js index 0e6ba65..c8b7b32 100644 --- a/lib/index.js +++ b/lib/index.js @@ -28,11 +28,10 @@ function swaggerize(options) { routes = {}; options.resources.forEach(function (resource) { - var opts, basepath, mountpath; + var opts; - basepath = url.parse(resource.api.basePath); - mountpath = basepath.pathname; - routes[mountpath] = []; + resource.api.resourcePath = utils.prefix(resource.api.resourcePath, '/'); + routes[resource.api.resourcePath] = []; opts = { api: resource.api, @@ -40,7 +39,7 @@ function swaggerize(options) { basedir: options.basedir }; - Array.prototype.push.apply(routes[mountpath], builder(opts)); + Array.prototype.push.apply(routes[resource.api.resourcePath], builder(opts)); }); options.routes = routes;