Skip to content

Commit 05d1a68

Browse files
author
Luis Fernando Planella Gonzalez
committed
NgModule still generated by default in 1.x
Fixes #373
1 parent 2706c4c commit 05d1a68

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

lib/ng-openapi-gen.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,11 @@ export class NgOpenApiGen {
404404
}
405405

406406
private setDefaults(): void {
407+
if (this.options.module === undefined) {
408+
this.options.module = false;
409+
} else if (this.options.module === true) {
410+
this.options.module = 'ApiModule';
411+
}
407412
if (!this.options.enumStyle) {
408413
this.options.enumStyle = 'alias';
409414
}

test/all-types.config.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@
33
"input": "all-types.json",
44
"output": "out/all-types/",
55
"indexFile": true,
6-
"enumStyle": "pascal"
6+
"enumStyle": "pascal",
7+
"module": "AllTypesModule",
8+
"services": true
79
}

test/all-types.spec.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -535,12 +535,11 @@ describe('Generation tests using all-types.json', () => {
535535
const parser = new TypescriptParser();
536536
parser.parseSource(ts).then(ast => {
537537
expect(ast.exports.length).toBe(5);
538-
expect(ast.exports.some((ex: NamedExport) => ex.from === './api-configuration')).toBeDefined();
539-
expect(ast.exports.some((ex: NamedExport) => ex.from === './base-service')).toBeDefined();
540-
expect(ast.exports.some((ex: NamedExport) => ex.from === './request-builder')).toBeDefined();
541-
expect(ast.exports.some((ex: NamedExport) => ex.from === './strict-http-response')).toBeDefined();
542-
expect(ast.exports.some((ex: NamedExport) => ex.from === './api.module')).toBeDefined();
543-
538+
expect(ast.exports.find((ex: NamedExport) => ex.from === './api-configuration')).toBeDefined();
539+
expect(ast.exports.find((ex: NamedExport) => ex.from === './base-service')).toBeDefined();
540+
expect(ast.exports.find((ex: NamedExport) => ex.from === './request-builder')).toBeDefined();
541+
expect(ast.exports.find((ex: NamedExport) => ex.from === './strict-http-response')).toBeDefined();
542+
expect(ast.exports.find((ex: NamedExport) => ex.from === './all-types.module')).toBeDefined();
544543
});
545544
});
546545
});

test/noModule.spec.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,10 @@ describe('Generation tests with index and no ApiModule', () => {
1818
const ts = gen.templates.apply('index', ref);
1919
const parser = new TypescriptParser();
2020
parser.parseSource(ts).then(ast => {
21-
expect(ast.exports.length).toBe(4);
21+
expect(ast.exports.length).toBe(3);
2222
expect(ast.exports.some((ex: NamedExport) => ex.from === './api-configuration')).toBeDefined();
23-
expect(ast.exports.some((ex: NamedExport) => ex.from === './base-service')).toBeDefined();
2423
expect(ast.exports.some((ex: NamedExport) => ex.from === './request-builder')).toBeDefined();
2524
expect(ast.exports.some((ex: NamedExport) => ex.from === './strict-http-response')).toBeDefined();
26-
2725
});
2826
});
2927

0 commit comments

Comments
 (0)