@@ -139,11 +139,28 @@ public class {{ name }} extends AbstractOpenApiSchema {
139
139
super("oneOf", Boolean.{{ "TRUE" if model.nullable else "FALSE" }});
140
140
}
141
141
142
+ {% - set constructor_sigs = [] %}
142
143
{% - for oneOf in model .oneOf %}
143
- public {{ name }}({{ get_type(oneOf) }} o) {
144
+ {% - set param_type = get_type (oneOf ) %}
145
+ {% - set unparam_type = param_type |un_parameterize_type %}
146
+ {% - if unparam_type in constructor_sigs %}
147
+ {% - if param_type .startswith ('List<' ) %}
148
+ {% - set inner_type = param_type [5:-1] %}
149
+ public static {{ name }} from{{ inner_type }}List({{ param_type }} o) {
150
+ {% - else %}
151
+ public static {{ name }} from{{ param_type.replace('<', '').replace('>', '').replace(' ', '').replace(',', '') }}({{ param_type }} o) {
152
+ {% - endif %}
153
+ {{ name }} instance = new {{ name }}();
154
+ instance.setActualInstance(o);
155
+ return instance;
156
+ }
157
+ {% - else %}
158
+ {% - set _ = constructor_sigs .append (unparam_type ) %}
159
+ public {{ name }}({{ param_type }} o) {
144
160
super("oneOf", Boolean.{{ "TRUE" if model.nullable else "FALSE" }});
145
161
setActualInstance(o);
146
162
}
163
+ {% - endif %}
147
164
{% - endfor %}
148
165
149
166
static {
@@ -204,9 +221,28 @@ public class {{ name }} extends AbstractOpenApiSchema {
204
221
return super.getActualInstance();
205
222
}
206
223
224
+ {% - set unparam_types = [] %}
225
+ {% - for oneOf in model .oneOf %}
226
+ {% - set unparam_type = get_type (oneOf )|un_parameterize_type %}
227
+ {% - set _ = unparam_types .append (unparam_type ) %}
228
+ {% - endfor %}
229
+
207
230
{% - for oneOf in model .oneOf %}
208
231
{% - set dataType = get_type (oneOf ) %}
209
232
{% - set unParameterizedDataType = get_type (oneOf )|un_parameterize_type %}
233
+ {% - set base_method_name = "get" + unParameterizedDataType %}
234
+
235
+ {% - if unparam_types .count (unParameterizedDataType ) > 1 %}
236
+ {% - if dataType .startswith ('List<' ) %}
237
+ {% - set inner_type = dataType [5:-1] %}
238
+ {% - set method_name = "get" + inner_type + "List" %}
239
+ {% - else %}
240
+ {% - set safe_type = dataType .replace ('<' , '' ).replace ('>' , '' ).replace (' ' , '' ).replace (',' , '' ) %}
241
+ {% - set method_name = "get" + safe_type %}
242
+ {% - endif %}
243
+ {% - else %}
244
+ {% - set method_name = base_method_name %}
245
+ {% - endif %}
210
246
211
247
/**
212
248
* Get the actual instance of `{{ dataType|escape_html }}`. If the actual instance is not `{{ dataType|escape_html }}`,
@@ -215,7 +251,7 @@ public class {{ name }} extends AbstractOpenApiSchema {
215
251
* @return The actual instance of `{{ dataType|escape_html }}`
216
252
* @throws ClassCastException if the instance is not `{{ dataType|escape_html }}`
217
253
*/
218
- public {{ dataType }} get {{ unParameterizedDataType }}() throws ClassCastException {
254
+ public {{ dataType }} {{ method_name }}() throws ClassCastException {
219
255
return ({{ dataType }})super.getActualInstance();
220
256
}
221
257
0 commit comments