Use objects for enums, not constructor functions

Fixes #2101.
This commit is contained in:
delenius 2016-02-11 09:02:45 -08:00
parent 847a8e1f3d
commit 86154f87c3
11 changed files with 39 additions and 29 deletions

View File

@ -6,14 +6,12 @@ if ( typeof define === "function" && define.amd ) {
}); });
} }
var {{datatypeWithEnum}} = function {{datatypeWithEnum}}() { var {{datatypeWithEnum}} = {
var self = this;
{{#allowableValues}}{{#enumVars}} {{#allowableValues}}{{#enumVars}}
/** /**
* @const * @const
*/ */
self.{{name}} = "{{value}}"{{^-last}}, {{name}}: "{{value}}"{{^-last}},
{{/-last}}{{#-last}};{{/-last}}{{/enumVars}}{{/allowableValues}} {{/-last}}{{/enumVars}}{{/allowableValues}}
} }

View File

@ -50,6 +50,7 @@
} }
/** /**
* @return {Integer} * @return {Integer}
**/ **/
@ -78,6 +79,7 @@
this['name'] = name; this['name'] = name;
} }
Category.prototype.toJson = function() { Category.prototype.toJson = function() {
return JSON.stringify(this); return JSON.stringify(this);

View File

@ -24,24 +24,22 @@ if ( typeof define === "function" && define.amd ) {
}); });
} }
var StatusEnum = function StatusEnum() { var StatusEnum = {
var self = this;
/** /**
* @const * @const
*/ */
self.PLACED = "placed", PLACED: "placed",
/** /**
* @const * @const
*/ */
self.APPROVED = "approved", APPROVED: "approved",
/** /**
* @const * @const
*/ */
self.DELIVERED = "delivered"; DELIVERED: "delivered"
} }
@ -115,6 +113,7 @@ var StatusEnum = function StatusEnum() {
} }
/** /**
* @return {Integer} * @return {Integer}
**/ **/
@ -201,6 +200,7 @@ var StatusEnum = function StatusEnum() {
this['complete'] = complete; this['complete'] = complete;
} }
Order.prototype.toJson = function() { Order.prototype.toJson = function() {
return JSON.stringify(this); return JSON.stringify(this);

View File

@ -24,24 +24,22 @@ if ( typeof define === "function" && define.amd ) {
}); });
} }
var StatusEnum = function StatusEnum() { var StatusEnum = {
var self = this;
/** /**
* @const * @const
*/ */
self.AVAILABLE = "available", AVAILABLE: "available",
/** /**
* @const * @const
*/ */
self.PENDING = "pending", PENDING: "pending",
/** /**
* @const * @const
*/ */
self.SOLD = "sold"; SOLD: "sold"
} }
@ -117,6 +115,7 @@ var StatusEnum = function StatusEnum() {
} }
/** /**
* @return {Integer} * @return {Integer}
**/ **/
@ -203,6 +202,7 @@ var StatusEnum = function StatusEnum() {
this['status'] = status; this['status'] = status;
} }
Pet.prototype.toJson = function() { Pet.prototype.toJson = function() {
return JSON.stringify(this); return JSON.stringify(this);

View File

@ -50,6 +50,7 @@
} }
/** /**
* @return {Integer} * @return {Integer}
**/ **/
@ -78,6 +79,7 @@
this['name'] = name; this['name'] = name;
} }
Tag.prototype.toJson = function() { Tag.prototype.toJson = function() {
return JSON.stringify(this); return JSON.stringify(this);

View File

@ -105,6 +105,7 @@
} }
/** /**
* @return {Integer} * @return {Integer}
**/ **/
@ -219,6 +220,7 @@
this['userStatus'] = userStatus; this['userStatus'] = userStatus;
} }
User.prototype.toJson = function() { User.prototype.toJson = function() {
return JSON.stringify(this); return JSON.stringify(this);

View File

@ -50,6 +50,7 @@
} }
/** /**
* @return {Integer} * @return {Integer}
**/ **/
@ -78,6 +79,7 @@
this['name'] = name; this['name'] = name;
} }
Category.prototype.toJson = function() { Category.prototype.toJson = function() {
return JSON.stringify(this); return JSON.stringify(this);

View File

@ -24,24 +24,22 @@ if ( typeof define === "function" && define.amd ) {
}); });
} }
var StatusEnum = function StatusEnum() { var StatusEnum = {
var self = this;
/** /**
* @const * @const
*/ */
self.PLACED = "placed", PLACED: "placed",
/** /**
* @const * @const
*/ */
self.APPROVED = "approved", APPROVED: "approved",
/** /**
* @const * @const
*/ */
self.DELIVERED = "delivered"; DELIVERED: "delivered"
} }
@ -115,6 +113,7 @@ var StatusEnum = function StatusEnum() {
} }
/** /**
* @return {Integer} * @return {Integer}
**/ **/
@ -201,6 +200,7 @@ var StatusEnum = function StatusEnum() {
this['complete'] = complete; this['complete'] = complete;
} }
Order.prototype.toJson = function() { Order.prototype.toJson = function() {
return JSON.stringify(this); return JSON.stringify(this);

View File

@ -24,24 +24,22 @@ if ( typeof define === "function" && define.amd ) {
}); });
} }
var StatusEnum = function StatusEnum() { var StatusEnum = {
var self = this;
/** /**
* @const * @const
*/ */
self.AVAILABLE = "available", AVAILABLE: "available",
/** /**
* @const * @const
*/ */
self.PENDING = "pending", PENDING: "pending",
/** /**
* @const * @const
*/ */
self.SOLD = "sold"; SOLD: "sold"
} }
@ -117,6 +115,7 @@ var StatusEnum = function StatusEnum() {
} }
/** /**
* @return {Integer} * @return {Integer}
**/ **/
@ -203,6 +202,7 @@ var StatusEnum = function StatusEnum() {
this['status'] = status; this['status'] = status;
} }
Pet.prototype.toJson = function() { Pet.prototype.toJson = function() {
return JSON.stringify(this); return JSON.stringify(this);

View File

@ -50,6 +50,7 @@
} }
/** /**
* @return {Integer} * @return {Integer}
**/ **/
@ -78,6 +79,7 @@
this['name'] = name; this['name'] = name;
} }
Tag.prototype.toJson = function() { Tag.prototype.toJson = function() {
return JSON.stringify(this); return JSON.stringify(this);

View File

@ -105,6 +105,7 @@
} }
/** /**
* @return {Integer} * @return {Integer}
**/ **/
@ -219,6 +220,7 @@
this['userStatus'] = userStatus; this['userStatus'] = userStatus;
} }
User.prototype.toJson = function() { User.prototype.toJson = function() {
return JSON.stringify(this); return JSON.stringify(this);