diff --git a/README.md b/README.md
index e8a6ec8dc..c7bcd7573 100644
--- a/README.md
+++ b/README.md
@@ -19,10 +19,11 @@ There is an online preview version of the API Designer, check it out a [differen
```
npm install -g api-designer
-api-designer
+api-designer --port=3000 --open-browser=true
```
This will start a local designer instance using the in-browser filesystem.
+This example shows the default values for `--port` and `--open-browser`
## Embedding
@@ -42,7 +43,7 @@ The following example details how to embed the API Designer:
diff --git a/bin/api-designer.js b/bin/api-designer.js
index 6252a9ec7..f056dc3cc 100755
--- a/bin/api-designer.js
+++ b/bin/api-designer.js
@@ -13,6 +13,12 @@ var argv = require('yargs')
describe: 'Port number to run the API designer',
type: 'number'
})
+ .option('o', {
+ alias: 'open-browser',
+ default: true,
+ describe: 'Automatically open the browser when server starts',
+ type: 'boolean'
+ })
.argv
var app = express()
@@ -21,7 +27,7 @@ app.use(express.static(join(__dirname, '../dist')))
app.use('/proxy', function (req, res, next) {
if (req.method.toUpperCase() === 'OPTIONS') {
- res.setHeader('Access-Control-Allow-Origin', '*')
+ res.setHeader('Access-Control-Allow-Origin', '*')
res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With')
return next()
}
@@ -40,7 +46,7 @@ app.use('/proxy', function (req, res, next) {
// Workaround for some remote services that do not handle
// multi-valued Accept header properly by omitting precedence
if (req.headers.accept) {
- req.headers.accept = req.headers.accept.split(',')[0].trim()
+ req.headers.accept = req.headers.accept.split(',')[ 0 ].trim()
}
// Pipe the request data directly into the proxy request and back to the
@@ -52,5 +58,7 @@ app.use('/proxy', function (req, res, next) {
app.listen(argv.p, function () {
console.log('API designer running on port ' + argv.p + '...')
- open('http://localhost:' + argv.p + '/')
+ if (argv.o) {
+ open('http://localhost:' + argv.p + '/')
+ }
})