I have a class "SubModel" which inherits from class "SuperModel". My REST request returns an object of one of these classes. Now i want to document that in my Swagger UI that either an object of SubModel OR an object of SuperModel will be returned. I googled for this use case and found the @ApiModel annotations but they dont work, does anybody have an idea what i´m doing wrong here?
@ApiModel(value = "SuperModel", discriminator = "foo", subTypes = {
SubModel.class })
public class SuperModel
{
@ApiModelProperty(required = true)
private String foo;
public String getFoo() {
return this.foo;
}
public void setFoo( String foo ) {
this.foo = foo;
}
}
@ApiModel(value = "SubModel")
public class SubModel extends SuperModel
{
private int number;
public int getNumber() {
return this.number;
}
public void setNumber( int number ) {
this.number = number;
}
}
What i see in Swagger UI is only:
SuperModel {
foo (string)
}
I found the example at this site: https://github.com/swagger-api/swagger-core/wiki/Annotations#apiresponses-apiresponse but it doesnt work :-(
Any ideas? Thanks a lot!