Discriminator is not included if objects are used in a list during tests
Closed this issue · 0 comments
BrandonSchmitt commented
I have an operation accepting a list of objects which use inheritance in the request body. When executing a test, I get the following error:
io.micronaut.http.client.exceptions.HttpClientResponseException:
Error decoding HTTP response body: Error decoding stream for type [interface java.util.List]: Missing type id when trying to resolve subtype of [simple type, ModelVO]: missing type id property 'type'
at [Source: (byte[])"[{"enabled":true, ...}]"; line: 1, column: 168] (through reference chain: java.util.ArrayList[0])
at io.micronaut.http.client.netty.DefaultHttpClient$12.channelRead0(DefaultHttpClient.java:2186)
...
Caused by: io.micronaut.http.codec.CodecException: Error decoding stream for type [interface java.util.List]: Missing type id when trying to resolve subtype of [simple type, class ModelVO]: missing type id property 'type'
at [Source: (byte[])"[{"enabled":true, ...}]"; line: 1, column: 168] (through reference chain: java.util.ArrayList[0])
at io.micronaut.jackson.codec.JacksonMediaTypeCodec.decode(JacksonMediaTypeCodec.java:194)
...
Caused by: com.fasterxml.jackson.databind.exc.InvalidTypeIdException: Missing type id when trying to resolve subtype of [simple type, class ModelVO]: missing type id property 'type'
at [Source: (byte[])"[{"enabled":true, ...}]"; line: 1, column: 168] (through reference chain: java.util.ArrayList[0])
at com.fasterxml.jackson.databind.exc.InvalidTypeIdException.from(InvalidTypeIdException.java:43)
If I change the operation to just take one object instead of a list of those objects it works perfectly.
After debugging for a while I assume it's just the test client not serializing the discriminator property as expected. I have created a test case covering this issue: BrandonSchmitt@04b7cc6