Skip to content

Commit

Permalink
Pass info object
Browse files Browse the repository at this point in the history
Use `if` as Swagger UI will add extra padding if passed an empty object
  • Loading branch information
tlvince committed May 4, 2014
1 parent 47fef6a commit 388396c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ Configure {swagger-express} as express middleware.

`basePath` -> The basePath for swagger.js

`info` -> [Metadata][info] about the API

`apis` -> Define your api array.

`middleware` -> Function before response.
Expand All @@ -44,13 +46,20 @@ app.configure(function(){
swaggerJSON: '/api-docs.json',
swaggerUI: './public/swagger/',
basePath: 'http://localhost:3000',
info: {
title: 'swagger-express sample app',
description: 'Swagger + Express = {swagger-express}'
},
apis: ['./api.js', './api.yml'],
middleware: function(req, res){}
}));
app.use(app.router);
...
});
```
```

[info]: https://github.com/wordnik/swagger-spec/blob/master/versions/1.2.md#513-info-object

## Read from jsdoc

Example 'api.js'
Expand Down
4 changes: 4 additions & 0 deletions lib/swagger-express/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,10 @@ function generate(opt) {
descriptor.swaggerJSON = (opt.swaggerJSON) ? opt.swaggerJSON : '/api-docs.json';
descriptor.apis = [];

if(opt.info) {
descriptor.info = opt.info;
}

opt.apiVersion = descriptor.apiVersion;
opt.swaggerVersion = descriptor.swaggerVersion;
opt.swaggerURL = descriptor.swaggerURL;
Expand Down

0 comments on commit 388396c

Please sign in to comment.