openapi-ts-generator 5.222.2 → 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 +8 -6
- package/package.json +1 -1
package/openapidoc-converter.js
CHANGED
|
@@ -152,20 +152,22 @@ var OpenApiDocConverter = /** @class */ (function () {
|
|
|
152
152
|
};
|
|
153
153
|
};
|
|
154
154
|
OpenApiDocConverter.prototype.getInitialValue = function (propertyName, schemaWrapperInfo) {
|
|
155
|
-
var _a;
|
|
155
|
+
var _a, _b;
|
|
156
156
|
var typescriptType = this.getPropertyTypeScriptType(schemaWrapperInfo);
|
|
157
157
|
var isRequired = this.getIsRequired(propertyName, schemaWrapperInfo);
|
|
158
|
-
|
|
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];
|
|
159
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]);
|
|
160
|
-
if (
|
|
162
|
+
if (!isRequired) {
|
|
163
|
+
return 'null';
|
|
164
|
+
}
|
|
165
|
+
else if (defaultValue && refObject.enum) {
|
|
161
166
|
return "".concat(schemaWrapperInfo.propertyReferenceObject['$ref'], ".").concat(defaultValue.split(' ').pop());
|
|
162
167
|
}
|
|
163
168
|
else if (defaultValue) {
|
|
164
169
|
return "'".concat(defaultValue.split(' ').pop(), "'");
|
|
165
170
|
}
|
|
166
|
-
else if (!isRequired) {
|
|
167
|
-
return 'null';
|
|
168
|
-
}
|
|
169
171
|
else if (typescriptType === 'Date') {
|
|
170
172
|
return 'new Date()';
|
|
171
173
|
}
|
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",
|