-
Notifications
You must be signed in to change notification settings - Fork 2
/
generate-demo3.js
31 lines (24 loc) · 914 Bytes
/
generate-demo3.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const fs = require("fs");
const { CodeGenerator } = require("@himenon/openapi-typescript-code-generator");
const Templates = require("@himenon/openapi-typescript-code-generator/templates");
const main = () => {
const codeGenerator = new CodeGenerator("openapi.yml");
const apiClientGeneratorTemplate = {
generator: Templates.ApiClient.generator,
option: {},
};
const typeDefCode = codeGenerator.generateTypeDefinition();
const apiClientCode = codeGenerator.generateCode([
{
generator: () => {
return [`import { Schemas, Responses } from "./types";`];
},
},
codeGenerator.getAdditionalTypeDefinitionCustomCodeGenerator(),
apiClientGeneratorTemplate,
]);
fs.writeFileSync("demo3/types.ts", typeDefCode, { encoding: "utf-8" });
fs.writeFileSync("demo3/apiClient.ts", apiClientCode, { encoding: "utf-8" });
console.log("Generate demo3");
};
main();