Skip to content

Commit ab2ee70

Browse files
committed
Attempt to fix deserialization
1 parent 6fdc1f3 commit ab2ee70

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

.generator/src/generator/templates/modelOneOf.j2

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ public class {{ name }} extends AbstractOpenApiSchema {
7575
try {
7676
boolean attemptParsing = true;
7777
// ensure that we respect type coercion as set on the client ObjectMapper
78+
{%- if unParameterizedDataType == "List" %}
79+
if (token != JsonToken.START_ARRAY) {
80+
attemptParsing = false;
81+
}
82+
{%- else %}
7883
if ({{ unParameterizedDataType }}.class.equals(Integer.class) || {{ unParameterizedDataType }}.class.equals(Long.class) || {{ unParameterizedDataType }}.class.equals(Float.class) || {{ unParameterizedDataType }}.class.equals(Double.class) || {{ unParameterizedDataType }}.class.equals(Boolean.class) || {{ unParameterizedDataType }}.class.equals(String.class)) {
7984
attemptParsing = typeCoercion;
8085
if (!attemptParsing) {
@@ -87,8 +92,13 @@ public class {{ name }} extends AbstractOpenApiSchema {
8792
{%- endif %}
8893
}
8994
}
95+
{%- endif %}
9096
if (attemptParsing) {
97+
{%- if unParameterizedDataType == "List" %}
98+
tmp = tree.traverse(jp.getCodec()).readValueAs(new TypeReference<{{ dataType }}>() {});
99+
{%- else %}
91100
tmp = tree.traverse(jp.getCodec()).readValueAs({{ unParameterizedDataType }}.class);
101+
{%- endif %}
92102
// TODO: there is no validation against JSON schema constraints
93103
// (min, max, enum, pattern...), this does not perform a strict JSON
94104
// validation, which means the 'match' count may be higher than it should be.

0 commit comments

Comments
 (0)