@@ -56,21 +56,21 @@ public enum <%- toPascalCase(attribute.key) %>: String, Codable, CaseIterable {
5656<% } -%>
5757public class <% - toPascalCase(collection.name) %> : Codable {
5858<% for (const attribute of collection.attributes) { -%>
59- public let <% - toCamelCase( attribute.key) %> : <% - getType(attribute) %>
59+ public let <% - attribute.key %> : <% - getType(attribute) %>
6060<% } %>
6161 enum CodingKeys: String, CodingKey {
6262<% for (const attribute of collection.attributes) { -%>
63- case <% - toCamelCase( attribute.key) %> = "<% - attribute.key %> "
63+ case <% - attribute.key %> = "<% - attribute.key %> "
6464<% } -%>
6565 }
6666
6767 init(
6868<% 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 ]) { %> ,<% } %>
7070<% } -%>
7171 ) {
7272<% for (const attribute of collection.attributes) { -%>
73- self.<% - toCamelCase( attribute.key) %> = <% - toCamelCase( attribute.key) %>
73+ self.<% - attribute.key %> = <% - attribute.key %>
7474<% } -%>
7575 }
7676
@@ -79,9 +79,9 @@ public class <%- toPascalCase(collection.name) %>: Codable {
7979
8080<% for (const attribute of collection.attributes) { -%>
8181<% 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 %> )
8383<% } 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 %> )
8585<% } -%>
8686<% } -%>
8787 }
@@ -91,9 +91,9 @@ public class <%- toPascalCase(collection.name) %>: Codable {
9191
9292<% for (const attribute of collection.attributes) { -%>
9393<% if (attribute.required) { -%>
94- try container.encode(<% - toCamelCase( attribute.key) %> , forKey: .<% - toCamelCase( attribute.key) %> )
94+ try container.encode(<% - attribute.key %> , forKey: .<% - attribute.key %> )
9595<% } else { -%>
96- try container.encodeIfPresent(<% - toCamelCase( attribute.key) %> , forKey: .<% - toCamelCase( attribute.key) %> )
96+ try container.encodeIfPresent(<% - attribute.key %> , forKey: .<% - attribute.key %> )
9797<% } -%>
9898<% } -%>
9999 }
@@ -102,11 +102,11 @@ public class <%- toPascalCase(collection.name) %>: Codable {
102102 return [
103103<% for (const attribute of collection.attributes) { -%>
104104<% 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 ]) { %> ,<% } %>
106106<% } 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 ]) { %> ,<% } %>
108108<% } 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 ]) { %> ,<% } %>
110110<% } -%>
111111<% } -%>
112112 ]
@@ -116,30 +116,30 @@ public class <%- toPascalCase(collection.name) %>: Codable {
116116 return <% - toPascalCase(collection.name) %> (
117117<% for (const attribute of collection.attributes) { -%>
118118<% 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 ]) { %> ,<% } %>
120120<% } else if (attribute.array) { -%>
121121<% 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 ]) { %> ,<% } %>
123123<% } 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 ]) { %> ,<% } %>
125125<% } 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 ]) { %> ,<% } %>
127127<% } 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 ]) { %> ,<% } %>
129129<% } 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 ]) { %> ,<% } %>
131131<% } -%>
132132<% } else { -%>
133133<% 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 ]) { %> ,<% } %>
135135<% } 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 ]) { %> ,<% } %>
137137<% } 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 ]) { %> ,<% } %>
139139<% } 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 ]) { %> ,<% } %>
141141<% } 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 ]) { %> ,<% } %>
143143<% } -%>
144144<% } -%>
145145<% } -%>
0 commit comments