diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavascriptClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavascriptClientCodegen.java index 3bd7fe4ac74..60ad022d7d7 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavascriptClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavascriptClientCodegen.java @@ -231,6 +231,7 @@ public void preprocessSwagger(Swagger swagger) { supportingFiles.add(new SupportingFile("package.mustache", "", "package.json")); supportingFiles.add(new SupportingFile("index.mustache", sourceFolder, "index.js")); supportingFiles.add(new SupportingFile("ApiClient.mustache", sourceFolder, "ApiClient.js")); + supportingFiles.add(new SupportingFile("ApiModel.mustache", sourceFolder, "ApiModel.js")); } @Override diff --git a/modules/swagger-codegen/src/main/resources/Javascript/ApiModel.mustache b/modules/swagger-codegen/src/main/resources/Javascript/ApiModel.mustache new file mode 100644 index 00000000000..def8a04c402 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/Javascript/ApiModel.mustache @@ -0,0 +1,33 @@ +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define([], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + module.exports = factory(); + } else { + // Browser globals (root is window) + if (!root.{{moduleName}}) { + root.{{moduleName}} = {}; + } + root.{{moduleName}}.ApiModel = factory(); + } +}(this, function() { + 'use strict'; + + /** + Base class for all generated model classes, + containing common functionality. + **/ + var ApiModel = function(){} + ApiModel.prototype.toJson = function() { + return JSON.stringify(this); + } + + if (module) { + module.ApiModel = ApiModel; + } + + return ApiModel; + +})); diff --git a/modules/swagger-codegen/src/main/resources/Javascript/model.mustache b/modules/swagger-codegen/src/main/resources/Javascript/model.mustache index fd64156bb52..5631904b698 100644 --- a/modules/swagger-codegen/src/main/resources/Javascript/model.mustache +++ b/modules/swagger-codegen/src/main/resources/Javascript/model.mustache @@ -1,18 +1,18 @@ (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. - define([undefined, '../ApiClient'{{#imports}}, './{{import}}'{{/imports}}], factory); + define([undefined, '../ApiClient', '../ApiModel'{{#imports}}, './{{import}}'{{/imports}}], factory); } else if (typeof module === 'object' && module.exports) { // CommonJS-like environments that support module.exports, like Node. - module.exports = factory(undefined, require('../ApiClient'){{#imports}}, require('./{{import}}'){{/imports}}); + module.exports = factory(undefined, require('../ApiClient'), require('../ApiModel'){{#imports}}, require('./{{import}}'){{/imports}}); } else { // Browser globals (root is window) if (!root.{{moduleName}}) { root.{{moduleName}} = {}; } - factory(root.{{moduleName}}, root.{{moduleName}}.ApiClient{{#imports}}, root.{{moduleName}}.{{import}}{{/imports}}); + factory(root.{{moduleName}}, root.{{moduleName}}.ApiClient, root.{{moduleName}}.ApiModel{{#imports}}, root.{{moduleName}}.{{import}}{{/imports}}); } -}(this, function(module, ApiClient{{#imports}}, {{import}}{{/imports}}) { +}(this, function(module, ApiClient, ApiModel{{#imports}}, {{import}}{{/imports}}) { 'use strict'; {{#models}}{{#model}} @@ -31,6 +31,7 @@ * minimum: {{minimum}}{{/minimum}}{{#maximum}} * maximum: {{maximum}}{{/maximum}} **/ + ApiModel.call(this); this['{{baseName}}'] = {{#required}}{{name}}{{/required}}{{^required}}{{{defaultValue}}}{{/required}}; {{/vars}} }; @@ -69,10 +70,6 @@ {{/vars}} {{/omitModelMethods}} - {{classname}}.prototype.toJson = function() { - return JSON.stringify(this); - } - if (module) { module.{{classname}} = {{classname}}; } diff --git a/samples/client/petstore/javascript-promise/src/ApiModel.js b/samples/client/petstore/javascript-promise/src/ApiModel.js new file mode 100644 index 00000000000..95919b0524f --- /dev/null +++ b/samples/client/petstore/javascript-promise/src/ApiModel.js @@ -0,0 +1,33 @@ +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define([], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + module.exports = factory(); + } else { + // Browser globals (root is window) + if (!root.SwaggerPetstore) { + root.SwaggerPetstore = {}; + } + root.SwaggerPetstore.ApiModel = factory(); + } +}(this, function() { + 'use strict'; + + /** + Base class for all generated model classes, + containing common functionality. + **/ + var ApiModel = function(){} + ApiModel.prototype.toJson = function() { + return JSON.stringify(this); + } + + if (module) { + module.ApiModel = ApiModel; + } + + return ApiModel; + +})); diff --git a/samples/client/petstore/javascript-promise/src/model/Category.js b/samples/client/petstore/javascript-promise/src/model/Category.js index 26742d7036b..12526b7926c 100644 --- a/samples/client/petstore/javascript-promise/src/model/Category.js +++ b/samples/client/petstore/javascript-promise/src/model/Category.js @@ -1,18 +1,18 @@ (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. - define([undefined, '../ApiClient'], factory); + define([undefined, '../ApiClient', '../ApiModel'], factory); } else if (typeof module === 'object' && module.exports) { // CommonJS-like environments that support module.exports, like Node. - module.exports = factory(undefined, require('../ApiClient')); + module.exports = factory(undefined, require('../ApiClient'), require('../ApiModel')); } else { // Browser globals (root is window) if (!root.SwaggerPetstore) { root.SwaggerPetstore = {}; } - factory(root.SwaggerPetstore, root.SwaggerPetstore.ApiClient); + factory(root.SwaggerPetstore, root.SwaggerPetstore.ApiClient, root.SwaggerPetstore.ApiModel); } -}(this, function(module, ApiClient) { +}(this, function(module, ApiClient, ApiModel) { 'use strict'; @@ -24,11 +24,13 @@ /** * datatype: Integer **/ + ApiModel.call(this); this['id'] = null; /** * datatype: String **/ + ApiModel.call(this); this['name'] = null; }; @@ -50,6 +52,7 @@ } + /** * @return {Integer} **/ @@ -78,10 +81,7 @@ this['name'] = name; } - - Category.prototype.toJson = function() { - return JSON.stringify(this); - } + if (module) { module.Category = Category; diff --git a/samples/client/petstore/javascript-promise/src/model/Order.js b/samples/client/petstore/javascript-promise/src/model/Order.js index 0d5b90d319a..c2cf6980982 100644 --- a/samples/client/petstore/javascript-promise/src/model/Order.js +++ b/samples/client/petstore/javascript-promise/src/model/Order.js @@ -1,18 +1,18 @@ (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. - define([undefined, '../ApiClient'], factory); + define([undefined, '../ApiClient', '../ApiModel'], factory); } else if (typeof module === 'object' && module.exports) { // CommonJS-like environments that support module.exports, like Node. - module.exports = factory(undefined, require('../ApiClient')); + module.exports = factory(undefined, require('../ApiClient'), require('../ApiModel')); } else { // Browser globals (root is window) if (!root.SwaggerPetstore) { root.SwaggerPetstore = {}; } - factory(root.SwaggerPetstore, root.SwaggerPetstore.ApiClient); + factory(root.SwaggerPetstore, root.SwaggerPetstore.ApiClient, root.SwaggerPetstore.ApiModel); } -}(this, function(module, ApiClient) { +}(this, function(module, ApiClient, ApiModel) { 'use strict'; @@ -52,32 +52,38 @@ var StatusEnum = function StatusEnum() { /** * datatype: Integer **/ + ApiModel.call(this); this['id'] = null; /** * datatype: Integer **/ + ApiModel.call(this); this['petId'] = null; /** * datatype: Integer **/ + ApiModel.call(this); this['quantity'] = null; /** * datatype: Date **/ + ApiModel.call(this); this['shipDate'] = null; /** * Order Status * datatype: StatusEnum **/ + ApiModel.call(this); this['status'] = null; /** * datatype: Boolean **/ + ApiModel.call(this); this['complete'] = null; }; @@ -115,6 +121,7 @@ var StatusEnum = function StatusEnum() { } + /** * @return {Integer} **/ @@ -201,10 +208,7 @@ var StatusEnum = function StatusEnum() { this['complete'] = complete; } - - Order.prototype.toJson = function() { - return JSON.stringify(this); - } + if (module) { module.Order = Order; diff --git a/samples/client/petstore/javascript-promise/src/model/Pet.js b/samples/client/petstore/javascript-promise/src/model/Pet.js index 67bacb19390..7d3bd4b75b3 100644 --- a/samples/client/petstore/javascript-promise/src/model/Pet.js +++ b/samples/client/petstore/javascript-promise/src/model/Pet.js @@ -1,18 +1,18 @@ (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. - define([undefined, '../ApiClient', './Category', './Tag'], factory); + define([undefined, '../ApiClient', '../ApiModel', './Category', './Tag'], factory); } else if (typeof module === 'object' && module.exports) { // CommonJS-like environments that support module.exports, like Node. - module.exports = factory(undefined, require('../ApiClient'), require('./Category'), require('./Tag')); + module.exports = factory(undefined, require('../ApiClient'), require('../ApiModel'), require('./Category'), require('./Tag')); } else { // Browser globals (root is window) if (!root.SwaggerPetstore) { root.SwaggerPetstore = {}; } - factory(root.SwaggerPetstore, root.SwaggerPetstore.ApiClient, root.SwaggerPetstore.Category, root.SwaggerPetstore.Tag); + factory(root.SwaggerPetstore, root.SwaggerPetstore.ApiClient, root.SwaggerPetstore.ApiModel, root.SwaggerPetstore.Category, root.SwaggerPetstore.Tag); } -}(this, function(module, ApiClient, Category, Tag) { +}(this, function(module, ApiClient, ApiModel, Category, Tag) { 'use strict'; @@ -52,34 +52,40 @@ var StatusEnum = function StatusEnum() { /** * datatype: Integer **/ + ApiModel.call(this); this['id'] = null; /** * datatype: Category **/ + ApiModel.call(this); this['category'] = new Category(); /** * datatype: String * required **/ + ApiModel.call(this); this['name'] = name; /** * datatype: [String] * required **/ + ApiModel.call(this); this['photoUrls'] = photoUrls; /** * datatype: [Tag] **/ + ApiModel.call(this); this['tags'] = []; /** * pet status in the store * datatype: StatusEnum **/ + ApiModel.call(this); this['status'] = null; }; @@ -117,6 +123,7 @@ var StatusEnum = function StatusEnum() { } + /** * @return {Integer} **/ @@ -203,10 +210,7 @@ var StatusEnum = function StatusEnum() { this['status'] = status; } - - Pet.prototype.toJson = function() { - return JSON.stringify(this); - } + if (module) { module.Pet = Pet; diff --git a/samples/client/petstore/javascript-promise/src/model/Tag.js b/samples/client/petstore/javascript-promise/src/model/Tag.js index 563c1ee9df8..3843e76f779 100644 --- a/samples/client/petstore/javascript-promise/src/model/Tag.js +++ b/samples/client/petstore/javascript-promise/src/model/Tag.js @@ -1,18 +1,18 @@ (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. - define([undefined, '../ApiClient'], factory); + define([undefined, '../ApiClient', '../ApiModel'], factory); } else if (typeof module === 'object' && module.exports) { // CommonJS-like environments that support module.exports, like Node. - module.exports = factory(undefined, require('../ApiClient')); + module.exports = factory(undefined, require('../ApiClient'), require('../ApiModel')); } else { // Browser globals (root is window) if (!root.SwaggerPetstore) { root.SwaggerPetstore = {}; } - factory(root.SwaggerPetstore, root.SwaggerPetstore.ApiClient); + factory(root.SwaggerPetstore, root.SwaggerPetstore.ApiClient, root.SwaggerPetstore.ApiModel); } -}(this, function(module, ApiClient) { +}(this, function(module, ApiClient, ApiModel) { 'use strict'; @@ -24,11 +24,13 @@ /** * datatype: Integer **/ + ApiModel.call(this); this['id'] = null; /** * datatype: String **/ + ApiModel.call(this); this['name'] = null; }; @@ -50,6 +52,7 @@ } + /** * @return {Integer} **/ @@ -78,10 +81,7 @@ this['name'] = name; } - - Tag.prototype.toJson = function() { - return JSON.stringify(this); - } + if (module) { module.Tag = Tag; diff --git a/samples/client/petstore/javascript-promise/src/model/User.js b/samples/client/petstore/javascript-promise/src/model/User.js index 67c45561d3c..6c7a38c814b 100644 --- a/samples/client/petstore/javascript-promise/src/model/User.js +++ b/samples/client/petstore/javascript-promise/src/model/User.js @@ -1,18 +1,18 @@ (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. - define([undefined, '../ApiClient'], factory); + define([undefined, '../ApiClient', '../ApiModel'], factory); } else if (typeof module === 'object' && module.exports) { // CommonJS-like environments that support module.exports, like Node. - module.exports = factory(undefined, require('../ApiClient')); + module.exports = factory(undefined, require('../ApiClient'), require('../ApiModel')); } else { // Browser globals (root is window) if (!root.SwaggerPetstore) { root.SwaggerPetstore = {}; } - factory(root.SwaggerPetstore, root.SwaggerPetstore.ApiClient); + factory(root.SwaggerPetstore, root.SwaggerPetstore.ApiClient, root.SwaggerPetstore.ApiModel); } -}(this, function(module, ApiClient) { +}(this, function(module, ApiClient, ApiModel) { 'use strict'; @@ -24,42 +24,50 @@ /** * datatype: Integer **/ + ApiModel.call(this); this['id'] = null; /** * datatype: String **/ + ApiModel.call(this); this['username'] = null; /** * datatype: String **/ + ApiModel.call(this); this['firstName'] = null; /** * datatype: String **/ + ApiModel.call(this); this['lastName'] = null; /** * datatype: String **/ + ApiModel.call(this); this['email'] = null; /** * datatype: String **/ + ApiModel.call(this); this['password'] = null; /** * datatype: String **/ + ApiModel.call(this); this['phone'] = null; /** * User Status * datatype: Integer **/ + ApiModel.call(this); this['userStatus'] = null; }; @@ -105,6 +113,7 @@ } + /** * @return {Integer} **/ @@ -219,10 +228,7 @@ this['userStatus'] = userStatus; } - - User.prototype.toJson = function() { - return JSON.stringify(this); - } + if (module) { module.User = User; diff --git a/samples/client/petstore/javascript/src/ApiModel.js b/samples/client/petstore/javascript/src/ApiModel.js new file mode 100644 index 00000000000..95919b0524f --- /dev/null +++ b/samples/client/petstore/javascript/src/ApiModel.js @@ -0,0 +1,33 @@ +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define([], factory); + } else if (typeof module === 'object' && module.exports) { + // CommonJS-like environments that support module.exports, like Node. + module.exports = factory(); + } else { + // Browser globals (root is window) + if (!root.SwaggerPetstore) { + root.SwaggerPetstore = {}; + } + root.SwaggerPetstore.ApiModel = factory(); + } +}(this, function() { + 'use strict'; + + /** + Base class for all generated model classes, + containing common functionality. + **/ + var ApiModel = function(){} + ApiModel.prototype.toJson = function() { + return JSON.stringify(this); + } + + if (module) { + module.ApiModel = ApiModel; + } + + return ApiModel; + +})); diff --git a/samples/client/petstore/javascript/src/model/Category.js b/samples/client/petstore/javascript/src/model/Category.js index 26742d7036b..12526b7926c 100644 --- a/samples/client/petstore/javascript/src/model/Category.js +++ b/samples/client/petstore/javascript/src/model/Category.js @@ -1,18 +1,18 @@ (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. - define([undefined, '../ApiClient'], factory); + define([undefined, '../ApiClient', '../ApiModel'], factory); } else if (typeof module === 'object' && module.exports) { // CommonJS-like environments that support module.exports, like Node. - module.exports = factory(undefined, require('../ApiClient')); + module.exports = factory(undefined, require('../ApiClient'), require('../ApiModel')); } else { // Browser globals (root is window) if (!root.SwaggerPetstore) { root.SwaggerPetstore = {}; } - factory(root.SwaggerPetstore, root.SwaggerPetstore.ApiClient); + factory(root.SwaggerPetstore, root.SwaggerPetstore.ApiClient, root.SwaggerPetstore.ApiModel); } -}(this, function(module, ApiClient) { +}(this, function(module, ApiClient, ApiModel) { 'use strict'; @@ -24,11 +24,13 @@ /** * datatype: Integer **/ + ApiModel.call(this); this['id'] = null; /** * datatype: String **/ + ApiModel.call(this); this['name'] = null; }; @@ -50,6 +52,7 @@ } + /** * @return {Integer} **/ @@ -78,10 +81,7 @@ this['name'] = name; } - - Category.prototype.toJson = function() { - return JSON.stringify(this); - } + if (module) { module.Category = Category; diff --git a/samples/client/petstore/javascript/src/model/Order.js b/samples/client/petstore/javascript/src/model/Order.js index 0d5b90d319a..c2cf6980982 100644 --- a/samples/client/petstore/javascript/src/model/Order.js +++ b/samples/client/petstore/javascript/src/model/Order.js @@ -1,18 +1,18 @@ (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. - define([undefined, '../ApiClient'], factory); + define([undefined, '../ApiClient', '../ApiModel'], factory); } else if (typeof module === 'object' && module.exports) { // CommonJS-like environments that support module.exports, like Node. - module.exports = factory(undefined, require('../ApiClient')); + module.exports = factory(undefined, require('../ApiClient'), require('../ApiModel')); } else { // Browser globals (root is window) if (!root.SwaggerPetstore) { root.SwaggerPetstore = {}; } - factory(root.SwaggerPetstore, root.SwaggerPetstore.ApiClient); + factory(root.SwaggerPetstore, root.SwaggerPetstore.ApiClient, root.SwaggerPetstore.ApiModel); } -}(this, function(module, ApiClient) { +}(this, function(module, ApiClient, ApiModel) { 'use strict'; @@ -52,32 +52,38 @@ var StatusEnum = function StatusEnum() { /** * datatype: Integer **/ + ApiModel.call(this); this['id'] = null; /** * datatype: Integer **/ + ApiModel.call(this); this['petId'] = null; /** * datatype: Integer **/ + ApiModel.call(this); this['quantity'] = null; /** * datatype: Date **/ + ApiModel.call(this); this['shipDate'] = null; /** * Order Status * datatype: StatusEnum **/ + ApiModel.call(this); this['status'] = null; /** * datatype: Boolean **/ + ApiModel.call(this); this['complete'] = null; }; @@ -115,6 +121,7 @@ var StatusEnum = function StatusEnum() { } + /** * @return {Integer} **/ @@ -201,10 +208,7 @@ var StatusEnum = function StatusEnum() { this['complete'] = complete; } - - Order.prototype.toJson = function() { - return JSON.stringify(this); - } + if (module) { module.Order = Order; diff --git a/samples/client/petstore/javascript/src/model/Pet.js b/samples/client/petstore/javascript/src/model/Pet.js index 67bacb19390..7d3bd4b75b3 100644 --- a/samples/client/petstore/javascript/src/model/Pet.js +++ b/samples/client/petstore/javascript/src/model/Pet.js @@ -1,18 +1,18 @@ (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. - define([undefined, '../ApiClient', './Category', './Tag'], factory); + define([undefined, '../ApiClient', '../ApiModel', './Category', './Tag'], factory); } else if (typeof module === 'object' && module.exports) { // CommonJS-like environments that support module.exports, like Node. - module.exports = factory(undefined, require('../ApiClient'), require('./Category'), require('./Tag')); + module.exports = factory(undefined, require('../ApiClient'), require('../ApiModel'), require('./Category'), require('./Tag')); } else { // Browser globals (root is window) if (!root.SwaggerPetstore) { root.SwaggerPetstore = {}; } - factory(root.SwaggerPetstore, root.SwaggerPetstore.ApiClient, root.SwaggerPetstore.Category, root.SwaggerPetstore.Tag); + factory(root.SwaggerPetstore, root.SwaggerPetstore.ApiClient, root.SwaggerPetstore.ApiModel, root.SwaggerPetstore.Category, root.SwaggerPetstore.Tag); } -}(this, function(module, ApiClient, Category, Tag) { +}(this, function(module, ApiClient, ApiModel, Category, Tag) { 'use strict'; @@ -52,34 +52,40 @@ var StatusEnum = function StatusEnum() { /** * datatype: Integer **/ + ApiModel.call(this); this['id'] = null; /** * datatype: Category **/ + ApiModel.call(this); this['category'] = new Category(); /** * datatype: String * required **/ + ApiModel.call(this); this['name'] = name; /** * datatype: [String] * required **/ + ApiModel.call(this); this['photoUrls'] = photoUrls; /** * datatype: [Tag] **/ + ApiModel.call(this); this['tags'] = []; /** * pet status in the store * datatype: StatusEnum **/ + ApiModel.call(this); this['status'] = null; }; @@ -117,6 +123,7 @@ var StatusEnum = function StatusEnum() { } + /** * @return {Integer} **/ @@ -203,10 +210,7 @@ var StatusEnum = function StatusEnum() { this['status'] = status; } - - Pet.prototype.toJson = function() { - return JSON.stringify(this); - } + if (module) { module.Pet = Pet; diff --git a/samples/client/petstore/javascript/src/model/Tag.js b/samples/client/petstore/javascript/src/model/Tag.js index 563c1ee9df8..3843e76f779 100644 --- a/samples/client/petstore/javascript/src/model/Tag.js +++ b/samples/client/petstore/javascript/src/model/Tag.js @@ -1,18 +1,18 @@ (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. - define([undefined, '../ApiClient'], factory); + define([undefined, '../ApiClient', '../ApiModel'], factory); } else if (typeof module === 'object' && module.exports) { // CommonJS-like environments that support module.exports, like Node. - module.exports = factory(undefined, require('../ApiClient')); + module.exports = factory(undefined, require('../ApiClient'), require('../ApiModel')); } else { // Browser globals (root is window) if (!root.SwaggerPetstore) { root.SwaggerPetstore = {}; } - factory(root.SwaggerPetstore, root.SwaggerPetstore.ApiClient); + factory(root.SwaggerPetstore, root.SwaggerPetstore.ApiClient, root.SwaggerPetstore.ApiModel); } -}(this, function(module, ApiClient) { +}(this, function(module, ApiClient, ApiModel) { 'use strict'; @@ -24,11 +24,13 @@ /** * datatype: Integer **/ + ApiModel.call(this); this['id'] = null; /** * datatype: String **/ + ApiModel.call(this); this['name'] = null; }; @@ -50,6 +52,7 @@ } + /** * @return {Integer} **/ @@ -78,10 +81,7 @@ this['name'] = name; } - - Tag.prototype.toJson = function() { - return JSON.stringify(this); - } + if (module) { module.Tag = Tag; diff --git a/samples/client/petstore/javascript/src/model/User.js b/samples/client/petstore/javascript/src/model/User.js index 67c45561d3c..6c7a38c814b 100644 --- a/samples/client/petstore/javascript/src/model/User.js +++ b/samples/client/petstore/javascript/src/model/User.js @@ -1,18 +1,18 @@ (function(root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. - define([undefined, '../ApiClient'], factory); + define([undefined, '../ApiClient', '../ApiModel'], factory); } else if (typeof module === 'object' && module.exports) { // CommonJS-like environments that support module.exports, like Node. - module.exports = factory(undefined, require('../ApiClient')); + module.exports = factory(undefined, require('../ApiClient'), require('../ApiModel')); } else { // Browser globals (root is window) if (!root.SwaggerPetstore) { root.SwaggerPetstore = {}; } - factory(root.SwaggerPetstore, root.SwaggerPetstore.ApiClient); + factory(root.SwaggerPetstore, root.SwaggerPetstore.ApiClient, root.SwaggerPetstore.ApiModel); } -}(this, function(module, ApiClient) { +}(this, function(module, ApiClient, ApiModel) { 'use strict'; @@ -24,42 +24,50 @@ /** * datatype: Integer **/ + ApiModel.call(this); this['id'] = null; /** * datatype: String **/ + ApiModel.call(this); this['username'] = null; /** * datatype: String **/ + ApiModel.call(this); this['firstName'] = null; /** * datatype: String **/ + ApiModel.call(this); this['lastName'] = null; /** * datatype: String **/ + ApiModel.call(this); this['email'] = null; /** * datatype: String **/ + ApiModel.call(this); this['password'] = null; /** * datatype: String **/ + ApiModel.call(this); this['phone'] = null; /** * User Status * datatype: Integer **/ + ApiModel.call(this); this['userStatus'] = null; }; @@ -105,6 +113,7 @@ } + /** * @return {Integer} **/ @@ -219,10 +228,7 @@ this['userStatus'] = userStatus; } - - User.prototype.toJson = function() { - return JSON.stringify(this); - } + if (module) { module.User = User;