@travetto/openapi 3.4.1 → 3.4.2
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/spec-generate.ts +8 -5
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@ All of the high level configurations can be found in the following structure:
|
|
|
24
24
|
|
|
25
25
|
**Code: Config: OpenAPI Configuration**
|
|
26
26
|
```typescript
|
|
27
|
-
import type { ServerObject, ContactObject, LicenseObject } from 'openapi3-ts/
|
|
27
|
+
import type { ServerObject, ContactObject, LicenseObject } from 'openapi3-ts/oas31';
|
|
28
28
|
|
|
29
29
|
import { Config } from '@travetto/config';
|
|
30
30
|
import { path, RootIndex } from '@travetto/manifest';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/openapi",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.2",
|
|
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.4.
|
|
30
|
-
"@travetto/rest": "^3.4.
|
|
31
|
-
"@travetto/schema": "^3.4.
|
|
29
|
+
"@travetto/config": "^3.4.2",
|
|
30
|
+
"@travetto/rest": "^3.4.2",
|
|
31
|
+
"@travetto/schema": "^3.4.2",
|
|
32
32
|
"@travetto/yaml": "^3.4.1",
|
|
33
33
|
"openapi3-ts": "^4.1.2"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@travetto/cli": "^3.4.
|
|
36
|
+
"@travetto/cli": "^3.4.4",
|
|
37
37
|
"@travetto/command": "^3.4.1"
|
|
38
38
|
},
|
|
39
39
|
"peerDependenciesMeta": {
|
package/src/config.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ServerObject, ContactObject, LicenseObject } from 'openapi3-ts/
|
|
1
|
+
import type { ServerObject, ContactObject, LicenseObject } from 'openapi3-ts/oas31';
|
|
2
2
|
|
|
3
3
|
import { Config } from '@travetto/config';
|
|
4
4
|
import { path, RootIndex } from '@travetto/manifest';
|
package/src/spec-generate.ts
CHANGED
|
@@ -7,7 +7,7 @@ import type {
|
|
|
7
7
|
import { EndpointConfig, ControllerConfig, ParamConfig, EndpointIOType, ControllerVisitor } from '@travetto/rest';
|
|
8
8
|
import { RootIndex } from '@travetto/manifest';
|
|
9
9
|
import { Class } from '@travetto/base';
|
|
10
|
-
import { SchemaRegistry, FieldConfig, ClassConfig } from '@travetto/schema';
|
|
10
|
+
import { SchemaRegistry, FieldConfig, ClassConfig, SchemaNameResolver } from '@travetto/schema';
|
|
11
11
|
import { AllViewⲐ } from '@travetto/schema/src/internal/types';
|
|
12
12
|
|
|
13
13
|
import { ApiSpecConfig } from './config';
|
|
@@ -37,6 +37,8 @@ export class OpenapiVisitor implements ControllerVisitor<GeneratedSpec> {
|
|
|
37
37
|
|
|
38
38
|
#config: Partial<ApiSpecConfig> = {};
|
|
39
39
|
|
|
40
|
+
#nameResolver = new SchemaNameResolver();
|
|
41
|
+
|
|
40
42
|
constructor(config: Partial<ApiSpecConfig> = {}) {
|
|
41
43
|
this.#config = config;
|
|
42
44
|
}
|
|
@@ -95,7 +97,7 @@ export class OpenapiVisitor implements ControllerVisitor<GeneratedSpec> {
|
|
|
95
97
|
const out: Record<string, unknown> = {};
|
|
96
98
|
// Handle nested types
|
|
97
99
|
if (SchemaRegistry.has(field.type)) {
|
|
98
|
-
const id = SchemaRegistry.get(field.type)
|
|
100
|
+
const id = this.#nameResolver.getName(SchemaRegistry.get(field.type));
|
|
99
101
|
// Exposing
|
|
100
102
|
this.#schemas[id] = this.#allSchemas[id];
|
|
101
103
|
out.$ref = `${DEFINITION}/${id}`;
|
|
@@ -193,7 +195,7 @@ export class OpenapiVisitor implements ControllerVisitor<GeneratedSpec> {
|
|
|
193
195
|
}
|
|
194
196
|
|
|
195
197
|
const cls = type.class;
|
|
196
|
-
const typeId = type
|
|
198
|
+
const typeId = this.#nameResolver.getName(type);
|
|
197
199
|
|
|
198
200
|
if (!this.#allSchemas[typeId]) {
|
|
199
201
|
const config = SchemaRegistry.get(cls);
|
|
@@ -253,8 +255,9 @@ export class OpenapiVisitor implements ControllerVisitor<GeneratedSpec> {
|
|
|
253
255
|
description: ''
|
|
254
256
|
};
|
|
255
257
|
} else {
|
|
256
|
-
const
|
|
257
|
-
const
|
|
258
|
+
const cls = SchemaRegistry.get(body.type);
|
|
259
|
+
const typeId = cls ? this.#nameResolver.getName(cls) : body.type.name;
|
|
260
|
+
const typeRef = cls ? this.#getType(body.type) : { type: body.type.name.toLowerCase() };
|
|
258
261
|
return {
|
|
259
262
|
content: {
|
|
260
263
|
[mime ?? 'application/json']: {
|