@travetto/openapi 3.1.3 → 3.1.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 +5 -6
- package/package.json +5 -5
- package/src/spec-generate.ts +14 -1
package/README.md
CHANGED
|
@@ -69,7 +69,7 @@ export class ApiHostConfig {
|
|
|
69
69
|
/**
|
|
70
70
|
* OpenAPI Version
|
|
71
71
|
*/
|
|
72
|
-
openapi = '3.
|
|
72
|
+
openapi = '3.0.0';
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
/**
|
|
@@ -95,10 +95,10 @@ export class ApiSpecConfig {
|
|
|
95
95
|
exposeAllSchemas: boolean = false;
|
|
96
96
|
|
|
97
97
|
async postConstruct(): Promise<void> {
|
|
98
|
-
this.output = path.resolve(this.output);
|
|
99
98
|
if (!this.output || this.output === '-') {
|
|
100
99
|
this.persist = false;
|
|
101
100
|
} else {
|
|
101
|
+
this.output = path.resolve(RootIndex.mainModule.sourcePath, this.output);
|
|
102
102
|
this.persist ??= GlobalEnv.dynamic;
|
|
103
103
|
}
|
|
104
104
|
if (this.persist) {
|
|
@@ -152,10 +152,9 @@ Options:
|
|
|
152
152
|
|
|
153
153
|
Available Presets
|
|
154
154
|
----------------------------------
|
|
155
|
-
* @travetto/
|
|
156
|
-
* @travetto/
|
|
157
|
-
* @travetto/
|
|
158
|
-
* @travetto/fetch -- typescript-fetch
|
|
155
|
+
* @travetto/angular14 -- typescript-angular supportsES6=true,stringEnums=true,ngVersion=14.0,fileNaming=kebab-case
|
|
156
|
+
* @travetto/angular15 -- typescript-angular supportsES6=true,stringEnums=true,ngVersion=15.0,fileNaming=kebab-case
|
|
157
|
+
* @travetto/fetch -- typescript-fetch stringEnums=true
|
|
159
158
|
```
|
|
160
159
|
|
|
161
160
|
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": "3.1.
|
|
3
|
+
"version": "3.1.4",
|
|
4
4
|
"description": "OpenAPI integration support for the Travetto framework",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"rest",
|
|
@@ -26,14 +26,14 @@
|
|
|
26
26
|
"directory": "module/openapi"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@travetto/config": "^3.1.
|
|
30
|
-
"@travetto/rest": "^3.1.
|
|
31
|
-
"@travetto/schema": "^3.1.
|
|
29
|
+
"@travetto/config": "^3.1.2",
|
|
30
|
+
"@travetto/rest": "^3.1.2",
|
|
31
|
+
"@travetto/schema": "^3.1.2",
|
|
32
32
|
"@travetto/yaml": "^3.1.1",
|
|
33
33
|
"openapi3-ts": "^3.1.2"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@travetto/cli": "^3.1.
|
|
36
|
+
"@travetto/cli": "^3.1.2"
|
|
37
37
|
},
|
|
38
38
|
"peerDependenciesMeta": {
|
|
39
39
|
"@travetto/cli": {
|
package/src/spec-generate.ts
CHANGED
|
@@ -5,6 +5,7 @@ import type {
|
|
|
5
5
|
} from 'openapi3-ts';
|
|
6
6
|
|
|
7
7
|
import { ControllerRegistry, EndpointConfig, ControllerConfig, ParamConfig, EndpointIOType } from '@travetto/rest';
|
|
8
|
+
import { RootIndex } from '@travetto/manifest';
|
|
8
9
|
import { Class } from '@travetto/base';
|
|
9
10
|
import { SchemaRegistry, FieldConfig } from '@travetto/schema';
|
|
10
11
|
import { AllViewⲐ } from '@travetto/schema/src/internal/types';
|
|
@@ -224,9 +225,21 @@ export class SpecGenerator {
|
|
|
224
225
|
properties[fieldName] = this.#processSchemaField(def.schema[fieldName], required);
|
|
225
226
|
}
|
|
226
227
|
|
|
228
|
+
const extra: Record<string, unknown> = {};
|
|
229
|
+
if (RootIndex.getFunctionMetadata(type)?.abstract) {
|
|
230
|
+
const map = SchemaRegistry.getSubTypesForClass(type);
|
|
231
|
+
if (map) {
|
|
232
|
+
extra.oneOf = [...new Set(map.values())].map(c => {
|
|
233
|
+
this.#processSchema(c);
|
|
234
|
+
return this.#getType(c);
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
227
239
|
Object.assign(this.#allSchemas[typeId], {
|
|
228
240
|
properties,
|
|
229
|
-
...(required.length ? { required } : {})
|
|
241
|
+
...(required.length ? { required } : {}),
|
|
242
|
+
...extra
|
|
230
243
|
});
|
|
231
244
|
} else {
|
|
232
245
|
this.#allSchemas[typeId] = { title: typeId };
|