@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 +23 -13
- package/package.json +7 -7
- package/support/bin/help.ts +1 -1
- package/support/cli.openapi_client.ts +9 -6
- package/support/cli.openapi_spec.ts +4 -1
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
|
|
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:
|
|
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
|
-
|
|
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
|
-
|
|
143
|
+
Generate API clients from an OpenAPI specification using the generator image.
|
|
140
144
|
|
|
141
|
-
**Terminal:
|
|
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
|
|
149
|
-
-a, --additional-properties <string> Additional
|
|
150
|
-
-i, --input <string> Input
|
|
151
|
-
-o, --output <string> Output
|
|
152
|
-
-d, --docker-image <string> Docker
|
|
153
|
-
|
|
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.
|
|
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.
|
|
31
|
-
"@travetto/schema": "^8.0.0-alpha.
|
|
32
|
-
"@travetto/web": "^8.0.0-alpha.
|
|
33
|
-
"openapi3-ts": "^4.
|
|
34
|
-
"yaml": "^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.
|
|
37
|
+
"@travetto/cli": "^8.0.0-alpha.25"
|
|
38
38
|
},
|
|
39
39
|
"peerDependenciesMeta": {
|
|
40
40
|
"@travetto/cli": {
|
package/support/bin/help.ts
CHANGED
|
@@ -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
|
|
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
|
-
*
|
|
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
|
|
17
|
+
/** Show expanded generator help for all available formats/options. */
|
|
15
18
|
@CliFlag({ short: '-x' })
|
|
16
19
|
extendedHelp: boolean = false;
|
|
17
|
-
/** Additional
|
|
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
|
|
23
|
+
/** Input OpenAPI document path. */
|
|
21
24
|
input = './openapi.yml';
|
|
22
|
-
/** Output
|
|
25
|
+
/** Output directory for generated client sources. */
|
|
23
26
|
output = './api-client';
|
|
24
|
-
/** Docker
|
|
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
|
-
*
|
|
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 {
|