File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed
templates/cli/lib/type-generation/languages Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff 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";
Original file line number Diff line number Diff 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' ) { -%>
4749import <% - 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<% } -%>
5163data class <% - toPascalCase(collection.name) %> (
You can’t perform that action at this time.
0 commit comments