openapi-ts-generator 5.221.5 → 5.223.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/openapidoc-converter.js
CHANGED
|
@@ -155,14 +155,19 @@ var OpenApiDocConverter = /** @class */ (function () {
|
|
|
155
155
|
var _a, _b;
|
|
156
156
|
var typescriptType = this.getPropertyTypeScriptType(schemaWrapperInfo);
|
|
157
157
|
var isRequired = this.getIsRequired(propertyName, schemaWrapperInfo);
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
else if (!isRequired) {
|
|
158
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
159
|
+
var refName = (((_a = schemaWrapperInfo === null || schemaWrapperInfo === void 0 ? void 0 : schemaWrapperInfo.componentSchemaObject) === null || _a === void 0 ? void 0 : _a.properties) || {})[propertyName].$ref;
|
|
160
|
+
var refObject = (((_b = this.apiDocument.components) === null || _b === void 0 ? void 0 : _b.schemas) || {})[refName];
|
|
161
|
+
var defaultValue = (schemaWrapperInfo.componentSchemaObject.default || (refObject === null || refObject === void 0 ? void 0 : refObject.default) || ((refObject === null || refObject === void 0 ? void 0 : refObject.enum) || [])[0]);
|
|
162
|
+
if (!isRequired) {
|
|
164
163
|
return 'null';
|
|
165
164
|
}
|
|
165
|
+
else if (defaultValue && refObject.enum) {
|
|
166
|
+
return "".concat(schemaWrapperInfo.propertyReferenceObject['$ref'], ".").concat(defaultValue.split(' ').pop());
|
|
167
|
+
}
|
|
168
|
+
else if (defaultValue) {
|
|
169
|
+
return "'".concat(defaultValue.split(' ').pop(), "'");
|
|
170
|
+
}
|
|
166
171
|
else if (typescriptType === 'Date') {
|
|
167
172
|
return 'new Date()';
|
|
168
173
|
}
|
|
@@ -185,13 +190,15 @@ var OpenApiDocConverter = /** @class */ (function () {
|
|
|
185
190
|
var required = this.getIsRequired(propertyName, schemaWrapperInfo);
|
|
186
191
|
var validatorCount = this.getValidatorCount(propertyName, schemaWrapperInfo);
|
|
187
192
|
var initialValue = this.getInitialValue(propertyName, schemaWrapperInfo);
|
|
193
|
+
var typeName = this.parseRef(schemaWrapperInfo);
|
|
188
194
|
return {
|
|
189
195
|
required: required,
|
|
190
196
|
name: propertyName,
|
|
191
197
|
initialValue: initialValue,
|
|
192
198
|
snakeCaseName: _.snakeCase(propertyName).toUpperCase(),
|
|
193
|
-
referenceTypeName:
|
|
194
|
-
typeScriptType:
|
|
199
|
+
referenceTypeName: typeName,
|
|
200
|
+
typeScriptType: typeName,
|
|
201
|
+
kebabCasedTypeScriptType: (0, lodash_1.kebabCase)(typeName),
|
|
195
202
|
isArray: false,
|
|
196
203
|
isEnum: (propertySchema.enum || []).length > 0,
|
|
197
204
|
hasValidators: validatorCount > 0,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openapi-ts-generator",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.223.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",
|
|
@@ -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{{#
|
|
10
|
-
import { {{
|
|
11
|
-
import { I{{
|
|
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({
|