Skip to content

Commit d9ca85a

Browse files
committed
chore: complete num for js and kotlin
1 parent 41282ce commit d9ca85a

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

templates/cli/lib/type-generation/languages/javascript.js.twig

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ class JavaScript extends LanguageMeta {
1212
case AttributeType.STRING:
1313
case AttributeType.EMAIL:
1414
case AttributeType.DATETIME:
15-
case AttributeType.ENUM:
1615
case AttributeType.IP:
1716
case AttributeType.___URL:
1817
type = "string";
18+
if (attribute.format === AttributeType.ENUM) {
19+
type = `"${attribute.elements.join('"|"')}"`;
20+
}
1921
break;
2022
case AttributeType.INTEGER:
2123
type = "number";

templates/cli/lib/type-generation/languages/kotlin.js.twig

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ class Kotlin extends LanguageMeta {
99
case AttributeType.STRING:
1010
case AttributeType.EMAIL:
1111
case AttributeType.DATETIME:
12-
case AttributeType.ENUM:
1312
type = "String";
13+
if (attribute.format === AttributeType.ENUM) {
14+
type = LanguageMeta.toPascalCase(attribute.key);
15+
}
1416
break;
1517
case AttributeType.INTEGER:
1618
type = "Int";
@@ -46,6 +48,16 @@ class Kotlin extends LanguageMeta {
4648
<% if (attribute.type === 'relationship') { -%>
4749
import <%- toPascalCase(attribute.relatedCollection) %>
4850

51+
<% } -%>
52+
<% } -%>
53+
<% for (const attribute of collection.attributes) { -%>
54+
<% if (attribute.format === 'enum') { -%>
55+
enum class <%- toPascalCase(attribute.key) %> {
56+
<% for (const [index, element] of Object.entries(attribute.elements)) { -%>
57+
<%- element %><%- index < attribute.elements.length - 1 ? ',' : '' %>
58+
<% } -%>
59+
}
60+
4961
<% } -%>
5062
<% } -%>
5163
data class <%- toPascalCase(collection.name) %>(

0 commit comments

Comments
 (0)