Skip to content
This repository was archived by the owner on Jan 31, 2025. It is now read-only.

Commit 6070fc2

Browse files
committed
Merge pull request #31 from tlivings/v2.0.0
Stores built routes under resource path, uses basePath as mountPath.
2 parents 8d536ab + 8e6156a commit 6070fc2

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

lib/expressroutes.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function expressroutes(router, options) {
2626
basepath = url.parse(resource.api.basePath);
2727
mountpath = basepath.pathname;
2828
resourcepath = utils.prefix(resource.api.resourcePath, '/');
29-
routes = options.routes[mountpath];
29+
routes = options.routes[resourcepath];
3030

3131
routes && router.get(docspath + resourcepath, function (req, res) {
3232
res.json(resource.api);

lib/index.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,18 @@ function swaggerize(options) {
2828
routes = {};
2929

3030
options.resources.forEach(function (resource) {
31-
var opts, basepath, mountpath;
31+
var opts;
3232

33-
basepath = url.parse(resource.api.basePath);
34-
mountpath = basepath.pathname;
35-
routes[mountpath] = [];
33+
resource.api.resourcePath = utils.prefix(resource.api.resourcePath, '/');
34+
routes[resource.api.resourcePath] = [];
3635

3736
opts = {
3837
api: resource.api,
3938
handlers: resource.handlers,
4039
basedir: options.basedir
4140
};
4241

43-
Array.prototype.push.apply(routes[mountpath], builder(opts));
42+
Array.prototype.push.apply(routes[resource.api.resourcePath], builder(opts));
4443
});
4544

4645
options.routes = routes;

0 commit comments

Comments
 (0)