openapi-ts-generator 5.262.4 → 5.277.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.
@@ -0,0 +1,6 @@
1
+ export interface IEnumValue {
2
+ key?: number;
3
+ name: string;
4
+ titleName: string;
5
+ snakeCaseName: string;
6
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,4 +1,5 @@
1
1
  import { ReferenceObject, SchemaObject } from 'openapi3-ts';
2
+ import { IEnumValue } from './enum-value';
2
3
  import { IGeneratorOptions } from './generator-options';
3
4
  import { IReferenceProperty } from './reference-property';
4
5
  import { IValueProperty } from './value-property';
@@ -6,11 +7,7 @@ export declare class SchemaWrapperInfo {
6
7
  propertySchemaObject: SchemaObject;
7
8
  propertyReferenceObject: ReferenceObject;
8
9
  isEnum?: boolean;
9
- readonly enumValues: (string | {
10
- key?: number;
11
- name: string;
12
- titleName: string;
13
- })[];
10
+ readonly enumValues: (string | IEnumValue)[];
14
11
  readonly componentSchemaObject: SchemaObject;
15
12
  readonly valueProperties: IValueProperty[];
16
13
  referenceProperties: IReferenceProperty[];
@@ -58,7 +58,9 @@ var OpenApiDocConverter = /** @class */ (function () {
58
58
  var entity = {
59
59
  isEnum: schemaWrapperInfo.isEnum,
60
60
  enumValues: schemaWrapperInfo.enumValues.map(function (t) {
61
- return typeof t === 'string' || t instanceof String ? t : __assign(__assign({}, t), { key: t.key || 0 });
61
+ return typeof t === 'string' || t instanceof String
62
+ ? t
63
+ : __assign(__assign({}, t), { key: t.key || 0 });
62
64
  }),
63
65
  name: schemaName,
64
66
  kebabCasedName: (0, lodash_1.kebabCase)(schemaName),
@@ -81,7 +83,12 @@ var OpenApiDocConverter = /** @class */ (function () {
81
83
  var _a, _b;
82
84
  var key = (_a = _this.startNumberregex.exec(x)) === null || _a === void 0 ? void 0 : _a.at(0);
83
85
  var name = ((_b = _this.endAlphaNumRegex.exec(x)) === null || _b === void 0 ? void 0 : _b.at(0)) || '';
84
- return { key: key ? +key : 0, name: name, titleName: (0, lodash_1.startCase)(name) };
86
+ return {
87
+ key: key ? +key : 0,
88
+ name: name,
89
+ titleName: (0, lodash_1.startCase)(name),
90
+ snakeCaseName: (0, lodash_1.snakeCase)(name).toUpperCase(),
91
+ };
85
92
  }));
86
93
  };
87
94
  OpenApiDocConverter.prototype.buildSchemaWrapperInfo = function (parentTypeName, schemaWrapperInfo) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openapi-ts-generator",
3
- "version": "5.262.4",
3
+ "version": "5.277.2",
4
4
  "description": "Based on swagger-ts-generator, this is a type script model generator specifically for services with OpenApi spec documentation.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -10,10 +10,24 @@
10
10
  * {{description}}
11
11
  */
12
12
  {{/if}}export enum {{{name}}} {
13
- {{#enumValues}}
13
+ {{#enumValues}}{{#if description}}/**
14
+ * {{description}}
15
+ */
16
+ {{/if}}
14
17
  {{name}} = {{key}},
15
18
  {{/enumValues}}
16
19
  }
20
+ {{#if description}}/**
21
+ * {{description}}
22
+ */
23
+ {{/if}}export enum {{name}}Names {
24
+ {{#enumValues}}
25
+ {{#if description}}/**
26
+ * {{description}}
27
+ */
28
+ {{/if}} {{snakeCaseName}} = '{{name}}',
29
+ {{/enumValues}}
30
+ }
17
31
 
18
32
  export const {{{camelSingularName}}}Values = [
19
33
  {{#enumValues}}