Skip to content

Commit f67b41a

Browse files
committed
Move CodeGenerator to separate file
Making it clear that the abstraction is designed with purpose. mtennoe#106
1 parent e2925fc commit f67b41a

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

src/generators/codeGenerator.ts

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { CodeGenOptions } from "../options/options";
2+
import { ViewData } from "../getViewForSwagger2";
3+
4+
/**
5+
* Abstraction over a code generator.
6+
*/
7+
export interface CodeGenerator {
8+
/**
9+
* Returns the ViewData from the provided options.
10+
*
11+
* @param {CodeGenOptions} opts
12+
*
13+
* @returns {ViewData}
14+
*/
15+
getViewData(opts: CodeGenOptions): ViewData;
16+
17+
/**
18+
* Generate the code from the provided options.
19+
*
20+
* @param {CodeGenOptions} opts
21+
*
22+
* @returns {string}
23+
*/
24+
getCode(opts: CodeGenOptions): string;
25+
}

src/generators/swagger2.ts

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import { CodeGenOptions } from "../options/options";
22
import { transformToCodeWithMustache } from "../transform/transformToCodeWithMustache";
33
import { getViewForSwagger2, ViewData } from "../getViewForSwagger2";
4-
5-
interface CodeGenerator {
6-
getViewData(opts: CodeGenOptions): ViewData;
7-
getCode(opts: CodeGenOptions): string;
8-
}
4+
import { CodeGenerator } from "./codeGenerator";
95

106
function verifyThatWeAreGeneratingForSwagger2(opts: CodeGenOptions): void {
117
if (opts.swagger.swagger !== "2.0") {

0 commit comments

Comments
 (0)