@travetto/openapi 7.0.0-rc.3 → 7.0.0-rc.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 +1 -1
- package/package.json +5 -5
- package/src/config.ts +1 -1
- package/src/generate.ts +7 -9
- package/src/service.ts +1 -6
- package/support/bin/help.ts +2 -2
package/README.md
CHANGED
|
@@ -99,7 +99,7 @@ export class ApiSpecConfig {
|
|
|
99
99
|
this.persist = false;
|
|
100
100
|
} else {
|
|
101
101
|
this.output = path.resolve(Runtime.mainSourcePath, this.output);
|
|
102
|
-
this.persist ??= Runtime.
|
|
102
|
+
this.persist ??= !Runtime.production;
|
|
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": "7.0.0-rc.
|
|
3
|
+
"version": "7.0.0-rc.4",
|
|
4
4
|
"description": "OpenAPI integration support for the Travetto framework",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"web",
|
|
@@ -26,14 +26,14 @@
|
|
|
26
26
|
"directory": "module/openapi"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@travetto/config": "^7.0.0-rc.
|
|
30
|
-
"@travetto/schema": "^7.0.0-rc.
|
|
31
|
-
"@travetto/web": "^7.0.0-rc.
|
|
29
|
+
"@travetto/config": "^7.0.0-rc.3",
|
|
30
|
+
"@travetto/schema": "^7.0.0-rc.3",
|
|
31
|
+
"@travetto/web": "^7.0.0-rc.4",
|
|
32
32
|
"openapi3-ts": "^4.5.0",
|
|
33
33
|
"yaml": "^2.8.1"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@travetto/cli": "^7.0.0-rc.
|
|
36
|
+
"@travetto/cli": "^7.0.0-rc.3"
|
|
37
37
|
},
|
|
38
38
|
"peerDependenciesMeta": {
|
|
39
39
|
"@travetto/cli": {
|
package/src/config.ts
CHANGED
|
@@ -73,7 +73,7 @@ export class ApiSpecConfig {
|
|
|
73
73
|
this.persist = false;
|
|
74
74
|
} else {
|
|
75
75
|
this.output = path.resolve(Runtime.mainSourcePath, this.output);
|
|
76
|
-
this.persist ??= Runtime.
|
|
76
|
+
this.persist ??= !Runtime.production;
|
|
77
77
|
}
|
|
78
78
|
if (this.persist) {
|
|
79
79
|
if (!/[.](json|ya?ml)$/.test(this.output)) { // Assume a folder
|
package/src/generate.ts
CHANGED
|
@@ -12,7 +12,7 @@ import { ApiSpecConfig } from './config.ts';
|
|
|
12
12
|
|
|
13
13
|
const DEFINITION = '#/components/schemas';
|
|
14
14
|
|
|
15
|
-
const isInputConfig = (value: object): value is SchemaInputConfig => !!value && '
|
|
15
|
+
const isInputConfig = (value: object): value is SchemaInputConfig => !!value && 'class' in value && 'type' in value;
|
|
16
16
|
const isFieldConfig = (value: object): value is SchemaFieldConfig => isInputConfig(value) && 'name' in value;
|
|
17
17
|
|
|
18
18
|
type GeneratedSpec = {
|
|
@@ -138,19 +138,19 @@ export class OpenapiVisitor implements ControllerVisitor<GeneratedSpec> {
|
|
|
138
138
|
}
|
|
139
139
|
config.description = input.description;
|
|
140
140
|
if (input.match) {
|
|
141
|
-
config.pattern = input.match.
|
|
141
|
+
config.pattern = input.match.regex!.source;
|
|
142
142
|
}
|
|
143
143
|
if (input.maxlength) {
|
|
144
|
-
config.maxLength = input.maxlength.
|
|
144
|
+
config.maxLength = input.maxlength.limit;
|
|
145
145
|
}
|
|
146
146
|
if (input.minlength) {
|
|
147
|
-
config.minLength = input.minlength.
|
|
147
|
+
config.minLength = input.minlength.limit;
|
|
148
148
|
}
|
|
149
149
|
if (input.min) {
|
|
150
|
-
config.minimum = typeof input.min.
|
|
150
|
+
config.minimum = typeof input.min.limit === 'number' ? input.min.limit : input.min.limit.getTime();
|
|
151
151
|
}
|
|
152
152
|
if (input.max) {
|
|
153
|
-
config.maximum = typeof input.max.
|
|
153
|
+
config.maximum = typeof input.max.limit === 'number' ? input.max.limit : input.max.limit.getTime();
|
|
154
154
|
}
|
|
155
155
|
if (input.enum) {
|
|
156
156
|
config.enum = input.enum.values;
|
|
@@ -314,9 +314,7 @@ export class OpenapiVisitor implements ControllerVisitor<GeneratedSpec> {
|
|
|
314
314
|
const code = Object.keys(bodyConfig.content).length ? 200 : 201;
|
|
315
315
|
apiConfig.responses![code] = bodyConfig;
|
|
316
316
|
|
|
317
|
-
const
|
|
318
|
-
|
|
319
|
-
for (const param of methodSchema.parameters) {
|
|
317
|
+
for (const param of schema.parameters) {
|
|
320
318
|
const result = this.#processEndpointParam(endpoint, endpoint.parameters[param.index] ?? {}, param);
|
|
321
319
|
if (result) {
|
|
322
320
|
if ('parameters' in result) {
|
package/src/service.ts
CHANGED
|
@@ -3,9 +3,7 @@ import { stringify } from 'yaml';
|
|
|
3
3
|
|
|
4
4
|
import { BinaryUtil } from '@travetto/runtime';
|
|
5
5
|
import { Injectable, Inject } from '@travetto/di';
|
|
6
|
-
import {
|
|
7
|
-
import { SchemaRegistryIndex } from '@travetto/schema';
|
|
8
|
-
import { Registry } from '@travetto/registry';
|
|
6
|
+
import { ControllerVisitUtil, WebConfig } from '@travetto/web';
|
|
9
7
|
|
|
10
8
|
import { ApiHostConfig, ApiInfoConfig, ApiSpecConfig } from './config.ts';
|
|
11
9
|
import { OpenapiVisitor } from './generate.ts';
|
|
@@ -44,9 +42,6 @@ export class OpenApiService {
|
|
|
44
42
|
* Initialize after schemas are readied
|
|
45
43
|
*/
|
|
46
44
|
async postConstruct(): Promise<void> {
|
|
47
|
-
Registry.onClassChange(() => this.resetSpec(), ControllerRegistryIndex);
|
|
48
|
-
Registry.onClassChange(() => this.resetSpec(), SchemaRegistryIndex);
|
|
49
|
-
|
|
50
45
|
if (!this.apiHostConfig.servers && this.webConfig.baseUrl) {
|
|
51
46
|
this.apiHostConfig.servers = [{ url: this.webConfig.baseUrl }];
|
|
52
47
|
}
|
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, Runtime } from '@travetto/runtime';
|
|
5
|
+
import { ExecUtil, JSONUtil, Runtime } from '@travetto/runtime';
|
|
6
6
|
import { cliTpl } from '@travetto/cli';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -24,7 +24,7 @@ export class OpenApiClientHelp {
|
|
|
24
24
|
await fs.mkdir(path.dirname(formatCache), { recursive: true });
|
|
25
25
|
await fs.writeFile(formatCache, JSON.stringify([...lines.toSorted(),]));
|
|
26
26
|
}
|
|
27
|
-
const list: string[] =
|
|
27
|
+
const list: string[] = await JSONUtil.readFile(formatCache);
|
|
28
28
|
return list;
|
|
29
29
|
}
|
|
30
30
|
|