@hey-api/openapi-ts 0.31.1 → 0.32.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/bin/index.js CHANGED
@@ -15,34 +15,66 @@ const params = program
15
15
  .option('-i, --input <value>', 'OpenAPI specification (path, url, or string content)')
16
16
  .option('-o, --output <value>', 'Output directory')
17
17
  .option('-c, --client <value>', 'HTTP client to generate [angular, axios, fetch, node, xhr]')
18
- .option('--name <value>', 'Custom client class name')
19
- .option('--useOptions [value]', 'Use options instead of arguments')
18
+ .option('-d, --debug', 'Run in debug mode?')
20
19
  .option('--base [value]', 'Manually set base in OpenAPI config instead of inferring from server value')
21
20
  .option('--enums <value>', 'Export enum definitions (javascript, typescript)')
22
- .option('--exportCore <value>', 'Write core files to disk')
23
- .option('--exportServices <value>', 'Write services to disk')
24
- .option('--exportModels <value>', 'Write models to disk')
25
- .option('--exportSchemas <value>', 'Write schemas to disk')
26
- .option('--format', 'Process output folder with formatter?')
27
- .option('--no-format', 'Disable processing output folder with formatter')
28
- .option('--lint', 'Process output folder with linter?')
29
- .option('--no-lint', 'Disable processing output folder with linter')
30
- .option('--operationId', 'Use operationd ID?')
31
- .option('--no-operationId', 'Use path URL to generate operation ID')
32
- .option('--postfixServices <value>', 'Service name postfix')
33
- .option('--serviceResponse [value]', 'Define shape of returned value from service calls')
34
- .option('--useDateType <value>', 'Output Date instead of string for the format "date-time" in the models')
21
+ .option('--exportCore [value]', 'Write core files to disk')
22
+ .option('--exportModels [value]', 'Write models to disk')
23
+ .option('--exportSchemas [value]', 'Write schemas to disk')
24
+ .option('--exportServices [value]', 'Write services to disk')
25
+ .option('--format [value]', 'Process output folder with formatter?')
26
+ .option('--lint [value]', 'Process output folder with linter?')
27
+ .option('--name <value>', 'Custom client class name')
28
+ .option('--operationId [value]', 'Use operationd ID?')
35
29
  .option('--postfixModels <value>', 'Model name postfix')
30
+ .option('--postfixServices <value>', 'Service name postfix')
36
31
  .option('--request <value>', 'Path to custom request file')
37
- .option('--write', 'Write files to disk? (used for testing)')
38
- .option('--no-write', 'Skip writing files to disk (used for testing)')
32
+ .option('--serviceResponse [value]', 'Define shape of returned value from service calls')
33
+ .option('--useDateType [value]', 'Output Date instead of string for the format "date-time" in the models')
34
+ .option('--useOptions [value]', 'Use options instead of arguments')
35
+ .option('--write [value]', 'Write files to disk? (used for testing)')
39
36
  .parse(process.argv)
40
37
  .opts();
41
38
 
39
+ const stringToBoolean = value => {
40
+ if (value === 'true') {
41
+ return true;
42
+ }
43
+ if (value === 'false') {
44
+ return false;
45
+ }
46
+ return value;
47
+ };
48
+
49
+ const processParams = (obj, keys) => {
50
+ const result = {};
51
+ for (const key of keys) {
52
+ const value = obj[key];
53
+ if (typeof value === 'string') {
54
+ result[key] = stringToBoolean(value);
55
+ }
56
+ }
57
+ return result;
58
+ };
59
+
42
60
  async function start() {
43
61
  try {
44
62
  const { createClient } = await import(new URL('../dist/node/index.js', import.meta.url));
45
- await createClient(params);
63
+ await createClient({
64
+ ...params,
65
+ ...processParams(params, [
66
+ 'exportCore',
67
+ 'exportModels',
68
+ 'exportSchemas',
69
+ 'exportServices',
70
+ 'format',
71
+ 'lint',
72
+ 'operationId',
73
+ 'useDateType',
74
+ 'useOptions',
75
+ 'write',
76
+ ]),
77
+ });
46
78
  process.exit(0);
47
79
  } catch (error) {
48
80
  console.error(error);
@@ -8,11 +8,21 @@ interface UserConfig {
8
8
  * @default 'fetch'
9
9
  */
10
10
  client?: 'angular' | 'axios' | 'fetch' | 'node' | 'xhr';
11
+ /**
12
+ * Run in debug mode?
13
+ * @default false
14
+ */
15
+ debug?: boolean;
11
16
  /**
12
17
  * Export enum definitions?
13
18
  * @default false
14
19
  */
15
20
  enums?: 'javascript' | 'typescript' | false;
21
+ /**
22
+ * Generate an experimental build?
23
+ * @default false
24
+ */
25
+ experimental?: boolean;
16
26
  /**
17
27
  * Generate core client classes?
18
28
  * @default true