@travetto/openapi 8.0.0-alpha.2 → 8.0.0-alpha.20

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
@@ -117,40 +117,50 @@ export class ApiSpecConfig {
117
117
  The framework, when in watch mode, will generate the [OpenAPI](https://github.com/OAI/OpenAPI-Specification) specification in either [JSON](https://www.json.org) or [YAML](https://en.wikipedia.org/wiki/YAML). This module integrates with the file watching paradigm and can regenerate the openapi spec as changes to endpoints and models are made during development. The output format is defined by the suffix of the output file, `.yaml` or `.json`.
118
118
 
119
119
  ## CLI - openapi:spec
120
- The module provides a command for the [Command Line Interface](https://github.com/travetto/travetto/tree/main/module/cli#readme "CLI infrastructure for Travetto framework") to allow scripting file generation.
120
+ The command will load your application, in non-listening mode, to collect all the endpoints and model information, to produce the `openapi.yml`. Once produced, the code will store the output in the specified location.
121
121
 
122
- **Terminal: OpenAPI usage**
122
+ **Terminal: Help for openapi:spec**
123
123
  ```bash
124
124
  $ trv openapi:spec --help
125
125
 
126
126
  Usage: openapi:spec [options]
127
127
 
128
+ Description:
129
+ Generate the OpenAPI specification for the selected module.
130
+
131
+ The resulting JSON can be written to stdout or to a file path for use in
132
+ downstream tooling, CI publishing, and client generation pipelines.
133
+
128
134
  Options:
129
135
  -o, --output <string> Output files
130
136
  -m, --module <module> Module to run for
131
- -h, --help display help for command
137
+ --help display help for command
132
138
  ```
133
139
 
134
- The command will run your application, in non-server mode, to collect all the endpoints and model information, to produce the `openapi.yml`. Once produced, the code will store the output in the specified location.
135
-
136
140
  **Note**: The module supports generating the OpenAPI spec in real-time while listening for changes to endpoints and models.
137
141
 
138
142
  ## CLI - openapi:client
139
- The module provides a command for the [Command Line Interface](https://github.com/travetto/travetto/tree/main/module/cli#readme "CLI infrastructure for Travetto framework") to allow client generation from the API structure.
143
+ Generate API clients from an OpenAPI specification using the generator image.
140
144
 
141
- **Terminal: OpenAPI usage**
145
+ **Terminal: Help for openapi:client**
142
146
  ```bash
143
147
  $ trv openapi:client --help
144
148
 
145
149
  Usage: openapi:client [options] <format:string>
146
150
 
151
+ Description:
152
+ Generate API clients from an OpenAPI specification using the generator image.
153
+
154
+ This command wraps OpenAPI Generator in Docker and writes generated client code
155
+ into the configured output folder.
156
+
147
157
  Options:
148
- -x, --extended-help Show Extended Help (default: false)
149
- -a, --additional-properties <string> Additional Properties (default: [])
150
- -i, --input <string> Input file (default: "./openapi.yml")
151
- -o, --output <string> Output folder (default: "./api-client")
152
- -d, --docker-image <string> Docker Image to user (default: "openapitools/openapi-generator-cli:latest")
153
- -h, --help display help for command
158
+ -x, --extended-help Show expanded generator help for all available formats/options. (default: false)
159
+ -a, --additional-properties <string> Additional generator properties passed as comma-separated key/value pairs. (default: [])
160
+ -i, --input <string> Input OpenAPI document path. (default: "./openapi.yml")
161
+ -o, --output <string> Output directory for generated client sources. (default: "./api-client")
162
+ -d, --docker-image <string> Docker image used to run OpenAPI Generator. (default: "openapitools/openapi-generator-cli:latest")
163
+ --help display help for command
154
164
  ```
155
165
 
156
166
  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": "8.0.0-alpha.2",
3
+ "version": "8.0.0-alpha.20",
4
4
  "type": "module",
5
5
  "description": "OpenAPI integration support for the Travetto framework",
6
6
  "keywords": [
@@ -27,14 +27,14 @@
27
27
  "directory": "module/openapi"
28
28
  },
29
29
  "dependencies": {
30
- "@travetto/config": "^8.0.0-alpha.2",
31
- "@travetto/schema": "^8.0.0-alpha.2",
32
- "@travetto/web": "^8.0.0-alpha.2",
33
- "openapi3-ts": "^4.5.0",
34
- "yaml": "^2.8.2"
30
+ "@travetto/config": "^8.0.0-alpha.19",
31
+ "@travetto/schema": "^8.0.0-alpha.19",
32
+ "@travetto/web": "^8.0.0-alpha.20",
33
+ "openapi3-ts": "^4.6.0",
34
+ "yaml": "^2.9.0"
35
35
  },
36
36
  "peerDependencies": {
37
- "@travetto/cli": "^8.0.0-alpha.3"
37
+ "@travetto/cli": "^8.0.0-alpha.25"
38
38
  },
39
39
  "peerDependenciesMeta": {
40
40
  "@travetto/cli": {
@@ -12,7 +12,7 @@ export class OpenApiClientHelp {
12
12
 
13
13
  static async getListOfFormats(dockerImage: string): Promise<string[]> {
14
14
  const formatCache = Runtime.toolPath('openapi-formats.json');
15
- if (!await fs.stat(formatCache).catch(() => false)) {
15
+ if (!await fs.stat(formatCache, { throwIfNoEntry: false })) {
16
16
  const { stdout } = await ExecUtil.getResult(spawn('docker', ['run', '--rm', dockerImage, 'list']));
17
17
  const lines = stdout
18
18
  .split('DOCUMENTATION')[0]
@@ -7,21 +7,24 @@ import { ExecUtil } from '@travetto/runtime';
7
7
  import { OpenApiClientHelp } from './bin/help.ts';
8
8
 
9
9
  /**
10
- * CLI for generating the cli client
10
+ * Generate API clients from an OpenAPI specification using the generator image.
11
+ *
12
+ * This command wraps OpenAPI Generator in Docker and writes generated client code
13
+ * into the configured output folder.
11
14
  */
12
15
  @CliCommand()
13
16
  export class OpenApiClientCommand implements CliCommandShape {
14
- /** Show Extended Help */
17
+ /** Show expanded generator help for all available formats/options. */
15
18
  @CliFlag({ short: '-x' })
16
19
  extendedHelp: boolean = false;
17
- /** Additional Properties */
20
+ /** Additional generator properties passed as comma-separated key/value pairs. */
18
21
  @CliFlag({ short: '-a', full: '--additional-properties' })
19
22
  properties: string[] = [];
20
- /** Input file */
23
+ /** Input OpenAPI document path. */
21
24
  input = './openapi.yml';
22
- /** Output folder */
25
+ /** Output directory for generated client sources. */
23
26
  output = './api-client';
24
- /** Docker Image to user */
27
+ /** Docker image used to run OpenAPI Generator. */
25
28
  dockerImage = 'openapitools/openapi-generator-cli:latest';
26
29
 
27
30
  async help(): Promise<string[]> {
@@ -7,7 +7,10 @@ import { Registry } from '@travetto/registry';
7
7
  import { DependencyRegistryIndex } from '@travetto/di';
8
8
 
9
9
  /**
10
- * CLI for outputting the open api spec to a local file
10
+ * Generate the OpenAPI specification for the selected module.
11
+ *
12
+ * The resulting JSON can be written to stdout or to a file path for use in
13
+ * downstream tooling, CI publishing, and client generation pipelines.
11
14
  */
12
15
  @CliCommand()
13
16
  export class OpenApiSpecCommand implements CliCommandShape {