Forum Discussion

danijelsudimac's avatar
danijelsudimac
New Contributor
14 days ago

Mixed-Type Arrays with java swagger-annotations 2.0.3.

Hi, 

I'm trying to generate spec looking like this:

using ArraySchema annotation on field "subscriptions" of class TestRequest which is used as DTO like this :

@ArraySchema(maxItems = 100,
schema = @Schema(
description = "An array of order level subscriptions. Subscriptions are either email or sms.\n\n" +
"Validation: Maximum size is 100 items.",
anyOf = {OrderSmsSubscription.class, OrderEmailSubscription.class}))
List<OrderSubscription> subscriptions;

but the specification generated is like this:



the parent class OrderSubscription has annotation:

@Schema(
anyOf = {OrderSmsSubscription.class, OrderEmailSubscription.class},
subTypes = {OrderSmsSubscription.class, OrderEmailSubscription.class},
discriminatorMapping = {
@DiscriminatorMapping(schema = OrderSmsSubscription.class, value = "sms"),
@DiscriminatorMapping(schema = OrderEmailSubscription.class, value = "email")
})

and child classes OrderSmsSubscription and OrderEmailSubscription have

@Schema(allOf = {OrderSubscription.class})

any suggestions why it doesn't generate mixed type array?

No RepliesBe the first to reply