Skip to content

Commit 2fb6cdb

Browse files
committed
Fixed some incorrectly generated classes for additionalProperties: oneOf: ...
1 parent de78043 commit 2fb6cdb

File tree

9 files changed

+86
-195
lines changed

9 files changed

+86
-195
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# 1.1.1
2+
* Fixed some incorrectly generated classes for ``additionalProperties: oneOf: ...`` #181
3+
14
# 1.1.0
25
* Updated generated code from Brevo's openapi.yml
36
* Updated references to "new" official Brevo client #

brevo-java-client/src/generated/java/software/xdev/brevo/model/CreateContact.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import java.util.HashMap;
2626
import java.util.List;
2727
import java.util.Map;
28-
import software.xdev.brevo.model.CreateDoiContactAttributesValue;
2928
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
3029
import com.fasterxml.jackson.annotation.JsonTypeName;
3130
import java.io.UnsupportedEncodingException;
@@ -57,7 +56,7 @@ public class CreateContact {
5756

5857
public static final String JSON_PROPERTY_ATTRIBUTES = "attributes";
5958
@jakarta.annotation.Nullable
60-
private Map<String, CreateDoiContactAttributesValue> attributes = new HashMap<>();
59+
private Map<String, Object> attributes = new HashMap<>();
6160

6261
public static final String JSON_PROPERTY_EMAIL_BLACKLISTED = "emailBlacklisted";
6362
@jakarta.annotation.Nullable
@@ -132,13 +131,13 @@ public void setExtId(@jakarta.annotation.Nullable String extId) {
132131
this.extId = extId;
133132
}
134133

135-
public CreateContact attributes(@jakarta.annotation.Nullable Map<String, CreateDoiContactAttributesValue> attributes) {
134+
public CreateContact attributes(@jakarta.annotation.Nullable Map<String, Object> attributes) {
136135

137136
this.attributes = attributes;
138137
return this;
139138
}
140139

141-
public CreateContact putAttributesItem(String key, CreateDoiContactAttributesValue attributesItem) {
140+
public CreateContact putAttributesItem(String key, Object attributesItem) {
142141
if (this.attributes == null) {
143142
this.attributes = new HashMap<>();
144143
}
@@ -152,16 +151,16 @@ public CreateContact putAttributesItem(String key, CreateDoiContactAttributesVal
152151
*/
153152
@jakarta.annotation.Nullable
154153
@JsonProperty(JSON_PROPERTY_ATTRIBUTES)
155-
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
154+
@JsonInclude(content = JsonInclude.Include.ALWAYS, value = JsonInclude.Include.USE_DEFAULTS)
156155

157-
public Map<String, CreateDoiContactAttributesValue> getAttributes() {
156+
public Map<String, Object> getAttributes() {
158157
return attributes;
159158
}
160159

161160

162161
@JsonProperty(JSON_PROPERTY_ATTRIBUTES)
163-
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
164-
public void setAttributes(@jakarta.annotation.Nullable Map<String, CreateDoiContactAttributesValue> attributes) {
162+
@JsonInclude(content = JsonInclude.Include.ALWAYS, value = JsonInclude.Include.USE_DEFAULTS)
163+
public void setAttributes(@jakarta.annotation.Nullable Map<String, Object> attributes) {
165164
this.attributes = attributes;
166165
}
167166

@@ -412,9 +411,13 @@ public String toUrlQueryString(String prefix) {
412411
// add `attributes` to the URL query string
413412
if (getAttributes() != null) {
414413
for (String _key : getAttributes().keySet()) {
415-
if (getAttributes().get(_key) != null) {
416-
joiner.add(getAttributes().get(_key).toUrlQueryString(String.format("%sattributes%s%s", prefix, suffix,
417-
"".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, _key, containerSuffix))));
414+
try {
415+
joiner.add(String.format("%sattributes%s%s=%s", prefix, suffix,
416+
"".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, _key, containerSuffix),
417+
getAttributes().get(_key), URLEncoder.encode(String.valueOf(getAttributes().get(_key)), "UTF-8").replaceAll("\\+", "%20")));
418+
} catch (UnsupportedEncodingException e) {
419+
// Should never happen, UTF-8 is always supported
420+
throw new RuntimeException(e);
418421
}
419422
}
420423
}

brevo-java-client/src/generated/java/software/xdev/brevo/model/CreateDoiContact.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import java.util.HashMap;
2626
import java.util.List;
2727
import java.util.Map;
28-
import software.xdev.brevo.model.CreateDoiContactAttributesValue;
2928
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
3029
import com.fasterxml.jackson.annotation.JsonTypeName;
3130
import java.io.UnsupportedEncodingException;
@@ -51,7 +50,7 @@ public class CreateDoiContact {
5150

5251
public static final String JSON_PROPERTY_ATTRIBUTES = "attributes";
5352
@jakarta.annotation.Nullable
54-
private Map<String, CreateDoiContactAttributesValue> attributes = new HashMap<>();
53+
private Map<String, Object> attributes = new HashMap<>();
5554

5655
public static final String JSON_PROPERTY_INCLUDE_LIST_IDS = "includeListIds";
5756
@jakarta.annotation.Nonnull
@@ -97,13 +96,13 @@ public void setEmail(@jakarta.annotation.Nonnull String email) {
9796
this.email = email;
9897
}
9998

100-
public CreateDoiContact attributes(@jakarta.annotation.Nullable Map<String, CreateDoiContactAttributesValue> attributes) {
99+
public CreateDoiContact attributes(@jakarta.annotation.Nullable Map<String, Object> attributes) {
101100

102101
this.attributes = attributes;
103102
return this;
104103
}
105104

106-
public CreateDoiContact putAttributesItem(String key, CreateDoiContactAttributesValue attributesItem) {
105+
public CreateDoiContact putAttributesItem(String key, Object attributesItem) {
107106
if (this.attributes == null) {
108107
this.attributes = new HashMap<>();
109108
}
@@ -117,16 +116,16 @@ public CreateDoiContact putAttributesItem(String key, CreateDoiContactAttributes
117116
*/
118117
@jakarta.annotation.Nullable
119118
@JsonProperty(JSON_PROPERTY_ATTRIBUTES)
120-
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
119+
@JsonInclude(content = JsonInclude.Include.ALWAYS, value = JsonInclude.Include.USE_DEFAULTS)
121120

122-
public Map<String, CreateDoiContactAttributesValue> getAttributes() {
121+
public Map<String, Object> getAttributes() {
123122
return attributes;
124123
}
125124

126125

127126
@JsonProperty(JSON_PROPERTY_ATTRIBUTES)
128-
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
129-
public void setAttributes(@jakarta.annotation.Nullable Map<String, CreateDoiContactAttributesValue> attributes) {
127+
@JsonInclude(content = JsonInclude.Include.ALWAYS, value = JsonInclude.Include.USE_DEFAULTS)
128+
public void setAttributes(@jakarta.annotation.Nullable Map<String, Object> attributes) {
130129
this.attributes = attributes;
131130
}
132131

@@ -338,9 +337,13 @@ public String toUrlQueryString(String prefix) {
338337
// add `attributes` to the URL query string
339338
if (getAttributes() != null) {
340339
for (String _key : getAttributes().keySet()) {
341-
if (getAttributes().get(_key) != null) {
342-
joiner.add(getAttributes().get(_key).toUrlQueryString(String.format("%sattributes%s%s", prefix, suffix,
343-
"".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, _key, containerSuffix))));
340+
try {
341+
joiner.add(String.format("%sattributes%s%s=%s", prefix, suffix,
342+
"".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, _key, containerSuffix),
343+
getAttributes().get(_key), URLEncoder.encode(String.valueOf(getAttributes().get(_key)), "UTF-8").replaceAll("\\+", "%20")));
344+
} catch (UnsupportedEncodingException e) {
345+
// Should never happen, UTF-8 is always supported
346+
throw new RuntimeException(e);
344347
}
345348
}
346349
}

brevo-java-client/src/generated/java/software/xdev/brevo/model/CreateDoiContactAttributesValue.java

Lines changed: 0 additions & 108 deletions
This file was deleted.

brevo-java-client/src/generated/java/software/xdev/brevo/model/CreateUpdateProduct.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import java.util.HashMap;
2727
import java.util.List;
2828
import java.util.Map;
29-
import software.xdev.brevo.model.GetContactInfoIdentifierParameter;
3029
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
3130
import com.fasterxml.jackson.annotation.JsonTypeName;
3231
import java.io.UnsupportedEncodingException;
@@ -87,7 +86,7 @@ public class CreateUpdateProduct {
8786

8887
public static final String JSON_PROPERTY_META_INFO = "metaInfo";
8988
@jakarta.annotation.Nullable
90-
private Map<String, GetContactInfoIdentifierParameter> metaInfo = new HashMap<>();
89+
private Map<String, Object> metaInfo = new HashMap<>();
9190

9291
public static final String JSON_PROPERTY_UPDATE_ENABLED = "updateEnabled";
9392
@jakarta.annotation.Nullable
@@ -316,13 +315,13 @@ public void setParentId(@jakarta.annotation.Nullable String parentId) {
316315
this.parentId = parentId;
317316
}
318317

319-
public CreateUpdateProduct metaInfo(@jakarta.annotation.Nullable Map<String, GetContactInfoIdentifierParameter> metaInfo) {
318+
public CreateUpdateProduct metaInfo(@jakarta.annotation.Nullable Map<String, Object> metaInfo) {
320319

321320
this.metaInfo = metaInfo;
322321
return this;
323322
}
324323

325-
public CreateUpdateProduct putMetaInfoItem(String key, GetContactInfoIdentifierParameter metaInfoItem) {
324+
public CreateUpdateProduct putMetaInfoItem(String key, Object metaInfoItem) {
326325
if (this.metaInfo == null) {
327326
this.metaInfo = new HashMap<>();
328327
}
@@ -336,16 +335,16 @@ public CreateUpdateProduct putMetaInfoItem(String key, GetContactInfoIdentifierP
336335
*/
337336
@jakarta.annotation.Nullable
338337
@JsonProperty(JSON_PROPERTY_META_INFO)
339-
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
338+
@JsonInclude(content = JsonInclude.Include.ALWAYS, value = JsonInclude.Include.USE_DEFAULTS)
340339

341-
public Map<String, GetContactInfoIdentifierParameter> getMetaInfo() {
340+
public Map<String, Object> getMetaInfo() {
342341
return metaInfo;
343342
}
344343

345344

346345
@JsonProperty(JSON_PROPERTY_META_INFO)
347-
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
348-
public void setMetaInfo(@jakarta.annotation.Nullable Map<String, GetContactInfoIdentifierParameter> metaInfo) {
346+
@JsonInclude(content = JsonInclude.Include.ALWAYS, value = JsonInclude.Include.USE_DEFAULTS)
347+
public void setMetaInfo(@jakarta.annotation.Nullable Map<String, Object> metaInfo) {
349348
this.metaInfo = metaInfo;
350349
}
351350

@@ -629,9 +628,13 @@ public String toUrlQueryString(String prefix) {
629628
// add `metaInfo` to the URL query string
630629
if (getMetaInfo() != null) {
631630
for (String _key : getMetaInfo().keySet()) {
632-
if (getMetaInfo().get(_key) != null) {
633-
joiner.add(getMetaInfo().get(_key).toUrlQueryString(String.format("%smetaInfo%s%s", prefix, suffix,
634-
"".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, _key, containerSuffix))));
631+
try {
632+
joiner.add(String.format("%smetaInfo%s%s=%s", prefix, suffix,
633+
"".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, _key, containerSuffix),
634+
getMetaInfo().get(_key), URLEncoder.encode(String.valueOf(getMetaInfo().get(_key)), "UTF-8").replaceAll("\\+", "%20")));
635+
} catch (UnsupportedEncodingException e) {
636+
// Should never happen, UTF-8 is always supported
637+
throw new RuntimeException(e);
635638
}
636639
}
637640
}

brevo-java-client/src/generated/java/software/xdev/brevo/model/CreateUpdateProducts.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import java.util.HashMap;
2727
import java.util.List;
2828
import java.util.Map;
29-
import software.xdev.brevo.model.GetContactInfoIdentifierParameter;
3029
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
3130
import com.fasterxml.jackson.annotation.JsonTypeName;
3231
import java.io.UnsupportedEncodingException;
@@ -86,7 +85,7 @@ public class CreateUpdateProducts {
8685

8786
public static final String JSON_PROPERTY_META_INFO = "metaInfo";
8887
@jakarta.annotation.Nullable
89-
private Map<String, GetContactInfoIdentifierParameter> metaInfo = new HashMap<>();
88+
private Map<String, Object> metaInfo = new HashMap<>();
9089

9190
public static final String JSON_PROPERTY_DELETED_AT = "deletedAt";
9291
@jakarta.annotation.Nullable
@@ -311,13 +310,13 @@ public void setParentId(@jakarta.annotation.Nullable String parentId) {
311310
this.parentId = parentId;
312311
}
313312

314-
public CreateUpdateProducts metaInfo(@jakarta.annotation.Nullable Map<String, GetContactInfoIdentifierParameter> metaInfo) {
313+
public CreateUpdateProducts metaInfo(@jakarta.annotation.Nullable Map<String, Object> metaInfo) {
315314

316315
this.metaInfo = metaInfo;
317316
return this;
318317
}
319318

320-
public CreateUpdateProducts putMetaInfoItem(String key, GetContactInfoIdentifierParameter metaInfoItem) {
319+
public CreateUpdateProducts putMetaInfoItem(String key, Object metaInfoItem) {
321320
if (this.metaInfo == null) {
322321
this.metaInfo = new HashMap<>();
323322
}
@@ -331,16 +330,16 @@ public CreateUpdateProducts putMetaInfoItem(String key, GetContactInfoIdentifier
331330
*/
332331
@jakarta.annotation.Nullable
333332
@JsonProperty(JSON_PROPERTY_META_INFO)
334-
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
333+
@JsonInclude(content = JsonInclude.Include.ALWAYS, value = JsonInclude.Include.USE_DEFAULTS)
335334

336-
public Map<String, GetContactInfoIdentifierParameter> getMetaInfo() {
335+
public Map<String, Object> getMetaInfo() {
337336
return metaInfo;
338337
}
339338

340339

341340
@JsonProperty(JSON_PROPERTY_META_INFO)
342-
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
343-
public void setMetaInfo(@jakarta.annotation.Nullable Map<String, GetContactInfoIdentifierParameter> metaInfo) {
341+
@JsonInclude(content = JsonInclude.Include.ALWAYS, value = JsonInclude.Include.USE_DEFAULTS)
342+
public void setMetaInfo(@jakarta.annotation.Nullable Map<String, Object> metaInfo) {
344343
this.metaInfo = metaInfo;
345344
}
346345

@@ -597,9 +596,13 @@ public String toUrlQueryString(String prefix) {
597596
// add `metaInfo` to the URL query string
598597
if (getMetaInfo() != null) {
599598
for (String _key : getMetaInfo().keySet()) {
600-
if (getMetaInfo().get(_key) != null) {
601-
joiner.add(getMetaInfo().get(_key).toUrlQueryString(String.format("%smetaInfo%s%s", prefix, suffix,
602-
"".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, _key, containerSuffix))));
599+
try {
600+
joiner.add(String.format("%smetaInfo%s%s=%s", prefix, suffix,
601+
"".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, _key, containerSuffix),
602+
getMetaInfo().get(_key), URLEncoder.encode(String.valueOf(getMetaInfo().get(_key)), "UTF-8").replaceAll("\\+", "%20")));
603+
} catch (UnsupportedEncodingException e) {
604+
// Should never happen, UTF-8 is always supported
605+
throw new RuntimeException(e);
603606
}
604607
}
605608
}

0 commit comments

Comments
 (0)