Skip to content

Commit 6ecf018

Browse files
committed
Merge pull request #2126 from delenius/enum-exports
Correct exporting of enum classes
2 parents 97dfa74 + 59931ef commit 6ecf018

File tree

12 files changed

+106
-152
lines changed

12 files changed

+106
-152
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
1-
2-
//export module
3-
if ( typeof define === "function" && define.amd ) {
4-
define('{{datatypeWithEnum}}', [], function() {
5-
return {{datatypeWithEnum}};
6-
});
7-
}
8-
91
var {{datatypeWithEnum}} = {
102
{{#allowableValues}}{{#enumVars}}
11-
/**
12-
* @const
13-
*/
14-
{{name}}: "{{value}}"{{^-last}},
15-
{{/-last}}{{/enumVars}}{{/allowableValues}}
3+
/**
4+
* @const
5+
*/
6+
{{name}}: "{{value}}"{{^-last}},
7+
{{/-last}}{{/enumVars}}{{/allowableValues}}
8+
};
169

17-
}
10+
{{classname}}.{{datatypeWithEnum}} = {{datatypeWithEnum}};

modules/swagger-codegen/src/main/resources/Javascript/model.mustache

+3-4
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@
1414
}
1515
}(this, function(module, ApiClient{{#imports}}, {{import}}{{/imports}}) {
1616
'use strict';
17-
1817
{{#models}}{{#model}}
19-
{{#vars}}{{#isEnum}}{{>enumClass}}{{/isEnum}}{{#items.isEnum}}{{#items}}
20-
{{>enumClass}}{{/items}}*/{{/items.isEnum}}{{/vars}}
21-
2218
{{#description}}/**
2319
* {{description}}
2420
**/{{/description}}
@@ -74,6 +70,9 @@
7470
return JSON.stringify(this);
7571
}
7672

73+
{{#vars}}{{#isEnum}}{{>enumClass}}{{/isEnum}}{{#items.isEnum}}{{#items}}
74+
{{>enumClass}}{{/items}}*/{{/items.isEnum}}{{/vars}}
75+
7776
if (module) {
7877
module.{{classname}} = {{classname}};
7978
}

samples/client/petstore/javascript-promise/src/model/Category.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@
1414
}
1515
}(this, function(module, ApiClient) {
1616
'use strict';
17-
18-
1917

20-
2118

2219
var Category = function Category() {
2320

@@ -86,6 +83,8 @@
8683
return JSON.stringify(this);
8784
}
8885

86+
87+
8988
if (module) {
9089
module.Category = Category;
9190
}

samples/client/petstore/javascript-promise/src/model/Order.js

+21-29
Original file line numberDiff line numberDiff line change
@@ -14,37 +14,8 @@
1414
}
1515
}(this, function(module, ApiClient) {
1616
'use strict';
17-
1817

1918

20-
//export module
21-
if ( typeof define === "function" && define.amd ) {
22-
define('StatusEnum', [], function() {
23-
return StatusEnum;
24-
});
25-
}
26-
27-
var StatusEnum = {
28-
29-
/**
30-
* @const
31-
*/
32-
PLACED: "placed",
33-
34-
/**
35-
* @const
36-
*/
37-
APPROVED: "approved",
38-
39-
/**
40-
* @const
41-
*/
42-
DELIVERED: "delivered"
43-
44-
}
45-
46-
47-
4819
var Order = function Order() {
4920

5021
/**
@@ -207,6 +178,27 @@ var StatusEnum = {
207178
return JSON.stringify(this);
208179
}
209180

181+
var StatusEnum = {
182+
183+
/**
184+
* @const
185+
*/
186+
PLACED: "placed",
187+
188+
/**
189+
* @const
190+
*/
191+
APPROVED: "approved",
192+
193+
/**
194+
* @const
195+
*/
196+
DELIVERED: "delivered"
197+
};
198+
199+
Order.StatusEnum = StatusEnum;
200+
201+
210202
if (module) {
211203
module.Order = Order;
212204
}

samples/client/petstore/javascript-promise/src/model/Pet.js

+21-29
Original file line numberDiff line numberDiff line change
@@ -14,37 +14,8 @@
1414
}
1515
}(this, function(module, ApiClient, Category, Tag) {
1616
'use strict';
17-
1817

1918

20-
//export module
21-
if ( typeof define === "function" && define.amd ) {
22-
define('StatusEnum', [], function() {
23-
return StatusEnum;
24-
});
25-
}
26-
27-
var StatusEnum = {
28-
29-
/**
30-
* @const
31-
*/
32-
AVAILABLE: "available",
33-
34-
/**
35-
* @const
36-
*/
37-
PENDING: "pending",
38-
39-
/**
40-
* @const
41-
*/
42-
SOLD: "sold"
43-
44-
}
45-
46-
47-
4819
var Pet = function Pet(photoUrls, name) {
4920

5021
/**
@@ -209,6 +180,27 @@ var StatusEnum = {
209180
return JSON.stringify(this);
210181
}
211182

183+
var StatusEnum = {
184+
185+
/**
186+
* @const
187+
*/
188+
AVAILABLE: "available",
189+
190+
/**
191+
* @const
192+
*/
193+
PENDING: "pending",
194+
195+
/**
196+
* @const
197+
*/
198+
SOLD: "sold"
199+
};
200+
201+
Pet.StatusEnum = StatusEnum;
202+
203+
212204
if (module) {
213205
module.Pet = Pet;
214206
}

samples/client/petstore/javascript-promise/src/model/Tag.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@
1414
}
1515
}(this, function(module, ApiClient) {
1616
'use strict';
17-
18-
1917

20-
2118

2219
var Tag = function Tag() {
2320

@@ -86,6 +83,8 @@
8683
return JSON.stringify(this);
8784
}
8885

86+
87+
8988
if (module) {
9089
module.Tag = Tag;
9190
}

samples/client/petstore/javascript-promise/src/model/User.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@
1414
}
1515
}(this, function(module, ApiClient) {
1616
'use strict';
17-
18-
1917

20-
2118

2219
var User = function User() {
2320

@@ -227,6 +224,8 @@
227224
return JSON.stringify(this);
228225
}
229226

227+
228+
230229
if (module) {
231230
module.User = User;
232231
}

samples/client/petstore/javascript/src/model/Category.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@
1414
}
1515
}(this, function(module, ApiClient) {
1616
'use strict';
17-
18-
1917

20-
2118

2219
var Category = function Category() {
2320

@@ -86,6 +83,8 @@
8683
return JSON.stringify(this);
8784
}
8885

86+
87+
8988
if (module) {
9089
module.Category = Category;
9190
}

samples/client/petstore/javascript/src/model/Order.js

+21-29
Original file line numberDiff line numberDiff line change
@@ -14,37 +14,8 @@
1414
}
1515
}(this, function(module, ApiClient) {
1616
'use strict';
17-
1817

1918

20-
//export module
21-
if ( typeof define === "function" && define.amd ) {
22-
define('StatusEnum', [], function() {
23-
return StatusEnum;
24-
});
25-
}
26-
27-
var StatusEnum = {
28-
29-
/**
30-
* @const
31-
*/
32-
PLACED: "placed",
33-
34-
/**
35-
* @const
36-
*/
37-
APPROVED: "approved",
38-
39-
/**
40-
* @const
41-
*/
42-
DELIVERED: "delivered"
43-
44-
}
45-
46-
47-
4819
var Order = function Order() {
4920

5021
/**
@@ -207,6 +178,27 @@ var StatusEnum = {
207178
return JSON.stringify(this);
208179
}
209180

181+
var StatusEnum = {
182+
183+
/**
184+
* @const
185+
*/
186+
PLACED: "placed",
187+
188+
/**
189+
* @const
190+
*/
191+
APPROVED: "approved",
192+
193+
/**
194+
* @const
195+
*/
196+
DELIVERED: "delivered"
197+
};
198+
199+
Order.StatusEnum = StatusEnum;
200+
201+
210202
if (module) {
211203
module.Order = Order;
212204
}

samples/client/petstore/javascript/src/model/Pet.js

+21-29
Original file line numberDiff line numberDiff line change
@@ -14,37 +14,8 @@
1414
}
1515
}(this, function(module, ApiClient, Category, Tag) {
1616
'use strict';
17-
1817

1918

20-
//export module
21-
if ( typeof define === "function" && define.amd ) {
22-
define('StatusEnum', [], function() {
23-
return StatusEnum;
24-
});
25-
}
26-
27-
var StatusEnum = {
28-
29-
/**
30-
* @const
31-
*/
32-
AVAILABLE: "available",
33-
34-
/**
35-
* @const
36-
*/
37-
PENDING: "pending",
38-
39-
/**
40-
* @const
41-
*/
42-
SOLD: "sold"
43-
44-
}
45-
46-
47-
4819
var Pet = function Pet(photoUrls, name) {
4920

5021
/**
@@ -209,6 +180,27 @@ var StatusEnum = {
209180
return JSON.stringify(this);
210181
}
211182

183+
var StatusEnum = {
184+
185+
/**
186+
* @const
187+
*/
188+
AVAILABLE: "available",
189+
190+
/**
191+
* @const
192+
*/
193+
PENDING: "pending",
194+
195+
/**
196+
* @const
197+
*/
198+
SOLD: "sold"
199+
};
200+
201+
Pet.StatusEnum = StatusEnum;
202+
203+
212204
if (module) {
213205
module.Pet = Pet;
214206
}

0 commit comments

Comments
 (0)