Skip to content

Commit 388396c

Browse files
committed
Pass info object
Use `if` as Swagger UI will add extra padding if passed an empty object
1 parent 47fef6a commit 388396c

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

README.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ Configure {swagger-express} as express middleware.
2828

2929
`basePath` -> The basePath for swagger.js
3030

31+
`info` -> [Metadata][info] about the API
32+
3133
`apis` -> Define your api array.
3234

3335
`middleware` -> Function before response.
@@ -44,13 +46,20 @@ app.configure(function(){
4446
swaggerJSON: '/api-docs.json',
4547
swaggerUI: './public/swagger/',
4648
basePath: 'http://localhost:3000',
49+
info: {
50+
title: 'swagger-express sample app',
51+
description: 'Swagger + Express = {swagger-express}'
52+
},
4753
apis: ['./api.js', './api.yml'],
4854
middleware: function(req, res){}
4955
}));
5056
app.use(app.router);
5157
...
5258
});
53-
```
59+
```
60+
61+
[info]: https://github.com/wordnik/swagger-spec/blob/master/versions/1.2.md#513-info-object
62+
5463
## Read from jsdoc
5564

5665
Example 'api.js'

lib/swagger-express/index.js

+4
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,10 @@ function generate(opt) {
235235
descriptor.swaggerJSON = (opt.swaggerJSON) ? opt.swaggerJSON : '/api-docs.json';
236236
descriptor.apis = [];
237237

238+
if(opt.info) {
239+
descriptor.info = opt.info;
240+
}
241+
238242
opt.apiVersion = descriptor.apiVersion;
239243
opt.swaggerVersion = descriptor.swaggerVersion;
240244
opt.swaggerURL = descriptor.swaggerURL;

0 commit comments

Comments
 (0)