@travetto/openapi 5.0.0-rc.1 → 5.0.0-rc.3
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 +6 -6
- package/package.json +6 -6
- package/src/config.ts +6 -6
- package/src/service.ts +1 -1
- package/src/spec-generate.ts +3 -4
- package/support/bin/help.ts +2 -2
- package/support/cli.openapi_client.ts +1 -1
- package/support/cli.openapi_spec.ts +1 -1
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@ import path from 'node:path';
|
|
|
29
29
|
import type { ServerObject, ContactObject, LicenseObject } from 'openapi3-ts/oas31';
|
|
30
30
|
|
|
31
31
|
import { Config } from '@travetto/config';
|
|
32
|
-
import {
|
|
32
|
+
import { Runtime } from '@travetto/runtime';
|
|
33
33
|
import { Required } from '@travetto/schema';
|
|
34
34
|
|
|
35
35
|
/**
|
|
@@ -51,9 +51,9 @@ export class ApiInfoConfig {
|
|
|
51
51
|
version: string;
|
|
52
52
|
|
|
53
53
|
postConstruct(): void {
|
|
54
|
-
this.title ??=
|
|
55
|
-
this.version ??=
|
|
56
|
-
this.description ??=
|
|
54
|
+
this.title ??= Runtime.main.name;
|
|
55
|
+
this.version ??= Runtime.main.version;
|
|
56
|
+
this.description ??= Runtime.main.description;
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
|
|
@@ -98,8 +98,8 @@ export class ApiSpecConfig {
|
|
|
98
98
|
if (!this.output || this.output === '-') {
|
|
99
99
|
this.persist = false;
|
|
100
100
|
} else {
|
|
101
|
-
this.output = path.resolve(
|
|
102
|
-
this.persist ??=
|
|
101
|
+
this.output = path.resolve(Runtime.mainSourcePath, this.output);
|
|
102
|
+
this.persist ??= Runtime.dynamic;
|
|
103
103
|
}
|
|
104
104
|
if (this.persist) {
|
|
105
105
|
if (!/[.](json|ya?ml) $/.test(this.output)) { // Assume a folder
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/openapi",
|
|
3
|
-
"version": "5.0.0-rc.
|
|
3
|
+
"version": "5.0.0-rc.3",
|
|
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": "^5.0.0-rc.
|
|
30
|
-
"@travetto/rest": "^5.0.0-rc.
|
|
31
|
-
"@travetto/schema": "^5.0.0-rc.
|
|
29
|
+
"@travetto/config": "^5.0.0-rc.3",
|
|
30
|
+
"@travetto/rest": "^5.0.0-rc.3",
|
|
31
|
+
"@travetto/schema": "^5.0.0-rc.3",
|
|
32
32
|
"yaml": "^2.4.5",
|
|
33
33
|
"openapi3-ts": "^4.3.3"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@travetto/cli": "^5.0.0-rc.
|
|
37
|
-
"@travetto/command": "^5.0.0-rc.
|
|
36
|
+
"@travetto/cli": "^5.0.0-rc.3",
|
|
37
|
+
"@travetto/command": "^5.0.0-rc.3"
|
|
38
38
|
},
|
|
39
39
|
"peerDependenciesMeta": {
|
|
40
40
|
"@travetto/cli": {
|
package/src/config.ts
CHANGED
|
@@ -3,7 +3,7 @@ import path from 'node:path';
|
|
|
3
3
|
import type { ServerObject, ContactObject, LicenseObject } from 'openapi3-ts/oas31';
|
|
4
4
|
|
|
5
5
|
import { Config } from '@travetto/config';
|
|
6
|
-
import {
|
|
6
|
+
import { Runtime } from '@travetto/runtime';
|
|
7
7
|
import { Required } from '@travetto/schema';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -25,9 +25,9 @@ export class ApiInfoConfig {
|
|
|
25
25
|
version: string;
|
|
26
26
|
|
|
27
27
|
postConstruct(): void {
|
|
28
|
-
this.title ??=
|
|
29
|
-
this.version ??=
|
|
30
|
-
this.description ??=
|
|
28
|
+
this.title ??= Runtime.main.name;
|
|
29
|
+
this.version ??= Runtime.main.version;
|
|
30
|
+
this.description ??= Runtime.main.description;
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
|
|
@@ -72,8 +72,8 @@ export class ApiSpecConfig {
|
|
|
72
72
|
if (!this.output || this.output === '-') {
|
|
73
73
|
this.persist = false;
|
|
74
74
|
} else {
|
|
75
|
-
this.output = path.resolve(
|
|
76
|
-
this.persist ??=
|
|
75
|
+
this.output = path.resolve(Runtime.mainSourcePath, this.output);
|
|
76
|
+
this.persist ??= Runtime.dynamic;
|
|
77
77
|
}
|
|
78
78
|
if (this.persist) {
|
|
79
79
|
if (!/[.](json|ya?ml)$/.test(this.output)) { // Assume a folder
|
package/src/service.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { OpenAPIObject } from 'openapi3-ts/oas31';
|
|
2
2
|
|
|
3
|
-
import { Util } from '@travetto/
|
|
3
|
+
import { Util } from '@travetto/runtime';
|
|
4
4
|
import { Injectable, Inject } from '@travetto/di';
|
|
5
5
|
import { ControllerRegistry, ControllerVisitUtil, RestConfig } from '@travetto/rest';
|
|
6
6
|
import { SchemaRegistry } from '@travetto/schema';
|
package/src/spec-generate.ts
CHANGED
|
@@ -5,8 +5,7 @@ import type {
|
|
|
5
5
|
} from 'openapi3-ts/oas31';
|
|
6
6
|
|
|
7
7
|
import { EndpointConfig, ControllerConfig, ParamConfig, EndpointIOType, ControllerVisitor } from '@travetto/rest';
|
|
8
|
-
import {
|
|
9
|
-
import { Class } from '@travetto/base';
|
|
8
|
+
import { Class, describeFunction } from '@travetto/runtime';
|
|
10
9
|
import { SchemaRegistry, FieldConfig, ClassConfig, SchemaNameResolver } from '@travetto/schema';
|
|
11
10
|
import { AllViewⲐ } from '@travetto/schema/src/internal/types';
|
|
12
11
|
|
|
@@ -218,11 +217,11 @@ export class OpenapiVisitor implements ControllerVisitor<GeneratedSpec> {
|
|
|
218
217
|
}
|
|
219
218
|
|
|
220
219
|
const extra: Record<string, unknown> = {};
|
|
221
|
-
if (
|
|
220
|
+
if (describeFunction(cls)?.abstract) {
|
|
222
221
|
const map = SchemaRegistry.getSubTypesForClass(cls);
|
|
223
222
|
if (map) {
|
|
224
223
|
extra.oneOf = map
|
|
225
|
-
.filter(x => !
|
|
224
|
+
.filter(x => !describeFunction(x)?.abstract)
|
|
226
225
|
.map(c => {
|
|
227
226
|
this.onSchema(SchemaRegistry.get(c));
|
|
228
227
|
return this.#getType(c);
|
package/support/bin/help.ts
CHANGED
|
@@ -2,7 +2,7 @@ import fs from 'node:fs/promises';
|
|
|
2
2
|
import { spawn } from 'node:child_process';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
|
|
5
|
-
import { ExecUtil,
|
|
5
|
+
import { ExecUtil, Runtime } from '@travetto/runtime';
|
|
6
6
|
import { cliTpl } from '@travetto/cli';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -11,7 +11,7 @@ import { cliTpl } from '@travetto/cli';
|
|
|
11
11
|
export class OpenApiClientHelp {
|
|
12
12
|
|
|
13
13
|
static async getListOfFormats(dockerImage: string): Promise<string[]> {
|
|
14
|
-
const formatCache =
|
|
14
|
+
const formatCache = Runtime.toolPath('openapi-formats.json');
|
|
15
15
|
if (!await fs.stat(formatCache).catch(() => false)) {
|
|
16
16
|
const { stdout } = await ExecUtil.getResult(spawn('docker', ['run', '--rm', dockerImage, 'list'], { shell: false }));
|
|
17
17
|
const lines = stdout
|
|
@@ -2,7 +2,7 @@ import path from 'node:path';
|
|
|
2
2
|
|
|
3
3
|
import { CliCommandShape, CliCommand, CliFlag } from '@travetto/cli';
|
|
4
4
|
import { DockerContainer } from '@travetto/command';
|
|
5
|
-
import { ExecUtil } from '@travetto/
|
|
5
|
+
import { ExecUtil } from '@travetto/runtime';
|
|
6
6
|
|
|
7
7
|
import { OpenApiClientHelp } from './bin/help';
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@ import fs from 'node:fs/promises';
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
|
|
4
4
|
import { CliCommandShape, CliCommand } from '@travetto/cli';
|
|
5
|
-
import { Env } from '@travetto/
|
|
5
|
+
import { Env } from '@travetto/runtime';
|
|
6
6
|
import { RootRegistry } from '@travetto/registry';
|
|
7
7
|
import { DependencyRegistry } from '@travetto/di';
|
|
8
8
|
|