Skip to content

Commit 3bba52c

Browse files
committed
Add support for npm 3 module layout when loading swagger resources
Closes #40
1 parent 8ca88ae commit 3bba52c

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "node-red-node-swagger",
3-
"version": "0.1.5",
3+
"version": "0.1.6",
44
"description": "A set of tools for generating Swagger API documentation based on the HTTP nodes deployed in a flow",
55
"license": "Apache",
66
"repository": {
@@ -22,7 +22,7 @@
2222
"Cody Walker <[email protected]>"
2323
],
2424
"dependencies": {
25-
"swagger-ui": "2.1.3",
25+
"swagger-ui": "2.1.4",
2626
"i18next-client": "1.10.3"
2727
}
2828
}

swagger/swagger.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2015 IBM Corp.
2+
* Copyright 2015, 2016 IBM Corp.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -162,11 +162,15 @@ module.exports = function(RED) {
162162
}
163163

164164
RED.httpAdmin.get('/swagger-ui/reqs/i18next.min.js', function(req, res){
165-
var filename = path.join(__dirname , '../node_modules/i18next-client/i18next.min.js');
165+
var basePath = require.resolve('i18next-client');
166+
basePath = basePath.replace(/\/i18next.js$/,"");
167+
var filename = path.join(basePath,'i18next.min.js');
166168
sendFile(res,filename);
167169
});
168170
RED.httpAdmin.get('/swagger-ui/reqs/*', function(req, res){
169-
var filename = path.join(__dirname , '../node_modules/swagger-ui/dist', req.params[0]);
171+
var basePath = require.resolve('swagger-ui');
172+
basePath = basePath.replace(/\/swagger-ui.js$/,"");
173+
var filename = path.join(basePath, req.params[0]);
170174
sendFile(res,filename);
171175
});
172176
RED.httpAdmin.get('/swagger-ui/nls/*', function(req, res){

0 commit comments

Comments
 (0)