@dazhicheng/openapi 1.1.3 → 1.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/cli.ts CHANGED
@@ -1,28 +1,28 @@
1
- #!/usr/bin/env node
2
-
3
- import chalk from "chalk";
4
- import { cosmiconfigSync } from "cosmiconfig";
5
- import { ttOpenAPI, GenerateServiceProps } from "./index";
6
-
7
- const explorerSync = cosmiconfigSync("openapi2ts");
8
- const searchedFor = explorerSync.search();
9
-
10
- async function run() {
11
- try {
12
- if (searchedFor?.config) {
13
- const configs: GenerateServiceProps[] = Array.isArray(searchedFor.config)
14
- ? searchedFor.config
15
- : [searchedFor.config];
16
-
17
- for (const config of configs) {
18
- await ttOpenAPI(config);
19
- }
20
- } else {
21
- throw new Error("config is not found");
22
- }
23
- } catch (error) {
24
- console.log(chalk.red(error));
25
- }
26
- }
27
-
28
- run();
1
+ #!/usr/bin/env node
2
+
3
+ import chalk from "chalk";
4
+ import { cosmiconfigSync } from "cosmiconfig";
5
+ import { ttOpenAPI, GenerateServiceProps } from "./index";
6
+
7
+ const explorerSync = cosmiconfigSync("openapi2ts");
8
+ const searchedFor = explorerSync.search();
9
+
10
+ async function run() {
11
+ try {
12
+ if (searchedFor?.config) {
13
+ const configs: GenerateServiceProps[] = Array.isArray(searchedFor.config)
14
+ ? searchedFor.config
15
+ : [searchedFor.config];
16
+
17
+ for (const config of configs) {
18
+ await ttOpenAPI(config);
19
+ }
20
+ } else {
21
+ throw new Error("config is not found");
22
+ }
23
+ } catch (error) {
24
+ console.log(chalk.red(error));
25
+ }
26
+ }
27
+
28
+ run();
package/src/index.ts CHANGED
@@ -8,7 +8,6 @@ import Log from "./log";
8
8
  import { mockGenerator } from "./mockGenerator";
9
9
  import { ServiceGenerator } from "./serviceGenerator";
10
10
  import type { APIDataType } from "./serviceGenerator";
11
- import fs from "fs";
12
11
 
13
12
  const getImportStatement = (requestLibPath: string) => {
14
13
  if (requestLibPath && requestLibPath.startsWith("import")) {
@@ -217,10 +216,6 @@ const getOpenAPIConfig = async (schemaPath: string, authorization?: string) => {
217
216
  if (!schema) {
218
217
  return null;
219
218
  }
220
- fs.writeFileSync("debug-output.json", JSON.stringify(schema, null, 2));
221
-
222
- // console.dir(schema, { depth: null });
223
-
224
219
  const openAPI = await converterSwaggerToOpenApi(schema);
225
220
  return openAPI;
226
221
  };