@@ -116,7 +116,11 @@ public class <%- toPascalCase(collection.name) %>: Codable {
116116 return <%- toPascalCase(collection.name) %>(
117117<% for (const attribute of collection.attributes) { -%>
118118<% 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 { -%>
119122 <%- toCamelCase(attribute.key) %>: map["<%- attribute.key %>"] as<% if (!attribute.required) { %>?<% } else { %>!<% } %> <%- toPascalCase(attribute.relatedCollection) %><% if (attribute !== collection.attributes[collection.attributes.length - 1]) { %>,<% } %>
123+ <% } -%>
120124<% } else if (attribute.array) { -%>
121125<% if (attribute.type === 'string') { -%>
122126 <%- 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 {
130134 <%- 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]) { %>,<% } %>
131135<% } -%>
132136<% } 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') { -%>
134138 <%- 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]) { %>,<% } %>
135141<% } else if (attribute.type === 'integer') { -%>
136142 <%- toCamelCase(attribute.key) %>: map["<%- attribute.key %>"] as<% if (!attribute.required) { %>?<% } else { %>!<% } %> Int<% if (attribute !== collection.attributes[collection.attributes.length - 1]) { %>,<% } %>
137143<% } else if (attribute.type === 'float') { -%>
0 commit comments