Skip to content

Commit

Permalink
Beautify Code
Browse files Browse the repository at this point in the history
  • Loading branch information
chdanielmueller committed Jun 6, 2015
1 parent afed184 commit 824d1c1
Show file tree
Hide file tree
Showing 9 changed files with 215 additions and 214 deletions.
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
**/node_modules
lib/swagger-ui
lib/swagger-ui
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
"no-use-before-define": [2, "nofunc"],
"quotes": [2, "single"]
}
}
}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
.DS_Store
node_modules/
node_modules/
2 changes: 1 addition & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.DS_Store
.git*
example/
example/
26 changes: 13 additions & 13 deletions example/app.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
'use strict';

var express = require('express'),
routes = require('./routes'),
swagger = require('..');
routes = require('./routes'),
swagger = require('..');

var app = express();

swagger.init(app, {
apiDocs: '/api.json',
swaggerUi: '/api',
info: {
title: 'Hello World',
version: '1.0.0'
},
apis: ['./routes.js']
apiDocs: '/api.json',
swaggerUi: '/api',
info: {
title: 'Hello World',
version: '1.0.0'
},
apis: ['./routes.js']
});

routes.setup(app);

var server = app.listen(3000, function () {
var host = server.address().address;
var port = server.address().port;
var host = server.address().address;
var port = server.address().port;

console.log('Example app listening at http://%s:%s', host, port);
});
console.log('Example app listening at http://%s:%s', host, port);
});
22 changes: 11 additions & 11 deletions example/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,34 @@
*/
module.exports.setup = function (app) {

/**
* @swagger
/**
* @swagger
* /:
* get:
* responses:
* 200:
* description: hello world
*/
app.get('/', rootHandler);
*/
app.get('/', rootHandler);

/**
/**
* @swagger
* /login:
* post:
* responses:
* 200:
* description: login
*/
app.get('/login', loginHandler);
app.get('/login', loginHandler);
};

function rootHandler(req, res) {
res.send('Hello World!');
}

function loginHandler(req, res) {
var user = {};
user.username = req.param('username');
user.password = req.param('password');
res.json(user);
}
var user = {};
user.username = req.param('username');
user.password = req.param('password');
res.json(user);
}
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('./lib');
module.exports = require('./lib');
13 changes: 8 additions & 5 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ function parseApiFile(file) {

if (fileExtension === '.js') {
parseJsFile(file);
}
else {
} else {
throw new Error('Unsupported extension \'' + fileExtension + '\'.');
}
}
Expand All @@ -81,7 +80,9 @@ function parseApiFile(file) {
* @param {string} file - File to parse
*/
function parseJsFile(file) {
var sourceCode = fs.readFileSync(file, { encoding: 'utf8' });
var sourceCode = fs.readFileSync(file, {
encoding: 'utf8'
});
var jsDocComments = parseJsDoc(sourceCode);
var swaggerJsDocComments = filterSwaggerTags(jsDocComments);

Expand Down Expand Up @@ -110,7 +111,9 @@ function parseJsDoc(jsSourceCode) {
if (fragments) {
for (var i = 0; i < fragments.length; i++) {
var fragment = fragments[i];
var jsDoc = doctrine.parse(fragment, { unwrap: true });
var jsDoc = doctrine.parse(fragment, {
unwrap: true
});
jsDocs.push(jsDoc);
}
}
Expand All @@ -137,4 +140,4 @@ function filterSwaggerTags(jsDocs) {
}

return swaggerJsDocs;
}
}
Loading

0 comments on commit 824d1c1

Please sign in to comment.