@@ -116,7 +116,11 @@ 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
+ <% if ((attribute.relationType === ' oneToMany' && attribute.side === ' parent' ) || (attribute.relationType === ' manyToOne' && attribute.side === ' child' ) || attribute.relationType === ' manyToMany' ) { -%>
120
+ <% - toCamelCase(attribute.key) %> : map["<% - attribute.key %> "] as<% if (!attribute.required) { %> ?<% } else { %> !<% } %> [<% - toPascalCase(attribute.relatedCollection) %> ]<% if (attribute != = collection.attributes[collection.attributes.length - 1 ]) { %> ,<% } %>
121
+ <% } else { -%>
119
122
<% - toCamelCase(attribute.key) %> : map["<% - attribute.key %> "] as<% if (!attribute.required) { %> ?<% } else { %> !<% } %> <% - toPascalCase(attribute.relatedCollection) %><% if (attribute != = collection.attributes[collection.attributes.length - 1 ]) { %> ,<% } %>
123
+ <% } -%>
120
124
<% } else if (attribute.array) { -%>
121
125
<% if (attribute.type === ' string' ) { -%>
122
126
<% - toCamelCase(attribute.key) %> : map["<% - attribute.key %> "] as<% if (!attribute.required) { %> ?<% } else { %> !<% } %> [String]<% if (attribute != = collection.attributes[collection.attributes.length - 1 ]) { %> ,<% } %>
@@ -130,8 +134,10 @@ public class <%- toPascalCase(collection.name) %>: Codable {
130
134
<% - 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 ]) { %> ,<% } %>
131
135
<% } -%>
132
136
<% } else { -%>
133
- <% if (attribute.type === ' string' || attribute.type === ' email' || attribute.type === ' datetime' || attribute.type = == ' enum' ) { -%>
137
+ <% if (( attribute.type === ' string' || attribute.type === ' email' || attribute.type === ' datetime' ) && attribute.format ! == ' enum' ) { -%>
134
138
<% - toCamelCase(attribute.key) %> : map["<% - attribute.key %> "] as<% if (!attribute.required) { %> ?<% } else { %> !<% } %> String<% if (attribute != = collection.attributes[collection.attributes.length - 1 ]) { %> ,<% } %>
139
+ <% } else if (attribute.type === ' string' && attribute.format === ' enum' ) { -%>
140
+ <% - toCamelCase(attribute.key) %> : <% - toPascalCase(attribute.key) %> (rawValue: map["<% - attribute.key %> "] as! String)!<% if (attribute != = collection.attributes[collection.attributes.length - 1 ]) { %> ,<% } %>
135
141
<% } else if (attribute.type === ' integer' ) { -%>
136
142
<% - toCamelCase(attribute.key) %> : map["<% - attribute.key %> "] as<% if (!attribute.required) { %> ?<% } else { %> !<% } %> Int<% if (attribute != = collection.attributes[collection.attributes.length - 1 ]) { %> ,<% } %>
137
143
<% } else if (attribute.type === ' float' ) { -%>
0 commit comments