Skip to content

Commit

Permalink
upgrade to swagger-node-runner 0.7.0 to incorporate Sway 1.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
theganyo committed Aug 8, 2016
1 parent fcc8541 commit 22770c6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 71 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Middleware for Swagger projects
# Middleware for Open API (Swagger) projects

Check out [Swagger](https://www.npmjs.com/package/swagger) for all your Swagger utility
and Swagger-driven API project needs!
This middleware is used by the [Swagger](https://www.npmjs.com/package/swagger) project. It is designed to handle all your Open API-driven project needs with minimal fuss - and maximal flexibility.

### Important!
This is primarily a wrapper for the [swagger-node-runner](https://github.com/theganyo/swagger-node-runner) project. Be sure to follow that project and read the release notes there!
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "swagger-express-mw",
"version": "0.6.0",
"version": "0.7.0",
"description": "Swagger loader and middleware for express",
"keywords": [
"swagger",
Expand All @@ -16,7 +16,7 @@
"url": "https://github.com/apigee-127/swagger-express.git"
},
"dependencies": {
"swagger-node-runner": "^0.6.1"
"swagger-node-runner": "^0.7.0"
},
"devDependencies": {
"lodash": "^3.9.3",
Expand Down
66 changes: 0 additions & 66 deletions test/lib/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ var _ = require('lodash');

var SwaggerRunner = require('../..');

var DEFAULT_PROJECT_ROOT = path.resolve(__dirname, '..', 'assets', 'project');
var DEFAULT_PROJECT_CONFIG = { appRoot: DEFAULT_PROJECT_ROOT };

describe('index', function() {

describe('instantiation', function() {
Expand Down Expand Up @@ -66,68 +63,5 @@ describe('index', function() {
});
});
});

describe('config', function() {

var DEFAULT_CONFIG = {
swagger: {
appRoot: DEFAULT_PROJECT_ROOT,
validateResponse: true,
controllersDirs: [path.resolve(DEFAULT_PROJECT_ROOT, 'api/controllers')],
mockControllersDirs: [path.resolve(DEFAULT_PROJECT_ROOT, 'api/mocks')],
configDir: path.resolve(DEFAULT_PROJECT_ROOT, 'config')
}
};

it('should load default config', function(done) {

SwaggerRunner.create(DEFAULT_PROJECT_CONFIG, function(err, mw) {
should.not.exist(err);

mw.config.should.eql(DEFAULT_CONFIG);

done();
});
});

it('should load a specified config dir', function(done) {

var configDir = path.resolve(__dirname, '..', 'assets', 'config');
var config = _.cloneDeep(DEFAULT_PROJECT_CONFIG);
config.configDir = configDir;
SwaggerRunner.create(config, function(err, mw) {
should.not.exist(err);

var testConfig = _.cloneDeep(DEFAULT_CONFIG);
testConfig.swagger.configDir = configDir;
testConfig.test = true;

mw.config.should.eql(testConfig);

done();
});
});

it('should load swagger config from env vars', function(done) {

process.env['swagger_test'] = 'true';
process.env['swagger_test2_test3'] = '2';
SwaggerRunner.create(DEFAULT_PROJECT_CONFIG, function(err, mw) {
should.not.exist(err);

var testConfig = _.cloneDeep(DEFAULT_CONFIG);
testConfig.swagger.test = true;
testConfig.swagger.test2 = {
test3: 2
};

mw.config.should.eql(testConfig);

delete(process.env['swagger_test']);
delete(process.env['swagger_test2_test3']);
done();
});
});
});
});

0 comments on commit 22770c6

Please sign in to comment.