Skip to content
This repository has been archived by the owner on Apr 11, 2018. It is now read-only.

Added server-mock executable with swagger-server-mock command #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions bin/swagger-server-mock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
var argv = require('yargs')
.usage('Usage: $0 <swagger_spec> [options]')
.command('swagger_spec', 'Path to swagger specification file (YAML or JSON)')
.demand(1)
.example('$0 swagger_spec -p 3000', 'Start mock server for swagger.yaml on port 3000')
.demand('p')
.alias('p', 'port')
.default('p', 3000)
.nargs('p', 1)
.describe('p', 'Port of mock server')
.help('h')
.alias('h', 'help')
.argv;

// Set the DEBUG environment variable to enable debug output
process.env.DEBUG = 'swagger:*';
process.chdir(__dirname);

// Create a Swagger Server app from the PetStore.yaml file
var swaggerServer = require('../lib/index.js');
var app = swaggerServer(argv._[0]);

var port = ((argv.p && Number.isInteger(argv.p)) ? argv.p : 3000);
app.listen(port, function() {
console.log('The Swagger mock is now running at http://localhost:' + port);
});
11 changes: 8 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
"name": "James Messinger",
"url": "http://jamesmessinger.com"
},
"bin": {
"swagger-server-mock": "bin/swagger-server-mock.js"
},
"license": "MIT",
"homepage": "https://github.com/BigstickCarpet/swagger-server",
"main": "lib/index.js",
Expand All @@ -30,7 +33,8 @@
"mocha": "mocha --bail --recursive tests",
"upgrade": "ncu --upgradeAll && npm update",
"bump": "bump --prerelease --tag --push --all",
"release": "npm run upgrade && npm run build && npm test && npm run bump && npm publish"
"release": "npm run upgrade && npm run build && npm test && npm run bump && npm publish",
"start": "node bin/swagger-server-mock.js"
},
"repository": {
"type": "git",
Expand All @@ -56,6 +60,7 @@
"express": "^4.13.3",
"lodash": "^3.10.1",
"swagger-express-middleware": ">=1.0.0-alpha.12",
"swagger-methods": "^1.0.0"
"swagger-methods": "^1.0.0",
"yargs": "^4.7.1"
}
}
}