Skip to content

Commit 7863fbe

Browse files
committed
fix: after release some bugs
1 parent 372a52c commit 7863fbe

File tree

5 files changed

+11
-19
lines changed

5 files changed

+11
-19
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ The hierarchical structure of the directory is converted to the hierarchical str
1515
yarn add -D @himenon/openapi-typescript-code-generator
1616
```
1717

18-
### デモ
18+
### DEMO
1919

2020
- [DEMO](./example/README.md)
2121

example/codegen.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@ import * as CodeGenerator from "../lib"; // = @himenon/openapi-typescript-code-g
44

55
const main = () => {
66
const params: CodeGenerator.Params = {
7-
version: "v3",
87
entryPoint: "./spec/openapi.yml",
98
enableValidate: true,
109
};
11-
fs.mkdirSync("test/code", { recursive: true });
1210
const code = CodeGenerator.generateTypeScriptCode(params);
1311
fs.writeFileSync("client.ts", code, { encoding: "utf-8" });
1412
};

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@
7575
"@types/json-schema": "7.0.6",
7676
"ajv": "7.0.3",
7777
"dot-prop": "6.0.1",
78-
"js-yaml": "4.0.0",
79-
"typescript": "4.1.3"
78+
"js-yaml": "4.0.0"
8079
},
8180
"devDependencies": {
8281
"@commitlint/cli": "11.0.0",
@@ -114,6 +113,9 @@
114113
"ts-node": "9.1.1",
115114
"yarn-deduplicate": "3.1.0"
116115
},
116+
"peerDependencies": {
117+
"typescript": "4.1.3"
118+
},
117119
"publishConfig": {
118120
"access": "public"
119121
},

scripts/testCodeGen.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import * as CodeGenerator from "../lib";
44

55
const main = () => {
66
const params: CodeGenerator.Params = {
7-
version: "v3",
87
entryPoint: "test/api.test.domain/index.yml",
98
log: {
109
validator: {

src/index.ts

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import * as Validator from "./Validator";
1010
export { Converter };
1111

1212
export interface Params {
13-
version: "v3";
1413
entryPoint: string;
1514
option?: Partial<Converter.v3.Option>;
1615
/** default: true */
@@ -20,23 +19,17 @@ export interface Params {
2019
};
2120
}
2221

23-
export const generateTypeScriptCode = ({ version, entryPoint, option, enableValidate = true, log }: Params): string => {
22+
export const generateTypeScriptCode = ({ entryPoint, option, enableValidate = true, log }: Params): string => {
2423
const schema = fileSystem.loadJsonOrYaml(entryPoint);
2524
const resolvedReferenceDocument = ResolveReference.resolve(entryPoint, entryPoint, JSON.parse(JSON.stringify(schema)));
2625

2726
if (enableValidate) {
2827
Validator.v3.validate(resolvedReferenceDocument, log && log.validator);
2928
}
3029

31-
switch (version) {
32-
case "v3": {
33-
const convertOption: Converter.v3.Option = option
34-
? { makeApiClient: option.makeApiClient || DefaultCodeTemplate.makeClientApiClient }
35-
: { makeApiClient: DefaultCodeTemplate.makeClientApiClient };
36-
const { createFunction, generateLeadingComment } = Converter.v3.create(entryPoint, schema, resolvedReferenceDocument, convertOption);
37-
return [generateLeadingComment(), TypeScriptCodeGenerator.generate(createFunction)].join(EOL + EOL + EOL);
38-
}
39-
default:
40-
return "UnSupport OpenAPI Version";
41-
}
30+
const convertOption: Converter.v3.Option = option
31+
? { makeApiClient: option.makeApiClient || DefaultCodeTemplate.makeClientApiClient }
32+
: { makeApiClient: DefaultCodeTemplate.makeClientApiClient };
33+
const { createFunction, generateLeadingComment } = Converter.v3.create(entryPoint, schema, resolvedReferenceDocument, convertOption);
34+
return [generateLeadingComment(), TypeScriptCodeGenerator.generate(createFunction)].join(EOL + EOL + EOL);
4235
};

0 commit comments

Comments
 (0)