@travetto/openapi 3.4.5 → 4.0.0-rc.0
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 +8 -9
- package/package.json +7 -7
- package/src/config.ts +7 -8
- package/src/spec-generate.ts +4 -4
- package/support/bin/help.ts +3 -3
- package/support/cli.openapi_client.ts +1 -2
- package/support/cli.openapi_spec.ts +3 -3
package/README.md
CHANGED
|
@@ -27,8 +27,8 @@ All of the high level configurations can be found in the following structure:
|
|
|
27
27
|
import type { ServerObject, ContactObject, LicenseObject } from 'openapi3-ts/oas31';
|
|
28
28
|
|
|
29
29
|
import { Config } from '@travetto/config';
|
|
30
|
-
import { path,
|
|
31
|
-
import {
|
|
30
|
+
import { path, RuntimeIndex, RuntimeContext } from '@travetto/manifest';
|
|
31
|
+
import { Env } from '@travetto/base';
|
|
32
32
|
import { Required } from '@travetto/schema';
|
|
33
33
|
|
|
34
34
|
/**
|
|
@@ -50,10 +50,9 @@ export class ApiInfoConfig {
|
|
|
50
50
|
version: string;
|
|
51
51
|
|
|
52
52
|
postConstruct(): void {
|
|
53
|
-
|
|
54
|
-
this.
|
|
55
|
-
this.
|
|
56
|
-
this.description ??= info.description;
|
|
53
|
+
this.title ??= RuntimeContext.main.name;
|
|
54
|
+
this.version ??= RuntimeContext.main.version;
|
|
55
|
+
this.description ??= RuntimeContext.main.description;
|
|
57
56
|
}
|
|
58
57
|
}
|
|
59
58
|
|
|
@@ -98,8 +97,8 @@ export class ApiSpecConfig {
|
|
|
98
97
|
if (!this.output || this.output === '-') {
|
|
99
98
|
this.persist = false;
|
|
100
99
|
} else {
|
|
101
|
-
this.output = path.resolve(
|
|
102
|
-
this.persist ??=
|
|
100
|
+
this.output = path.resolve(RuntimeIndex.mainModule.sourcePath, this.output);
|
|
101
|
+
this.persist ??= Env.dynamic;
|
|
103
102
|
}
|
|
104
103
|
if (this.persist) {
|
|
105
104
|
if (!/[.](json|ya?ml) $/.test(this.output)) { // Assume a folder
|
|
@@ -124,7 +123,7 @@ Usage: openapi:spec [options]
|
|
|
124
123
|
|
|
125
124
|
Options:
|
|
126
125
|
-o, --output <string> Output files
|
|
127
|
-
-m, --module <
|
|
126
|
+
-m, --module <module> Module to run for
|
|
128
127
|
-h, --help display help for command
|
|
129
128
|
```
|
|
130
129
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/openapi",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-rc.0",
|
|
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": "^
|
|
30
|
-
"@travetto/rest": "^
|
|
31
|
-
"@travetto/schema": "^
|
|
32
|
-
"@travetto/yaml": "^
|
|
29
|
+
"@travetto/config": "^4.0.0-rc.0",
|
|
30
|
+
"@travetto/rest": "^4.0.0-rc.0",
|
|
31
|
+
"@travetto/schema": "^4.0.0-rc.0",
|
|
32
|
+
"@travetto/yaml": "^4.0.0-rc.0",
|
|
33
33
|
"openapi3-ts": "^4.1.2"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@travetto/cli": "^
|
|
37
|
-
"@travetto/command": "^
|
|
36
|
+
"@travetto/cli": "^4.0.0-rc.0",
|
|
37
|
+
"@travetto/command": "^4.0.0-rc.0"
|
|
38
38
|
},
|
|
39
39
|
"peerDependenciesMeta": {
|
|
40
40
|
"@travetto/cli": {
|
package/src/config.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { ServerObject, ContactObject, LicenseObject } from 'openapi3-ts/oas31';
|
|
2
2
|
|
|
3
3
|
import { Config } from '@travetto/config';
|
|
4
|
-
import { path,
|
|
5
|
-
import {
|
|
4
|
+
import { path, RuntimeIndex, RuntimeContext } from '@travetto/manifest';
|
|
5
|
+
import { Env } from '@travetto/base';
|
|
6
6
|
import { Required } from '@travetto/schema';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -24,10 +24,9 @@ export class ApiInfoConfig {
|
|
|
24
24
|
version: string;
|
|
25
25
|
|
|
26
26
|
postConstruct(): void {
|
|
27
|
-
|
|
28
|
-
this.
|
|
29
|
-
this.
|
|
30
|
-
this.description ??= info.description;
|
|
27
|
+
this.title ??= RuntimeContext.main.name;
|
|
28
|
+
this.version ??= RuntimeContext.main.version;
|
|
29
|
+
this.description ??= RuntimeContext.main.description;
|
|
31
30
|
}
|
|
32
31
|
}
|
|
33
32
|
|
|
@@ -72,8 +71,8 @@ export class ApiSpecConfig {
|
|
|
72
71
|
if (!this.output || this.output === '-') {
|
|
73
72
|
this.persist = false;
|
|
74
73
|
} else {
|
|
75
|
-
this.output = path.resolve(
|
|
76
|
-
this.persist ??=
|
|
74
|
+
this.output = path.resolve(RuntimeIndex.mainModule.sourcePath, this.output);
|
|
75
|
+
this.persist ??= Env.dynamic;
|
|
77
76
|
}
|
|
78
77
|
if (this.persist) {
|
|
79
78
|
if (!/[.](json|ya?ml)$/.test(this.output)) { // Assume a folder
|
package/src/spec-generate.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Readable } from 'stream';
|
|
1
|
+
import { Readable } from 'node:stream';
|
|
2
2
|
import type {
|
|
3
3
|
SchemaObject, SchemasObject, ParameterObject, OperationObject,
|
|
4
4
|
RequestBodyObject, TagObject, PathsObject, PathItemObject
|
|
5
5
|
} from 'openapi3-ts/oas31';
|
|
6
6
|
|
|
7
7
|
import { EndpointConfig, ControllerConfig, ParamConfig, EndpointIOType, ControllerVisitor } from '@travetto/rest';
|
|
8
|
-
import {
|
|
8
|
+
import { RuntimeIndex } from '@travetto/manifest';
|
|
9
9
|
import { Class } from '@travetto/base';
|
|
10
10
|
import { SchemaRegistry, FieldConfig, ClassConfig, SchemaNameResolver } from '@travetto/schema';
|
|
11
11
|
import { AllViewⲐ } from '@travetto/schema/src/internal/types';
|
|
@@ -218,11 +218,11 @@ export class OpenapiVisitor implements ControllerVisitor<GeneratedSpec> {
|
|
|
218
218
|
}
|
|
219
219
|
|
|
220
220
|
const extra: Record<string, unknown> = {};
|
|
221
|
-
if (
|
|
221
|
+
if (RuntimeIndex.getFunctionMetadata(cls)?.abstract) {
|
|
222
222
|
const map = SchemaRegistry.getSubTypesForClass(cls);
|
|
223
223
|
if (map) {
|
|
224
224
|
extra.oneOf = map
|
|
225
|
-
.filter(x => !
|
|
225
|
+
.filter(x => !RuntimeIndex.getFunctionMetadata(x)?.abstract)
|
|
226
226
|
.map(c => {
|
|
227
227
|
this.onSchema(SchemaRegistry.get(c));
|
|
228
228
|
return this.#getType(c);
|
package/support/bin/help.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import fs from 'fs/promises';
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
2
|
|
|
3
|
-
import { ManifestFileUtil, path,
|
|
3
|
+
import { ManifestFileUtil, path, RuntimeIndex } from '@travetto/manifest';
|
|
4
4
|
import { cliTpl } from '@travetto/cli';
|
|
5
5
|
import { OpenApiClientPresets } from './presets';
|
|
6
6
|
import { ExecUtil } from '@travetto/base';
|
|
@@ -11,7 +11,7 @@ import { ExecUtil } from '@travetto/base';
|
|
|
11
11
|
export class OpenApiClientHelp {
|
|
12
12
|
|
|
13
13
|
static async getListOfFormats(dockerImage: string): Promise<string[]> {
|
|
14
|
-
const formatCache = ManifestFileUtil.toolPath(
|
|
14
|
+
const formatCache = ManifestFileUtil.toolPath(RuntimeIndex, 'openapi-formats.json');
|
|
15
15
|
if (!await fs.stat(formatCache).catch(() => false)) {
|
|
16
16
|
const stdout = ExecUtil.spawn('docker', ['run', '--rm', dockerImage, 'list']);
|
|
17
17
|
const res = await stdout.result;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { path } from '@travetto/manifest';
|
|
2
|
-
import { ShutdownManager } from '@travetto/base';
|
|
3
2
|
import { CliCommandShape, CliCommand, CliFlag } from '@travetto/cli';
|
|
4
3
|
import { DockerContainer } from '@travetto/command';
|
|
5
4
|
|
|
@@ -76,7 +75,7 @@ export class OpenApiClientCommand implements CliCommandShape {
|
|
|
76
75
|
|
|
77
76
|
const result = await res;
|
|
78
77
|
if (!result.valid) {
|
|
79
|
-
|
|
78
|
+
process.exitCode = 1;
|
|
80
79
|
}
|
|
81
80
|
}
|
|
82
81
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import fs from 'fs/promises';
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
2
|
|
|
3
3
|
import { CliCommandShape, CliCommand } from '@travetto/cli';
|
|
4
|
-
import {
|
|
4
|
+
import { Env } from '@travetto/base';
|
|
5
5
|
import { RootRegistry } from '@travetto/registry';
|
|
6
6
|
import { DependencyRegistry } from '@travetto/di';
|
|
7
7
|
import { path } from '@travetto/manifest';
|
|
@@ -16,7 +16,7 @@ export class OpenApiSpecCommand implements CliCommandShape {
|
|
|
16
16
|
output?: string;
|
|
17
17
|
|
|
18
18
|
preMain(): void {
|
|
19
|
-
|
|
19
|
+
Env.DEBUG.set(false);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
async main(): Promise<void> {
|