Skip to content

Commit b60395e

Browse files
committed
use anyOf for request
1 parent 15d3bc1 commit b60395e

File tree

3 files changed

+27
-33
lines changed

3 files changed

+27
-33
lines changed

api/openapi.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9224,16 +9224,16 @@ components:
92249224
- $ref: "#/components/schemas/multiChannelChannelListMMSObject"
92259225
- $ref: "#/components/schemas/multiChannelChannelListOwnerObject"
92269226
multiChannelChannelListRequestObject:
9227+
anyOf:
9228+
- $ref: "#/components/schemas/multiChannelChannelListRBMObject"
9229+
- $ref: "#/components/schemas/multiChannelChannelListSMSObject"
9230+
- $ref: "#/components/schemas/multiChannelChannelListMMSObject"
92279231
discriminator:
92289232
mapping:
92299233
RBM: "#/components/schemas/multiChannelChannelListRBMObject"
92309234
SMS: "#/components/schemas/multiChannelChannelListSMSObject"
92319235
MMS: "#/components/schemas/multiChannelChannelListMMSObject"
92329236
propertyName: channel
9233-
oneOf:
9234-
- $ref: "#/components/schemas/multiChannelChannelListRBMObject"
9235-
- $ref: "#/components/schemas/multiChannelChannelListSMSObject"
9236-
- $ref: "#/components/schemas/multiChannelChannelListMMSObject"
92379237
multiChannelChannelListOwnerObject:
92389238
properties:
92399239
owner:

bandwidth.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2562,7 +2562,7 @@ components:
25622562
- $ref: '#/components/schemas/multiChannelChannelListMMSObject'
25632563
- $ref: '#/components/schemas/multiChannelChannelListOwnerObject'
25642564
multiChannelChannelListRequestObject:
2565-
oneOf:
2565+
anyOf:
25662566
- $ref: '#/components/schemas/multiChannelChannelListRBMObject'
25672567
- $ref: '#/components/schemas/multiChannelChannelListSMSObject'
25682568
- $ref: '#/components/schemas/multiChannelChannelListMMSObject'

src/main/java/com/bandwidth/sdk/model/MultiChannelChannelListRequestObject.java

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public void write(JsonWriter out, MultiChannelChannelListRequestObject value) th
106106
elementAdapter.write(out, element);
107107
return;
108108
}
109-
throw new IOException("Failed to serialize as the type doesn't match oneOf schemas: MultiChannelChannelListMMSObject, MultiChannelChannelListRBMObject, MultiChannelChannelListSMSObject");
109+
throw new IOException("Failed to serialize as the type doesn't match anyOf schemas: MultiChannelChannelListMMSObject, MultiChannelChannelListRBMObject, MultiChannelChannelListSMSObject");
110110
}
111111

112112
@Override
@@ -149,8 +149,9 @@ public MultiChannelChannelListRequestObject read(JsonReader in) throws IOExcepti
149149
// validate the JSON object to see if any exception is thrown
150150
MultiChannelChannelListRBMObject.validateJsonElement(jsonElement);
151151
actualAdapter = adapterMultiChannelChannelListRBMObject;
152-
match++;
153-
log.log(Level.FINER, "Input data matches schema 'MultiChannelChannelListRBMObject'");
152+
MultiChannelChannelListRequestObject ret = new MultiChannelChannelListRequestObject();
153+
ret.setActualInstance(actualAdapter.fromJsonTree(jsonElement));
154+
return ret;
154155
} catch (Exception e) {
155156
// deserialization failed, continue
156157
errorMessages.add(String.format(Locale.ROOT, "Deserialization for MultiChannelChannelListRBMObject failed with `%s`.", e.getMessage()));
@@ -161,8 +162,9 @@ public MultiChannelChannelListRequestObject read(JsonReader in) throws IOExcepti
161162
// validate the JSON object to see if any exception is thrown
162163
MultiChannelChannelListSMSObject.validateJsonElement(jsonElement);
163164
actualAdapter = adapterMultiChannelChannelListSMSObject;
164-
match++;
165-
log.log(Level.FINER, "Input data matches schema 'MultiChannelChannelListSMSObject'");
165+
MultiChannelChannelListRequestObject ret = new MultiChannelChannelListRequestObject();
166+
ret.setActualInstance(actualAdapter.fromJsonTree(jsonElement));
167+
return ret;
166168
} catch (Exception e) {
167169
// deserialization failed, continue
168170
errorMessages.add(String.format(Locale.ROOT, "Deserialization for MultiChannelChannelListSMSObject failed with `%s`.", e.getMessage()));
@@ -173,35 +175,30 @@ public MultiChannelChannelListRequestObject read(JsonReader in) throws IOExcepti
173175
// validate the JSON object to see if any exception is thrown
174176
MultiChannelChannelListMMSObject.validateJsonElement(jsonElement);
175177
actualAdapter = adapterMultiChannelChannelListMMSObject;
176-
match++;
177-
log.log(Level.FINER, "Input data matches schema 'MultiChannelChannelListMMSObject'");
178+
MultiChannelChannelListRequestObject ret = new MultiChannelChannelListRequestObject();
179+
ret.setActualInstance(actualAdapter.fromJsonTree(jsonElement));
180+
return ret;
178181
} catch (Exception e) {
179182
// deserialization failed, continue
180183
errorMessages.add(String.format(Locale.ROOT, "Deserialization for MultiChannelChannelListMMSObject failed with `%s`.", e.getMessage()));
181184
log.log(Level.FINER, "Input data does not match schema 'MultiChannelChannelListMMSObject'", e);
182185
}
183186

184-
if (match == 1) {
185-
MultiChannelChannelListRequestObject ret = new MultiChannelChannelListRequestObject();
186-
ret.setActualInstance(actualAdapter.fromJsonTree(jsonElement));
187-
return ret;
188-
}
189-
190-
throw new IOException(String.format(Locale.ROOT, "Failed deserialization for MultiChannelChannelListRequestObject: %d classes match result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s", match, errorMessages, jsonElement.toString()));
187+
throw new IOException(String.format(Locale.ROOT, "Failed deserialization for MultiChannelChannelListRequestObject: no class matches result, expected at least 1. Detailed failure message for anyOf schemas: %s. JSON: %s", errorMessages, jsonElement.toString()));
191188
}
192189
}.nullSafe();
193190
}
194191
}
195192

196-
// store a list of schema names defined in oneOf
193+
// store a list of schema names defined in anyOf
197194
public static final Map<String, Class<?>> schemas = new HashMap<String, Class<?>>();
198195

199196
public MultiChannelChannelListRequestObject() {
200-
super("oneOf", Boolean.FALSE);
197+
super("anyOf", Boolean.FALSE);
201198
}
202199

203200
public MultiChannelChannelListRequestObject(Object o) {
204-
super("oneOf", Boolean.FALSE);
201+
super("anyOf", Boolean.FALSE);
205202
setActualInstance(o);
206203
}
207204

@@ -217,11 +214,11 @@ public Map<String, Class<?>> getSchemas() {
217214
}
218215

219216
/**
220-
* Set the instance that matches the oneOf child schema, check
221-
* the instance parameter is valid against the oneOf child schemas:
217+
* Set the instance that matches the anyOf child schema, check
218+
* the instance parameter is valid against the anyOf child schemas:
222219
* MultiChannelChannelListMMSObject, MultiChannelChannelListRBMObject, MultiChannelChannelListSMSObject
223220
*
224-
* It could be an instance of the 'oneOf' schemas.
221+
* It could be an instance of the 'anyOf' schemas.
225222
*/
226223
@Override
227224
public void setActualInstance(Object instance) {
@@ -295,36 +292,33 @@ public MultiChannelChannelListMMSObject getMultiChannelChannelListMMSObject() th
295292
* @throws IOException if the JSON Element is invalid with respect to MultiChannelChannelListRequestObject
296293
*/
297294
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
298-
// validate oneOf schemas one by one
299-
int validCount = 0;
295+
// validate anyOf schemas one by one
300296
ArrayList<String> errorMessages = new ArrayList<>();
301297
// validate the json string with MultiChannelChannelListRBMObject
302298
try {
303299
MultiChannelChannelListRBMObject.validateJsonElement(jsonElement);
304-
validCount++;
300+
return;
305301
} catch (Exception e) {
306302
errorMessages.add(String.format(Locale.ROOT, "Deserialization for MultiChannelChannelListRBMObject failed with `%s`.", e.getMessage()));
307303
// continue to the next one
308304
}
309305
// validate the json string with MultiChannelChannelListSMSObject
310306
try {
311307
MultiChannelChannelListSMSObject.validateJsonElement(jsonElement);
312-
validCount++;
308+
return;
313309
} catch (Exception e) {
314310
errorMessages.add(String.format(Locale.ROOT, "Deserialization for MultiChannelChannelListSMSObject failed with `%s`.", e.getMessage()));
315311
// continue to the next one
316312
}
317313
// validate the json string with MultiChannelChannelListMMSObject
318314
try {
319315
MultiChannelChannelListMMSObject.validateJsonElement(jsonElement);
320-
validCount++;
316+
return;
321317
} catch (Exception e) {
322318
errorMessages.add(String.format(Locale.ROOT, "Deserialization for MultiChannelChannelListMMSObject failed with `%s`.", e.getMessage()));
323319
// continue to the next one
324320
}
325-
if (validCount != 1) {
326-
throw new IOException(String.format(Locale.ROOT, "The JSON string is invalid for MultiChannelChannelListRequestObject with oneOf schemas: MultiChannelChannelListMMSObject, MultiChannelChannelListRBMObject, MultiChannelChannelListSMSObject. %d class(es) match the result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s", validCount, errorMessages, jsonElement.toString()));
327-
}
321+
throw new IOException(String.format(Locale.ROOT, "The JSON string is invalid for MultiChannelChannelListRequestObject with anyOf schemas: MultiChannelChannelListMMSObject, MultiChannelChannelListRBMObject, MultiChannelChannelListSMSObject. no class match the result, expected at least 1. Detailed failure message for anyOf schemas: %s. JSON: %s", errorMessages, jsonElement.toString()));
328322
}
329323

330324
/**

0 commit comments

Comments
 (0)