forked from loafle/openapi-generator-original
Use static model factory methods
The `constructFromObject` factory methods should be class methods (or "static" methods), not instance methods. With this commit, ApiClient no longer calls the model constructors directly. Instead, it calls the new static factory method to get the new instance. If there is no data on the top level, null is returned. It is still possible for users to call the model constructors directly, of course.
This commit is contained in:
@@ -250,8 +250,7 @@
|
||||
default:
|
||||
if (typeof type === 'function') {
|
||||
// for model type like: User
|
||||
var model = new type();
|
||||
model.constructFromObject(data);
|
||||
var model = type.constructFromObject(data);
|
||||
return model;
|
||||
} else if (Array.isArray(type)) {
|
||||
// for array type like: ['String']
|
||||
|
||||
Reference in New Issue
Block a user