openapi-ts-generator 5.221.2 → 5.221.7

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.
@@ -46,6 +46,7 @@ export interface IReferenceProperty {
46
46
  snakeCaseName: string;
47
47
  referenceTypeName: string;
48
48
  typeScriptType: string;
49
+ kebabCasedTypeScriptType: string;
49
50
  hasValidators: boolean;
50
51
  isArray: boolean;
51
52
  required: boolean;
@@ -152,11 +152,11 @@ var OpenApiDocConverter = /** @class */ (function () {
152
152
  };
153
153
  };
154
154
  OpenApiDocConverter.prototype.getInitialValue = function (propertyName, schemaWrapperInfo) {
155
- var _a, _b;
155
+ var _a;
156
156
  var typescriptType = this.getPropertyTypeScriptType(schemaWrapperInfo);
157
157
  var isRequired = this.getIsRequired(propertyName, schemaWrapperInfo);
158
- var defaultValue = (schemaWrapperInfo.componentSchemaObject.default ||
159
- ((_b = (((_a = this.apiDocument.components) === null || _a === void 0 ? void 0 : _a.schemas) || {})[schemaWrapperInfo.propertyReferenceObject['$ref']]) === null || _b === void 0 ? void 0 : _b.default));
158
+ var refObject = (((_a = this.apiDocument.components) === null || _a === void 0 ? void 0 : _a.schemas) || {})[schemaWrapperInfo.propertyReferenceObject['$ref']];
159
+ var defaultValue = (schemaWrapperInfo.componentSchemaObject.default || (refObject === null || refObject === void 0 ? void 0 : refObject.default) || ((refObject === null || refObject === void 0 ? void 0 : refObject.enum) || [])[0]);
160
160
  if (defaultValue) {
161
161
  return "'".concat(defaultValue.split(' ').pop(), "'");
162
162
  }
@@ -169,6 +169,9 @@ var OpenApiDocConverter = /** @class */ (function () {
169
169
  else if (typescriptType === 'boolean') {
170
170
  return 'false';
171
171
  }
172
+ else if (typescriptType === 'number') {
173
+ return '0';
174
+ }
172
175
  else {
173
176
  return "''";
174
177
  }
@@ -182,13 +185,15 @@ var OpenApiDocConverter = /** @class */ (function () {
182
185
  var required = this.getIsRequired(propertyName, schemaWrapperInfo);
183
186
  var validatorCount = this.getValidatorCount(propertyName, schemaWrapperInfo);
184
187
  var initialValue = this.getInitialValue(propertyName, schemaWrapperInfo);
188
+ var typeName = this.parseRef(schemaWrapperInfo);
185
189
  return {
186
190
  required: required,
187
191
  name: propertyName,
188
192
  initialValue: initialValue,
189
193
  snakeCaseName: _.snakeCase(propertyName).toUpperCase(),
190
- referenceTypeName: this.parseRef(schemaWrapperInfo),
191
- typeScriptType: this.parseRef(schemaWrapperInfo),
194
+ referenceTypeName: typeName,
195
+ typeScriptType: typeName,
196
+ kebabCasedTypeScriptType: (0, lodash_1.kebabCase)(typeName),
192
197
  isArray: false,
193
198
  isEnum: (propertySchema.enum || []).length > 0,
194
199
  hasValidators: validatorCount > 0,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openapi-ts-generator",
3
- "version": "5.221.2",
3
+ "version": "5.221.7",
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",
@@ -6,9 +6,9 @@
6
6
  * For issues or feature request, visit the repo: https://github.com/ikemtz/openapi-ts-generator
7
7
  * Do not edit.
8
8
  */
9
- import { FormControl, FormArray, FormGroup, Validators } from '@angular/forms'; //NOSONAR{{#if importTypes}}{{#importTypes}}{{#if isEnum}}
10
- import { {{name}} } from './{{kebabCasedTypeName}}.enum'; //NOSONAR{{else}}
11
- import { I{{name}} } from './{{kebabCasedTypeName}}.model'; //NOSONAR{{/if}}{{/importTypes}}{{/if}}
9
+ import { FormControl, FormArray, FormGroup, Validators } from '@angular/forms'; //NOSONAR{{#referenceProperties}}{{#unless isArray}}{{#if isEnum}}
10
+ import { {{typeScriptType}} } from './{{kebabCasedTypeScriptType}}.enum';{{else}}
11
+ import { I{{typeScriptType}} } from './{{kebabCasedTypeScriptType}}.model';{{/if}}{{/unless}}{{/referenceProperties}}
12
12
 
13
13
  export function {{name}}FormGroupFac(): FormGroup {
14
14
  return new FormGroup({
@@ -17,7 +17,7 @@ export function {{name}}FormGroupFac(): FormGroup {
17
17
  {{#if hasMultipleValidators}}
18
18
  {{name}}: new FormControl([], { validators: Validators.compose([{{#if required}}Validators.required, {{/if}}{{minLengthValidator "valueProperties"}}{{maxLengthValidator "valueProperties"}}{{minimumValidator "valueProperties"}}{{maximumValidator "valueProperties"}}{{{patternValidator "valueProperties"}}}]) })),
19
19
  {{else}}
20
- {{name}}: new FormControl([]{{#if hasValidators}}, { validators: {{#if required}}Validators.required{{/if}}{{minLengthValidator "valueProperties"}}{{maxLengthValidator "valueProperties"}}{{minimumValidator "valueProperties"}}{{maximumValidator "valueProperties"}}{{{patternValidator "valueProperties"}}}{{#if required}}, nonNullable: true{{/if}} }{{/if}}),
20
+ {{name}}: new FormControl([]{{#if hasValidators}}, { validators: {{#if required}}Validators.required{{/if}}{{minLengthValidator "valueProperties"}}{{maxLengthValidator "valueProperties"}}{{minimumValidator "valueProperties"}}{{maximumValidator "valueProperties"}}{{{patternValidator "valueProperties"}}} }{{/if}}),
21
21
  {{/if}}
22
22
  {{else}}
23
23
  {{#if hasMultipleValidators}}
@@ -30,9 +30,9 @@ export function {{name}}FormGroupFac(): FormGroup {
30
30
  {{#referenceProperties}}
31
31
  {{#if isArray}}
32
32
  {{#if hasMultipleValidators}}
33
- {{name}}: new FormArray([], { validators: Validators.compose([{{#if required}}Validators.required, {{/if}}{{minLengthValidator "referenceProperties"}}{{maxLengthValidator "referenceProperties"}}{{minimumValidator "referenceProperties"}}{{maximumValidator "referenceProperties"}}{{{patternValidator "referenceProperties"}}}]){{#if required}}, nonNullable: true{{/if}} }),
33
+ {{name}}: new FormArray([], { validators: Validators.compose([{{#if required}}Validators.required, {{/if}}{{minLengthValidator "referenceProperties"}}{{maxLengthValidator "referenceProperties"}}{{minimumValidator "referenceProperties"}}{{maximumValidator "referenceProperties"}}{{{patternValidator "referenceProperties"}}}]) }),
34
34
  {{else}}
35
- {{name}}: new FormArray([]{{#if hasValidators}}, { validators: {{#if required}}Validators.required{{/if}}{{minLengthValidator "referenceProperties"}}{{maxLengthValidator "referenceProperties"}}{{minimumValidator "referenceProperties"}}{{maximumValidator "referenceProperties"}}{{{patternValidator "referenceProperties"}}}{{#if required}}, nonNullable: true{{/if}} } {{/if}}),
35
+ {{name}}: new FormArray([]{{#if hasValidators}}, { validators: {{#if required}}Validators.required{{/if}}{{minLengthValidator "referenceProperties"}}{{maxLengthValidator "referenceProperties"}}{{minimumValidator "referenceProperties"}}{{maximumValidator "referenceProperties"}}{{{patternValidator "referenceProperties"}}} } {{/if}}),
36
36
  {{/if}}
37
37
  {{else}}
38
38
  {{#if hasMultipleValidators}}