@@ -56,21 +56,21 @@ public enum <%- toPascalCase(attribute.key) %>: String, Codable, CaseIterable {
56
56
<% } -%>
57
57
public class <% - toPascalCase(collection.name) %> : Codable {
58
58
<% for (const attribute of collection.attributes) { -%>
59
- public let <% - toCamelCase( attribute.key) %> : <% - getType(attribute) %>
59
+ public let <% - attribute.key %> : <% - getType(attribute) %>
60
60
<% } %>
61
61
enum CodingKeys: String, CodingKey {
62
62
<% for (const attribute of collection.attributes) { -%>
63
- case <% - toCamelCase( attribute.key) %> = "<% - attribute.key %> "
63
+ case <% - attribute.key %> = "<% - attribute.key %> "
64
64
<% } -%>
65
65
}
66
66
67
67
init(
68
68
<% for (const attribute of collection.attributes) { -%>
69
- <% - toCamelCase( attribute.key) %> : <% - getType(attribute) %><% if (attribute != = collection.attributes[collection.attributes.length - 1 ]) { %> ,<% } %>
69
+ <% - attribute.key %> : <% - getType(attribute) %><% if (attribute != = collection.attributes[collection.attributes.length - 1 ]) { %> ,<% } %>
70
70
<% } -%>
71
71
) {
72
72
<% for (const attribute of collection.attributes) { -%>
73
- self.<% - toCamelCase( attribute.key) %> = <% - toCamelCase( attribute.key) %>
73
+ self.<% - attribute.key %> = <% - attribute.key %>
74
74
<% } -%>
75
75
}
76
76
@@ -79,9 +79,9 @@ public class <%- toPascalCase(collection.name) %>: Codable {
79
79
80
80
<% for (const attribute of collection.attributes) { -%>
81
81
<% if (attribute.required) { -%>
82
- self.<% - toCamelCase( attribute.key) %> = try container.decode(<% - getType(attribute).replace(' ?' , ' ' ) %> .self, forKey: .<% - toCamelCase( attribute.key) %> )
82
+ self.<% - attribute.key %> = try container.decode(<% - getType(attribute).replace(' ?' , ' ' ) %> .self, forKey: .<% - attribute.key %> )
83
83
<% } else { -%>
84
- self.<% - toCamelCase( attribute.key) %> = try container.decodeIfPresent(<% - getType(attribute).replace(' ?' , ' ' ) %> .self, forKey: .<% - toCamelCase( attribute.key) %> )
84
+ self.<% - attribute.key %> = try container.decodeIfPresent(<% - getType(attribute).replace(' ?' , ' ' ) %> .self, forKey: .<% - attribute.key %> )
85
85
<% } -%>
86
86
<% } -%>
87
87
}
@@ -91,9 +91,9 @@ public class <%- toPascalCase(collection.name) %>: Codable {
91
91
92
92
<% for (const attribute of collection.attributes) { -%>
93
93
<% if (attribute.required) { -%>
94
- try container.encode(<% - toCamelCase( attribute.key) %> , forKey: .<% - toCamelCase( attribute.key) %> )
94
+ try container.encode(<% - attribute.key %> , forKey: .<% - attribute.key %> )
95
95
<% } else { -%>
96
- try container.encodeIfPresent(<% - toCamelCase( attribute.key) %> , forKey: .<% - toCamelCase( attribute.key) %> )
96
+ try container.encodeIfPresent(<% - attribute.key %> , forKey: .<% - attribute.key %> )
97
97
<% } -%>
98
98
<% } -%>
99
99
}
@@ -102,11 +102,11 @@ public class <%- toPascalCase(collection.name) %>: Codable {
102
102
return [
103
103
<% for (const attribute of collection.attributes) { -%>
104
104
<% if (attribute.type === ' relationship' ) { -%>
105
- "<% - attribute.key %> ": <% - toCamelCase( attribute.key) %> as Any<% if (attribute != = collection.attributes[collection.attributes.length - 1 ]) { %> ,<% } %>
105
+ "<% - attribute.key %> ": <% - attribute.key %> as Any<% if (attribute != = collection.attributes[collection.attributes.length - 1 ]) { %> ,<% } %>
106
106
<% } else if (attribute.array && attribute.type != = ' string' && attribute.type != = ' integer' && attribute.type != = ' float' && attribute.type != = ' boolean' ) { -%>
107
- "<% - attribute.key %> ": <% - toCamelCase( attribute.key) %> ?.map { $0.toMap() } as Any<% if (attribute != = collection.attributes[collection.attributes.length - 1 ]) { %> ,<% } %>
107
+ "<% - attribute.key %> ": <% - attribute.key %> ?.map { $0.toMap() } as Any<% if (attribute != = collection.attributes[collection.attributes.length - 1 ]) { %> ,<% } %>
108
108
<% } else { -%>
109
- "<% - attribute.key %> ": <% - toCamelCase( attribute.key) %> as Any<% if (attribute != = collection.attributes[collection.attributes.length - 1 ]) { %> ,<% } %>
109
+ "<% - attribute.key %> ": <% - attribute.key %> as Any<% if (attribute != = collection.attributes[collection.attributes.length - 1 ]) { %> ,<% } %>
110
110
<% } -%>
111
111
<% } -%>
112
112
]
@@ -116,30 +116,30 @@ public class <%- toPascalCase(collection.name) %>: Codable {
116
116
return <% - toPascalCase(collection.name) %> (
117
117
<% for (const attribute of collection.attributes) { -%>
118
118
<% if (attribute.type === ' relationship' ) { -%>
119
- <% - toCamelCase( attribute.key) %> : map["<% - attribute.key %> "] as<% if (!attribute.required) { %> ?<% } else { %> !<% } %> <% - toPascalCase(attribute.relatedCollection) %><% if (attribute != = collection.attributes[collection.attributes.length - 1 ]) { %> ,<% } %>
119
+ <% - attribute.key %> : map["<% - attribute.key %> "] as<% if (!attribute.required) { %> ?<% } else { %> !<% } %> <% - toPascalCase(attribute.relatedCollection) %><% if (attribute != = collection.attributes[collection.attributes.length - 1 ]) { %> ,<% } %>
120
120
<% } else if (attribute.array) { -%>
121
121
<% if (attribute.type === ' string' ) { -%>
122
- <% - toCamelCase( attribute.key) %> : map["<% - attribute.key %> "] as<% if (!attribute.required) { %> ?<% } else { %> !<% } %> [String]<% if (attribute != = collection.attributes[collection.attributes.length - 1 ]) { %> ,<% } %>
122
+ <% - attribute.key %> : map["<% - attribute.key %> "] as<% if (!attribute.required) { %> ?<% } else { %> !<% } %> [String]<% if (attribute != = collection.attributes[collection.attributes.length - 1 ]) { %> ,<% } %>
123
123
<% } else if (attribute.type === ' integer' ) { -%>
124
- <% - toCamelCase( attribute.key) %> : map["<% - attribute.key %> "] as<% if (!attribute.required) { %> ?<% } else { %> !<% } %> [Int]<% if (attribute != = collection.attributes[collection.attributes.length - 1 ]) { %> ,<% } %>
124
+ <% - attribute.key %> : map["<% - attribute.key %> "] as<% if (!attribute.required) { %> ?<% } else { %> !<% } %> [Int]<% if (attribute != = collection.attributes[collection.attributes.length - 1 ]) { %> ,<% } %>
125
125
<% } else if (attribute.type === ' float' ) { -%>
126
- <% - toCamelCase( attribute.key) %> : map["<% - attribute.key %> "] as<% if (!attribute.required) { %> ?<% } else { %> !<% } %> [Double]<% if (attribute != = collection.attributes[collection.attributes.length - 1 ]) { %> ,<% } %>
126
+ <% - attribute.key %> : map["<% - attribute.key %> "] as<% if (!attribute.required) { %> ?<% } else { %> !<% } %> [Double]<% if (attribute != = collection.attributes[collection.attributes.length - 1 ]) { %> ,<% } %>
127
127
<% } else if (attribute.type === ' boolean' ) { -%>
128
- <% - toCamelCase( attribute.key) %> : map["<% - attribute.key %> "] as<% if (!attribute.required) { %> ?<% } else { %> !<% } %> [Bool]<% if (attribute != = collection.attributes[collection.attributes.length - 1 ]) { %> ,<% } %>
128
+ <% - attribute.key %> : map["<% - attribute.key %> "] as<% if (!attribute.required) { %> ?<% } else { %> !<% } %> [Bool]<% if (attribute != = collection.attributes[collection.attributes.length - 1 ]) { %> ,<% } %>
129
129
<% } else { -%>
130
- <% - toCamelCase( attribute.key) %> : (map["<% - attribute.key %> "] as<% if (!attribute.required) { %> ?<% } else { %> !<% } %> [[String: Any]])<% if (!attribute.required) { %> ?<% } %> .map { <% - toPascalCase(attribute.type) %> .from(map: $0) }<% if (attribute != = collection.attributes[collection.attributes.length - 1 ]) { %> ,<% } %>
130
+ <% - attribute.key %> : (map["<% - attribute.key %> "] as<% if (!attribute.required) { %> ?<% } else { %> !<% } %> [[String: Any]])<% if (!attribute.required) { %> ?<% } %> .map { <% - toPascalCase(attribute.type) %> .from(map: $0) }<% if (attribute != = collection.attributes[collection.attributes.length - 1 ]) { %> ,<% } %>
131
131
<% } -%>
132
132
<% } else { -%>
133
133
<% if (attribute.type === ' string' || attribute.type === ' email' || attribute.type === ' datetime' || attribute.type === ' enum' ) { -%>
134
- <% - toCamelCase( attribute.key) %> : map["<% - attribute.key %> "] as<% if (!attribute.required) { %> ?<% } else { %> !<% } %> String<% if (attribute != = collection.attributes[collection.attributes.length - 1 ]) { %> ,<% } %>
134
+ <% - attribute.key %> : map["<% - attribute.key %> "] as<% if (!attribute.required) { %> ?<% } else { %> !<% } %> String<% if (attribute != = collection.attributes[collection.attributes.length - 1 ]) { %> ,<% } %>
135
135
<% } else if (attribute.type === ' integer' ) { -%>
136
- <% - toCamelCase( attribute.key) %> : map["<% - attribute.key %> "] as<% if (!attribute.required) { %> ?<% } else { %> !<% } %> Int<% if (attribute != = collection.attributes[collection.attributes.length - 1 ]) { %> ,<% } %>
136
+ <% - attribute.key %> : map["<% - attribute.key %> "] as<% if (!attribute.required) { %> ?<% } else { %> !<% } %> Int<% if (attribute != = collection.attributes[collection.attributes.length - 1 ]) { %> ,<% } %>
137
137
<% } else if (attribute.type === ' float' ) { -%>
138
- <% - toCamelCase( attribute.key) %> : map["<% - attribute.key %> "] as<% if (!attribute.required) { %> ?<% } else { %> !<% } %> Double<% if (attribute != = collection.attributes[collection.attributes.length - 1 ]) { %> ,<% } %>
138
+ <% - attribute.key %> : map["<% - attribute.key %> "] as<% if (!attribute.required) { %> ?<% } else { %> !<% } %> Double<% if (attribute != = collection.attributes[collection.attributes.length - 1 ]) { %> ,<% } %>
139
139
<% } else if (attribute.type === ' boolean' ) { -%>
140
- <% - toCamelCase( attribute.key) %> : map["<% - attribute.key %> "] as<% if (!attribute.required) { %> ?<% } else { %> !<% } %> Bool<% if (attribute != = collection.attributes[collection.attributes.length - 1 ]) { %> ,<% } %>
140
+ <% - attribute.key %> : map["<% - attribute.key %> "] as<% if (!attribute.required) { %> ?<% } else { %> !<% } %> Bool<% if (attribute != = collection.attributes[collection.attributes.length - 1 ]) { %> ,<% } %>
141
141
<% } else { -%>
142
- <% - toCamelCase( attribute.key) %> : <% - toPascalCase(attribute.type) %> .from(map: map["<% - attribute.key %> "] as! [String: Any])<% if (attribute != = collection.attributes[collection.attributes.length - 1 ]) { %> ,<% } %>
142
+ <% - attribute.key %> : <% - toPascalCase(attribute.type) %> .from(map: map["<% - attribute.key %> "] as! [String: Any])<% if (attribute != = collection.attributes[collection.attributes.length - 1 ]) { %> ,<% } %>
143
143
<% } -%>
144
144
<% } -%>
145
145
<% } -%>
0 commit comments