Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

}));
Original file line number Diff line number Diff line change
@@ -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}}
Expand All @@ -23,6 +23,7 @@
* {{description}}
**/{{/description}}
var {{classname}} = function {{classname}}({{#mandatory}}{{this}}{{^-last}}, {{/-last}}{{/mandatory}}) { {{#parent}}/* extends {{{parent}}}*/{{/parent}}
ApiModel.call(this);
{{#vars}}
/**{{#description}}
* {{{description}}}{{/description}}
Expand Down Expand Up @@ -69,10 +70,6 @@
{{/vars}}
{{/omitModelMethods}}

{{classname}}.prototype.toJson = function() {
return JSON.stringify(this);
}

if (module) {
module.{{classname}} = {{classname}};
}
Expand Down
33 changes: 33 additions & 0 deletions samples/client/petstore/javascript-promise/src/ApiModel.js
Original file line number Diff line number Diff line change
@@ -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;

}));
15 changes: 7 additions & 8 deletions samples/client/petstore/javascript-promise/src/model/Category.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
(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';





var Category = function Category() {
ApiModel.call(this);

/**
* datatype: Integer
Expand Down Expand Up @@ -50,6 +51,7 @@
}



/**
* @return {Integer}
**/
Expand Down Expand Up @@ -78,10 +80,7 @@
this['name'] = name;
}


Category.prototype.toJson = function() {
return JSON.stringify(this);
}


if (module) {
module.Category = Category;
Expand Down
15 changes: 7 additions & 8 deletions samples/client/petstore/javascript-promise/src/model/Order.js
Original file line number Diff line number Diff line change
@@ -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';


Expand Down Expand Up @@ -48,6 +48,7 @@ var StatusEnum = function StatusEnum() {


var Order = function Order() {
ApiModel.call(this);

/**
* datatype: Integer
Expand Down Expand Up @@ -115,6 +116,7 @@ var StatusEnum = function StatusEnum() {
}



/**
* @return {Integer}
**/
Expand Down Expand Up @@ -201,10 +203,7 @@ var StatusEnum = function StatusEnum() {
this['complete'] = complete;
}


Order.prototype.toJson = function() {
return JSON.stringify(this);
}


if (module) {
module.Order = Order;
Expand Down
15 changes: 7 additions & 8 deletions samples/client/petstore/javascript-promise/src/model/Pet.js
Original file line number Diff line number Diff line change
@@ -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';


Expand Down Expand Up @@ -48,6 +48,7 @@ var StatusEnum = function StatusEnum() {


var Pet = function Pet(photoUrls, name) {
ApiModel.call(this);

/**
* datatype: Integer
Expand Down Expand Up @@ -117,6 +118,7 @@ var StatusEnum = function StatusEnum() {
}



/**
* @return {Integer}
**/
Expand Down Expand Up @@ -203,10 +205,7 @@ var StatusEnum = function StatusEnum() {
this['status'] = status;
}


Pet.prototype.toJson = function() {
return JSON.stringify(this);
}


if (module) {
module.Pet = Pet;
Expand Down
15 changes: 7 additions & 8 deletions samples/client/petstore/javascript-promise/src/model/Tag.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
(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';





var Tag = function Tag() {
ApiModel.call(this);

/**
* datatype: Integer
Expand Down Expand Up @@ -50,6 +51,7 @@
}



/**
* @return {Integer}
**/
Expand Down Expand Up @@ -78,10 +80,7 @@
this['name'] = name;
}


Tag.prototype.toJson = function() {
return JSON.stringify(this);
}


if (module) {
module.Tag = Tag;
Expand Down
15 changes: 7 additions & 8 deletions samples/client/petstore/javascript-promise/src/model/User.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
(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';





var User = function User() {
ApiModel.call(this);

/**
* datatype: Integer
Expand Down Expand Up @@ -105,6 +106,7 @@
}



/**
* @return {Integer}
**/
Expand Down Expand Up @@ -219,10 +221,7 @@
this['userStatus'] = userStatus;
}


User.prototype.toJson = function() {
return JSON.stringify(this);
}


if (module) {
module.User = User;
Expand Down
Loading