@@ -139,11 +139,36 @@ public class {{ name }} extends AbstractOpenApiSchema {
139139 super("oneOf", Boolean.{{ "TRUE" if model.nullable else "FALSE" }});
140140 }
141141
142+ {% - set unparam_type_counts = {} %}
142143 {% - 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 unparam_type_counts %}
147+ {% - set _ = unparam_type_counts .update ({unparam_type : unparam_type_counts [unparam_type ] + 1}) %}
148+ {% - else %}
149+ {% - set _ = unparam_type_counts .update ({unparam_type : 1}) %}
150+ {% - endif %}
151+ {% - endfor %}
152+ {% - for oneOf in model .oneOf %}
153+ {% - set param_type = get_type (oneOf ) %}
154+ {% - set unparam_type = param_type |un_parameterize_type %}
155+ {% - if unparam_type_counts [unparam_type ] > 1 %}
156+ {% - if param_type .startswith ('List<' ) %}
157+ {% - set inner_type = param_type [5:-1] %}
158+ public static {{ name }} from{{ inner_type }}List({{ param_type }} o) {
159+ {% - else %}
160+ public static {{ name }} from{{ param_type.replace('<', '').replace('>', '').replace(' ', '').replace(',', '') }}({{ param_type }} o) {
161+ {% - endif %}
162+ {{ name }} instance = new {{ name }}();
163+ instance.setActualInstance(o);
164+ return instance;
165+ }
166+ {% - else %}
167+ public {{ name }}({{ param_type }} o) {
144168 super("oneOf", Boolean.{{ "TRUE" if model.nullable else "FALSE" }});
145169 setActualInstance(o);
146170 }
171+ {% - endif %}
147172 {% - endfor %}
148173
149174 static {
@@ -204,9 +229,28 @@ public class {{ name }} extends AbstractOpenApiSchema {
204229 return super.getActualInstance();
205230 }
206231
232+ {% - set unparam_types = [] %}
233+ {% - for oneOf in model .oneOf %}
234+ {% - set unparam_type = get_type (oneOf )|un_parameterize_type %}
235+ {% - set _ = unparam_types .append (unparam_type ) %}
236+ {% - endfor %}
237+
207238 {% - for oneOf in model .oneOf %}
208239 {% - set dataType = get_type (oneOf ) %}
209240 {% - set unParameterizedDataType = get_type (oneOf )|un_parameterize_type %}
241+ {% - set base_method_name = "get" + unParameterizedDataType %}
242+
243+ {% - if unparam_types .count (unParameterizedDataType ) > 1 %}
244+ {% - if dataType .startswith ('List<' ) %}
245+ {% - set inner_type = dataType [5:-1] %}
246+ {% - set method_name = "get" + inner_type + "List" %}
247+ {% - else %}
248+ {% - set safe_type = dataType .replace ('<' , '' ).replace ('>' , '' ).replace (' ' , '' ).replace (',' , '' ) %}
249+ {% - set method_name = "get" + safe_type %}
250+ {% - endif %}
251+ {% - else %}
252+ {% - set method_name = base_method_name %}
253+ {% - endif %}
210254
211255 /**
212256 * Get the actual instance of `{{ dataType|escape_html }}`. If the actual instance is not `{{ dataType|escape_html }}`,
@@ -215,7 +259,7 @@ public class {{ name }} extends AbstractOpenApiSchema {
215259 * @return The actual instance of `{{ dataType|escape_html }}`
216260 * @throws ClassCastException if the instance is not `{{ dataType|escape_html }}`
217261 */
218- public {{ dataType }} get {{ unParameterizedDataType }}() throws ClassCastException {
262+ public {{ dataType }} {{ method_name }}() throws ClassCastException {
219263 return ({{ dataType }})super.getActualInstance();
220264 }
221265
0 commit comments