@travetto/openapi 3.2.0-rc.0 → 3.2.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/openapi",
3
- "version": "3.2.0-rc.0",
3
+ "version": "3.2.1",
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": "^3.2.0-rc.0",
30
- "@travetto/rest": "^3.2.0-rc.0",
31
- "@travetto/schema": "^3.2.0-rc.0",
32
- "@travetto/yaml": "^3.2.0-rc.0",
29
+ "@travetto/config": "^3.2.0",
30
+ "@travetto/rest": "^3.2.1",
31
+ "@travetto/schema": "^3.2.0",
32
+ "@travetto/yaml": "^3.2.0",
33
33
  "openapi3-ts": "^3.2.0"
34
34
  },
35
35
  "peerDependencies": {
36
- "@travetto/cli": "^3.2.0-rc.0",
37
- "@travetto/command": "^3.2.0-rc.0"
36
+ "@travetto/cli": "^3.2.0",
37
+ "@travetto/command": "^3.2.0"
38
38
  },
39
39
  "peerDependenciesMeta": {
40
40
  "@travetto/cli": {
@@ -41,22 +41,6 @@ export class OpenapiVisitor implements ControllerVisitor<GeneratedSpec> {
41
41
  this.#config = config;
42
42
  }
43
43
 
44
- /**
45
- * Get type id
46
- * @param cls
47
- */
48
- #getTypeId(cls: Class): string {
49
- return cls.name?.replace('Ⲑsyn', '');
50
- }
51
-
52
- /**
53
- * Get tag name
54
- * @param cls
55
- */
56
- #getTypeTag(cls: Class): string {
57
- return cls.name.replace(/(Rest|Controller)$/, '');
58
- }
59
-
60
44
  /**
61
45
  * Build response object
62
46
  */
@@ -111,7 +95,7 @@ export class OpenapiVisitor implements ControllerVisitor<GeneratedSpec> {
111
95
  const out: Record<string, unknown> = {};
112
96
  // Handle nested types
113
97
  if (SchemaRegistry.has(field.type)) {
114
- const id = this.#getTypeId(field.type);
98
+ const id = SchemaRegistry.get(field.type).externalName;
115
99
  // Exposing
116
100
  this.#schemas[id] = this.#allSchemas[id];
117
101
  out.$ref = `${DEFINITION}/${id}`;
@@ -209,8 +193,7 @@ export class OpenapiVisitor implements ControllerVisitor<GeneratedSpec> {
209
193
  }
210
194
 
211
195
  const cls = type.class;
212
-
213
- const typeId = this.#getTypeId(cls);
196
+ const typeId = type.externalName;
214
197
 
215
198
  if (!this.#allSchemas[typeId]) {
216
199
  const config = SchemaRegistry.get(cls);
@@ -270,7 +253,7 @@ export class OpenapiVisitor implements ControllerVisitor<GeneratedSpec> {
270
253
  description: ''
271
254
  };
272
255
  } else {
273
- const typeId = this.#getTypeId(body.type);
256
+ const typeId = SchemaRegistry.get(body.type)?.externalName ?? body.type.name;
274
257
  const typeRef = SchemaRegistry.has(body.type) ? this.#getType(body.type) : { type: body.type.name.toLowerCase() };
275
258
  return {
276
259
  content: {
@@ -322,7 +305,7 @@ export class OpenapiVisitor implements ControllerVisitor<GeneratedSpec> {
322
305
  return;
323
306
  }
324
307
 
325
- const tagName = ctrl.class.name.replace(/(Rest|Controller)$/, '');
308
+ const tagName = ctrl.externalName;
326
309
 
327
310
  const op: OperationObject = {
328
311
  tags: [tagName],
@@ -369,7 +352,7 @@ export class OpenapiVisitor implements ControllerVisitor<GeneratedSpec> {
369
352
  return;
370
353
  }
371
354
  this.#tags.push({
372
- name: this.#getTypeTag(controller.class),
355
+ name: controller.externalName,
373
356
  description: controller.description || controller.title
374
357
  });
375
358
  }