Skip to content

Commit db5b2f6

Browse files
Merge pull request #38 from alessandrovaccaro/info-block
read info object from swaggerConfig.json
2 parents 16f3c93 + 168d3e0 commit db5b2f6

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,9 @@ export interface SwaggerConfig {
9292
* Possible values are `csv`, `ssv`, `tsv`, `pipes`, `multi`. If not specified, Swagger defaults to `csv`.
9393
*/
9494
collectionFormat?: string;
95+
96+
/**
97+
* Swagger Info block, if it exists will be used as Info section of the resulting swagger file.
98+
*/
99+
info?: any;
95100
}

src/swagger/generator.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,17 @@ export class SpecGenerator {
5959

6060
if (this.config.consumes) { spec.consumes = this.config.consumes; }
6161
if (this.config.produces) { spec.produces = this.config.produces; }
62-
if (this.config.description) { spec.info.description = this.config.description; }
63-
if (this.config.license) { spec.info.license = { name: this.config.license }; }
64-
if (this.config.name) { spec.info.title = this.config.name; }
65-
if (this.config.version) { spec.info.version = this.config.version; }
6662
if (this.config.host) { spec.host = this.config.host; }
6763

64+
if (this.config.hasOwnProperty('info')) {
65+
spec.info = this.config.info;
66+
} else {
67+
if (this.config.description) { spec.info.description = this.config.description; }
68+
if (this.config.license) { spec.info.license = { name: this.config.license }; }
69+
if (this.config.name) { spec.info.title = this.config.name; }
70+
if (this.config.version) { spec.info.version = this.config.version; }
71+
}
72+
6873
if (this.config.spec) {
6974
spec = require('merge').recursive(spec, this.config.spec);
7075
}

0 commit comments

Comments
 (0)