@hey-api/openapi-ts 0.58.0 → 0.59.1
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/README.md +2 -2
- package/bin/index.cjs +23 -11
- package/dist/index.cjs +63 -60
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +71 -32
- package/dist/index.d.ts +71 -32
- package/dist/index.js +58 -57
- package/dist/index.js.map +1 -1
- package/package.json +19 -19
package/README.md
CHANGED
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
|
|
11
11
|
- works with CLI, Node.js 18+, or npx
|
|
12
12
|
- supports OpenAPI 2.0, 3.0, and 3.1 specifications
|
|
13
|
-
- supports
|
|
14
|
-
- generates TypeScript interfaces
|
|
13
|
+
- supports JSON and YAML input files
|
|
14
|
+
- generates TypeScript interfaces and SDKs
|
|
15
15
|
- Fetch API, Axios, Angular, Node.js, and XHR clients available
|
|
16
16
|
- plugin ecosystem to reduce third-party boilerplate
|
|
17
17
|
|
package/bin/index.cjs
CHANGED
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
const { resolve } = require('path');
|
|
5
|
+
const path = require('path');
|
|
7
6
|
|
|
8
7
|
const { program } = require('commander');
|
|
9
8
|
const pkg = require('../package.json');
|
|
@@ -16,7 +15,7 @@ const params = program
|
|
|
16
15
|
'-c, --client <value>',
|
|
17
16
|
'HTTP client to generate [@hey-api/client-axios, @hey-api/client-fetch, legacy/angular, legacy/axios, legacy/fetch, legacy/node, legacy/xhr]',
|
|
18
17
|
)
|
|
19
|
-
.option('-d, --debug', '
|
|
18
|
+
.option('-d, --debug', 'Set log level to debug')
|
|
20
19
|
.option('--dry-run [value]', 'Skip writing files to disk?')
|
|
21
20
|
.option(
|
|
22
21
|
'-e, --experimental-parser [value]',
|
|
@@ -27,12 +26,14 @@ const params = program
|
|
|
27
26
|
'-i, --input <value>',
|
|
28
27
|
'OpenAPI specification (path, url, or string content)',
|
|
29
28
|
)
|
|
29
|
+
.option('-l, --logs [value]', 'Logs folder')
|
|
30
30
|
.option('-o, --output <value>', 'Output folder')
|
|
31
31
|
.option('-p, --plugins [value...]', "List of plugins you'd like to use")
|
|
32
32
|
.option(
|
|
33
33
|
'--base [value]',
|
|
34
34
|
'DEPRECATED. Manually set base in OpenAPI config instead of inferring from server value',
|
|
35
35
|
)
|
|
36
|
+
.option('-s, --silent', 'Set log level to silent')
|
|
36
37
|
.option('--exportCore [value]', 'DEPRECATED. Write core files to disk')
|
|
37
38
|
.option('--name <value>', 'DEPRECATED. Custom client class name')
|
|
38
39
|
.option('--request <value>', 'DEPRECATED. Path to custom request file')
|
|
@@ -70,29 +71,40 @@ const processParams = (obj, booleanKeys) => {
|
|
|
70
71
|
|
|
71
72
|
async function start() {
|
|
72
73
|
let userConfig;
|
|
74
|
+
|
|
73
75
|
try {
|
|
74
|
-
const { createClient } = require(
|
|
76
|
+
const { createClient } = require(
|
|
77
|
+
path.resolve(__dirname, '../dist/index.cjs'),
|
|
78
|
+
);
|
|
79
|
+
|
|
75
80
|
userConfig = processParams(params, [
|
|
76
81
|
'dryRun',
|
|
77
82
|
'experimentalParser',
|
|
78
83
|
'exportCore',
|
|
79
84
|
'useOptions',
|
|
80
85
|
]);
|
|
86
|
+
|
|
81
87
|
if (params.plugins === true) {
|
|
82
88
|
userConfig.plugins = [];
|
|
83
89
|
} else if (params.plugins) {
|
|
84
90
|
userConfig.plugins = params.plugins;
|
|
85
91
|
}
|
|
92
|
+
|
|
93
|
+
userConfig.logs = userConfig.logs
|
|
94
|
+
? {
|
|
95
|
+
path: userConfig.logs,
|
|
96
|
+
}
|
|
97
|
+
: {};
|
|
98
|
+
|
|
99
|
+
if (userConfig.debug || stringToBoolean(process.env.DEBUG)) {
|
|
100
|
+
userConfig.logs.level = 'debug';
|
|
101
|
+
} else if (userConfig.silent) {
|
|
102
|
+
userConfig.logs.level = 'silent';
|
|
103
|
+
}
|
|
104
|
+
|
|
86
105
|
await createClient(userConfig);
|
|
87
106
|
process.exit(0);
|
|
88
107
|
} catch (error) {
|
|
89
|
-
if (!userConfig?.dryRun) {
|
|
90
|
-
const logName = `openapi-ts-error-${Date.now()}.log`;
|
|
91
|
-
const logPath = resolve(process.cwd(), logName);
|
|
92
|
-
writeFileSync(logPath, `${error.message}\n${error.stack}`);
|
|
93
|
-
console.error(`🔥 Unexpected error occurred. Log saved to ${logPath}`);
|
|
94
|
-
}
|
|
95
|
-
console.error(`🔥 Unexpected error occurred. ${error.message}`);
|
|
96
108
|
process.exit(1);
|
|
97
109
|
}
|
|
98
110
|
}
|