Skip to content

Commit

Permalink
Add support for npm 3 module layout when loading swagger resources
Browse files Browse the repository at this point in the history
Closes #40
  • Loading branch information
knolleary committed Jun 22, 2016
1 parent 8ca88ae commit 3bba52c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-red-node-swagger",
"version": "0.1.5",
"version": "0.1.6",
"description": "A set of tools for generating Swagger API documentation based on the HTTP nodes deployed in a flow",
"license": "Apache",
"repository": {
Expand All @@ -22,7 +22,7 @@
"Cody Walker <[email protected]>"
],
"dependencies": {
"swagger-ui": "2.1.3",
"swagger-ui": "2.1.4",
"i18next-client": "1.10.3"
}
}
10 changes: 7 additions & 3 deletions swagger/swagger.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2015 IBM Corp.
* Copyright 2015, 2016 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -162,11 +162,15 @@ module.exports = function(RED) {
}

RED.httpAdmin.get('/swagger-ui/reqs/i18next.min.js', function(req, res){
var filename = path.join(__dirname , '../node_modules/i18next-client/i18next.min.js');
var basePath = require.resolve('i18next-client');
basePath = basePath.replace(/\/i18next.js$/,"");
var filename = path.join(basePath,'i18next.min.js');
sendFile(res,filename);
});
RED.httpAdmin.get('/swagger-ui/reqs/*', function(req, res){
var filename = path.join(__dirname , '../node_modules/swagger-ui/dist', req.params[0]);
var basePath = require.resolve('swagger-ui');
basePath = basePath.replace(/\/swagger-ui.js$/,"");
var filename = path.join(basePath, req.params[0]);
sendFile(res,filename);
});
RED.httpAdmin.get('/swagger-ui/nls/*', function(req, res){
Expand Down

0 comments on commit 3bba52c

Please sign in to comment.