Skip to content

Commit 3803087

Browse files
committed
fix: remove conversion of attribute keys to camel case
1 parent 0780426 commit 3803087

File tree

7 files changed

+50
-50
lines changed

7 files changed

+50
-50
lines changed

templates/cli/lib/type-generation/languages/dart.js.twig

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,19 @@ enum <%- toPascalCase(attribute.key) %> {
6060
<% } -%>
6161
class <%= toPascalCase(collection.name) %> {
6262
<% for (const [index, attribute] of Object.entries(collection.attributes)) { -%>
63-
<%- getType(attribute) %> <%= toCamelCase(attribute.key) %>;
63+
<%- getType(attribute) %> <%- attribute.key %>;
6464
<% } -%>
6565

6666
<%= toPascalCase(collection.name) %>({
6767
<% for (const [index, attribute] of Object.entries(collection.attributes)) { -%>
68-
<% if (attribute.required) { %>required <% } %>this.<%= toCamelCase(attribute.key) %>,
68+
<% if (attribute.required) { %>required <% } %>this.<%- attribute.key %>,
6969
<% } -%>
7070
});
7171

7272
factory <%= toPascalCase(collection.name) %>.fromMap(Map<String, dynamic> map) {
7373
return <%= toPascalCase(collection.name) %>(
7474
<% for (const [index, attribute] of Object.entries(collection.attributes)) { -%>
75-
<%= toCamelCase(attribute.key) %>: <% if (attribute.type === 'string' || attribute.type === 'email' || attribute.type === 'datetime') { -%>
75+
<%- attribute.key %>: <% if (attribute.type === 'string' || attribute.type === 'email' || attribute.type === 'datetime') { -%>
7676
<% if (attribute.format === 'enum') { -%>
7777
<% if (attribute.array) { -%>
7878
(map['<%= attribute.key %>'] as List<dynamic>?)?.map((e) => <%- toPascalCase(attribute.key) %>.values.firstWhere((element) => element.name == e)).toList()<% if (!attribute.required) { %> ?? []<% } -%>
@@ -124,18 +124,18 @@ map['<%= attribute.key %>'] != null ? <%- toPascalCase(attribute.relatedCollecti
124124
<% for (const [index, attribute] of Object.entries(collection.attributes)) { -%>
125125
"<%= attribute.key %>": <% if (attribute.type === 'relationship') { -%>
126126
<% if ((attribute.relationType === 'oneToMany' && attribute.side === 'parent') || (attribute.relationType === 'manyToOne' && attribute.side === 'child') || attribute.relationType === 'manyToMany') { -%>
127-
<%= toCamelCase(attribute.key) %><% if (!attribute.required) { %>?<% } %>.map((e) => e.toMap()).toList()<% if (!attribute.required) { %> ?? []<% } -%>
127+
<%- attribute.key %><% if (!attribute.required) { %>?<% } %>.map((e) => e.toMap()).toList()<% if (!attribute.required) { %> ?? []<% } -%>
128128
<% } else { -%>
129-
<%= toCamelCase(attribute.key) %><% if (!attribute.required) { %>?<% } %>.toMap()<% if (!attribute.required) { %> ?? {}<% } -%>
129+
<%- attribute.key %><% if (!attribute.required) { %>?<% } %>.toMap()<% if (!attribute.required) { %> ?? {}<% } -%>
130130
<% } -%>
131131
<% } else if (attribute.format === 'enum') { -%>
132132
<% if (attribute.array) { -%>
133-
<%= toCamelCase(attribute.key) %><% if (!attribute.required) { %>?<% } %>.map((e) => e.name).toList()<% if (!attribute.required) { %> ?? []<% } -%>
133+
<%- attribute.key %><% if (!attribute.required) { %>?<% } %>.map((e) => e.name).toList()<% if (!attribute.required) { %> ?? []<% } -%>
134134
<% } else { -%>
135-
<%= toCamelCase(attribute.key) %><% if (!attribute.required) { %>?<% } %>.name<% if (!attribute.required) { %> ?? null<% } -%>
135+
<%- attribute.key %><% if (!attribute.required) { %>?<% } %>.name<% if (!attribute.required) { %> ?? null<% } -%>
136136
<% } -%>
137137
<% } else { -%>
138-
<%= toCamelCase(attribute.key) -%>
138+
<%- attribute.key -%>
139139
<% } -%>,
140140
<% } -%>
141141
};

templates/cli/lib/type-generation/languages/java.js.twig

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,29 +61,29 @@ public class <%- toPascalCase(collection.name) %> {
6161
<% } -%>
6262
<% } -%>
6363
<% for (const attribute of collection.attributes) { -%>
64-
private <%- getType(attribute) %> <%- toCamelCase(attribute.key) %>;
64+
private <%- getType(attribute) %> <%- attribute.key %>;
6565
<% } -%>
6666

6767
public <%- toPascalCase(collection.name) %>() {
6868
}
6969

7070
public <%- toPascalCase(collection.name) %>(
7171
<% for (const [index, attribute] of Object.entries(collection.attributes)) { -%>
72-
<%- getType(attribute) %> <%= toCamelCase(attribute.key) %><%- index < collection.attributes.length - 1 ? ',' : '' %>
72+
<%- getType(attribute) %> <%- attribute.key %><%- index < collection.attributes.length - 1 ? ',' : '' %>
7373
<% } -%>
7474
) {
7575
<% for (const attribute of collection.attributes) { -%>
76-
this.<%= toCamelCase(attribute.key) %> = <%= toCamelCase(attribute.key) %>;
76+
this.<%- attribute.key %> = <%- attribute.key %>;
7777
<% } -%>
7878
}
7979

8080
<% for (const attribute of collection.attributes) { -%>
8181
public <%- getType(attribute) %> get<%- toPascalCase(attribute.key) %>() {
82-
return <%= toCamelCase(attribute.key) %>;
82+
return <%- attribute.key %>;
8383
}
8484

85-
public void set<%- toPascalCase(attribute.key) %>(<%- getType(attribute) %> <%= toCamelCase(attribute.key) %>) {
86-
this.<%= toCamelCase(attribute.key) %> = <%= toCamelCase(attribute.key) %>;
85+
public void set<%- toPascalCase(attribute.key) %>(<%- getType(attribute) %> <%- attribute.key %>) {
86+
this.<%- attribute.key %> = <%- attribute.key %>;
8787
}
8888

8989
<% } -%>
@@ -92,20 +92,20 @@ public class <%- toPascalCase(collection.name) %> {
9292
if (this == obj) return true;
9393
if (obj == null || getClass() != obj.getClass()) return false;
9494
<%- toPascalCase(collection.name) %> that = (<%- toPascalCase(collection.name) %>) obj;
95-
return <% collection.attributes.forEach((attr, index) => { %>Objects.equals(<%= toCamelCase(attr.key) %>, that.<%= toCamelCase(attr.key) %>)<% if (index < collection.attributes.length - 1) { %> &&
95+
return <% collection.attributes.forEach((attr, index) => { %>Objects.equals(<%- attribute.key %>, that.<%- attribute.key %>)<% if (index < collection.attributes.length - 1) { %> &&
9696
<% } }); %>;
9797
}
9898

9999
@Override
100100
public int hashCode() {
101-
return Objects.hash(<%= collection.attributes.map(attr => toCamelCase(attr.key)).join(', ') %>);
101+
return Objects.hash(<%- collection.attributes.map(attr => attribute.key).join(', ') %>);
102102
}
103103

104104
@Override
105105
public String toString() {
106106
return "<%- toPascalCase(collection.name) %>{" +
107107
<% for (const [index, attribute] of Object.entries(collection.attributes)) { -%>
108-
"<%= toCamelCase(attribute.key) %>=" + <%= toCamelCase(attribute.key) %> +
108+
"<%- attribute.key %>=" + <%- attribute.key %> +
109109
<% } -%>
110110
'}';
111111
}

templates/cli/lib/type-generation/languages/javascript.js.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class JavaScript extends LanguageMeta {
6969
/**
7070
* @typedef {Object} <%- toPascalCase(collection.name) %>
7171
<% for (const attribute of collection.attributes) { -%>
72-
* @property {<%- getType(attribute) %>} <%- toCamelCase(attribute.key) %>
72+
* @property {<%- getType(attribute) %>} <%- attribute.key %>
7373
<% } -%>
7474
*/
7575

templates/cli/lib/type-generation/languages/kotlin.js.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ enum class <%- toPascalCase(attribute.key) %> {
6262
<% } -%>
6363
data class <%- toPascalCase(collection.name) %>(
6464
<% for (const attribute of collection.attributes) { -%>
65-
val <%- toCamelCase(attribute.key) %>: <%- getType(attribute) %>,
65+
val <%- attribute.key %>: <%- getType(attribute) %>,
6666
<% } -%>
6767
)`;
6868
}

templates/cli/lib/type-generation/languages/php.js.twig

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,30 +63,30 @@ enum <%- toPascalCase(attribute.key) %> {
6363
<% } -%>
6464
class <%- toPascalCase(collection.name) %> {
6565
<% for (const attribute of collection.attributes ){ -%>
66-
private <%- getType(attribute) %> $<%- toCamelCase(attribute.key) %>;
66+
private <%- getType(attribute) %> $<%- attribute.key %>;
6767
<% } -%>
6868
6969
public function __construct(
7070
<% for (const attribute of collection.attributes ){ -%>
7171
<% if (attribute.required) { -%>
72-
<%- getType(attribute).replace('|null', '') %> $<%- toCamelCase(attribute.key) %><% if (collection.attributes.indexOf(attribute) < collection.attributes.length - 1) { %>,<% } %>
72+
<%- getType(attribute).replace('|null', '') %> $<%- attribute.key %><% if (collection.attributes.indexOf(attribute) < collection.attributes.length - 1) { %>,<% } %>
7373
<% } else { -%>
74-
?<%- getType(attribute).replace('|null', '') %> $<%- toCamelCase(attribute.key) %> = null<% if (collection.attributes.indexOf(attribute) < collection.attributes.length - 1) { %>,<% } %>
74+
?<%- getType(attribute).replace('|null', '') %> $<%- attribute.key %> = null<% if (collection.attributes.indexOf(attribute) < collection.attributes.length - 1) { %>,<% } %>
7575
<% } -%>
7676
<% } -%>
7777
) {
7878
<% for (const attribute of collection.attributes ){ -%>
79-
$this-><%- toCamelCase(attribute.key) %> = $<%- toCamelCase(attribute.key) %>;
79+
$this-><%- attribute.key %> = $<%- attribute.key %>;
8080
<% } -%>
8181
}
8282
8383
<% for (const attribute of collection.attributes ){ -%>
8484
public function get<%- toPascalCase(attribute.key) %>(): <%- getType(attribute) %> {
85-
return $this-><%- toCamelCase(attribute.key) %>;
85+
return $this-><%- attribute.key %>;
8686
}
8787
88-
public function set<%- toPascalCase(attribute.key) %>(<%- getType(attribute) %> $<%- toCamelCase(attribute.key) %>): void {
89-
$this-><%- toCamelCase(attribute.key) %> = $<%- toCamelCase(attribute.key) %>;
88+
public function set<%- toPascalCase(attribute.key) %>(<%- getType(attribute) %> $<%- attribute.key %>): void {
89+
$this-><%- attribute.key %> = $<%- attribute.key %>;
9090
}
9191
<% } -%>
9292
}`;

templates/cli/lib/type-generation/languages/swift.js.twig

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -56,21 +56,21 @@ public enum <%- toPascalCase(attribute.key) %>: String, Codable, CaseIterable {
5656
<% } -%>
5757
public 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
<% } -%>

templates/cli/lib/type-generation/languages/typescript.js.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ export enum <%- toPascalCase(attribute.key) %> {
7878
<% } -%>
7979
<% } -%>
8080
<% } -%>
81-
<% for (const collection of collections) { %>
81+
<% for (const collection of collections) { -%>
8282
export type <%- toPascalCase(collection.name) %> = Models.Document & {
8383
<% for (const attribute of collection.attributes) { -%>
84-
<%- toCamelCase(attribute.key) %>: <%- getType(attribute) %>;
84+
<%- attribute.key %>: <%- getType(attribute) %>;
8585
<% } -%>
8686
}
8787
<% } %>`;

0 commit comments

Comments
 (0)