@travetto/openapi 4.0.2 → 4.0.4

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 CHANGED
@@ -145,15 +145,8 @@ Options:
145
145
  -a, --additional-properties <string> Additional Properties (default: [])
146
146
  -i, --input <string> Input file (default: "./openapi.yml")
147
147
  -o, --output <string> Output folder (default: "./api-client")
148
- -d, --docker-image <string> Docker Image to user (default: "arcsine/openapi-generator:latest")
149
- -w, --watch Watch for file changes
148
+ -d, --docker-image <string> Docker Image to user (default: "openapitools/openapi-generator-cli:latest")
150
149
  -h, --help display help for command
151
-
152
- Available Presets
153
- ----------------------------------
154
- * @travetto/angular14 -- typescript-angular supportsES6=true,stringEnums=true,ngVersion=14.0,fileNaming=kebab-case
155
- * @travetto/angular15 -- typescript-angular supportsES6=true,stringEnums=true,ngVersion=15.0,fileNaming=kebab-case
156
- * @travetto/fetch -- typescript-fetch stringEnums=true
157
150
  ```
158
151
 
159
152
  This tool relies upon a custom build of [OpenAPI client generation tools](https://github.com/OpenAPITools/openapi-generator), which supports watching. This allows for fast responsive client generation as the shape of the API changes.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/openapi",
3
- "version": "4.0.2",
3
+ "version": "4.0.4",
4
4
  "description": "OpenAPI integration support for the Travetto framework",
5
5
  "keywords": [
6
6
  "rest",
@@ -26,15 +26,15 @@
26
26
  "directory": "module/openapi"
27
27
  },
28
28
  "dependencies": {
29
- "@travetto/config": "^4.0.2",
30
- "@travetto/rest": "^4.0.2",
31
- "@travetto/schema": "^4.0.2",
32
- "@travetto/yaml": "^4.0.1",
29
+ "@travetto/config": "^4.0.3",
30
+ "@travetto/rest": "^4.0.3",
31
+ "@travetto/schema": "^4.0.3",
32
+ "@travetto/yaml": "^4.0.2",
33
33
  "openapi3-ts": "^4.2.1"
34
34
  },
35
35
  "peerDependencies": {
36
- "@travetto/cli": "^4.0.2",
37
- "@travetto/command": "^4.0.1"
36
+ "@travetto/cli": "^4.0.4",
37
+ "@travetto/command": "^4.0.2"
38
38
  },
39
39
  "peerDependenciesMeta": {
40
40
  "@travetto/cli": {
@@ -5,8 +5,6 @@ import { ExecUtil } from '@travetto/base';
5
5
  import { path, RuntimeContext } from '@travetto/manifest';
6
6
  import { cliTpl } from '@travetto/cli';
7
7
 
8
- import { OpenApiClientPresets } from './presets';
9
-
10
8
  /**
11
9
  * Help utility for openapi client command
12
10
  */
@@ -31,28 +29,16 @@ export class OpenApiClientHelp {
31
29
  }
32
30
 
33
31
  static async help(dockerImage: string, extendedHelp: boolean): Promise<string[]> {
34
- const presets = await OpenApiClientPresets.getPresets();
35
- const presetLen = Math.max(...Object.keys(presets).map(x => x.length));
36
- const presetEntries = Object
37
- .entries(presets)
38
- .sort(([a], [b]) => a.localeCompare(b))
39
- .map(([k, [cmd, v]]) => [`@travetto/${k}`.padEnd(presetLen + 5), [cmd, OpenApiClientPresets.presetMap(v)]] as const);
40
-
41
- const presetText = [
42
- cliTpl`${{ subtitle: 'Available Presets' }}`,
43
- '----------------------------------',
44
- ...presetEntries.map(([k, [cmd, param]]) => cliTpl`* ${{ input: k }} -- ${{ identifier: cmd }} ${{ param }}`),
45
- ];
46
-
32
+ const help: string[] = [];
47
33
  if (extendedHelp) {
48
34
  const formats = await this.getListOfFormats(dockerImage);
49
- presetText.push(
35
+ help.push(
50
36
  '',
51
37
  cliTpl`${{ subtitle: 'Available Formats' }}`,
52
38
  '----------------------------------',
53
39
  ...formats.map(x => cliTpl`* ${{ input: x }}`)
54
40
  );
55
41
  }
56
- return presetText;
42
+ return help;
57
43
  }
58
44
  }
@@ -4,7 +4,6 @@ import { DockerContainer } from '@travetto/command';
4
4
  import { ExecUtil } from '@travetto/base';
5
5
 
6
6
  import { OpenApiClientHelp } from './bin/help';
7
- import { OpenApiClientPresets } from './bin/presets';
8
7
 
9
8
  /**
10
9
  * CLI for generating the cli client
@@ -20,30 +19,7 @@ export class OpenApiClientCommand implements CliCommandShape {
20
19
  @CliFlag({ desc: 'Output folder' })
21
20
  output = './api-client';
22
21
  @CliFlag({ desc: 'Docker Image to user' })
23
- dockerImage = 'arcsine/openapi-generator:latest';
24
- @CliFlag({ desc: 'Watch for file changes' })
25
- watch?: boolean;
26
-
27
- async getPropList(format: string): Promise<string> {
28
- let propMap = Object.fromEntries(this.props?.map(p => p.split('=')) ?? []);
29
-
30
- if (format.startsWith('@travetto/')) {
31
- const key = format.split('@travetto/')[1];
32
- const [, props] = (await OpenApiClientPresets.getPresets())[key];
33
- propMap = { ...props, ...propMap };
34
- }
35
-
36
- return OpenApiClientPresets.presetMap(propMap);
37
- }
38
-
39
- async getResolvedFormat(format: string): Promise<string> {
40
- if (format.startsWith('@travetto/')) {
41
- const key = format.split('@travetto/')[1];
42
- const [fmt] = (await OpenApiClientPresets.getPresets())[key];
43
- return fmt;
44
- }
45
- return format;
46
- }
22
+ dockerImage = 'openapitools/openapi-generator-cli:latest';
47
23
 
48
24
  async help(): Promise<string[]> {
49
25
  return OpenApiClientHelp.help(this.dockerImage, this.extendedHelp ?? false);
@@ -61,17 +37,14 @@ export class OpenApiClientCommand implements CliCommandShape {
61
37
  .setTTY(false)
62
38
  .setDeleteOnFinish(true);
63
39
 
64
- const propList = await this.getPropList(format);
65
-
66
40
  const proc = await cmd.run([
67
41
  'generate',
68
42
  '--skip-validate-spec',
69
43
  '--remove-operation-id-prefix',
70
- '-g', await this.getResolvedFormat(format),
44
+ '-g', format,
71
45
  '-o', '/workspace',
72
46
  '-i', `/input/${path.basename(this.input)}`,
73
- ...(this.watch ? ['-w'] : []),
74
- ...(propList ? ['--additional-properties', propList] : [])
47
+ ...(this.props.length ? ['--additional-properties', this.props.join(',')] : [])
75
48
  ]);
76
49
 
77
50
  const result = await ExecUtil.getResult(proc);
@@ -1,22 +0,0 @@
1
- import { FileLoader } from '@travetto/base';
2
-
3
- /**
4
- * Presets utility for openapi client command
5
- */
6
- export class OpenApiClientPresets {
7
-
8
- static #presets: Record<string, [string, object] | [string]>;
9
- static #resources = new FileLoader(['@travetto/openapi#support/resources']);
10
-
11
- static async getPresets(): Promise<Record<string, [string, object] | [string]>> {
12
- if (!this.#presets) {
13
- const text = await this.#resources.read('presets.json');
14
- this.#presets = JSON.parse(text);
15
- }
16
- return this.#presets;
17
- }
18
-
19
- static presetMap(prop?: object): string {
20
- return !prop || Object.keys(prop).length === 0 ? '' : Object.entries(prop).map(([k, v]) => `${k}=${v}`).join(',');
21
- }
22
- }
@@ -1,26 +0,0 @@
1
- {
2
- "angular15": [
3
- "typescript-angular",
4
- {
5
- "supportsES6": true,
6
- "stringEnums": true,
7
- "ngVersion": "15.0",
8
- "fileNaming": "kebab-case"
9
- }
10
- ],
11
- "angular14": [
12
- "typescript-angular",
13
- {
14
- "supportsES6": true,
15
- "stringEnums": true,
16
- "ngVersion": "14.0",
17
- "fileNaming": "kebab-case"
18
- }
19
- ],
20
- "fetch": [
21
- "typescript-fetch",
22
- {
23
- "stringEnums": true
24
- }
25
- ]
26
- }