1
我有一個類「SubModel」,它繼承了類「SuperModel」。我的REST請求返回其中一個類的對象。現在我想在我的Swagger UI中記錄那個SubModel的對象或SuperModel的對象將被返回。我搜索了這個用例,發現了@ApiModel註解,但他們不工作,有沒有人知道我在這裏做錯了什麼?Swagger does not show inherited objects
@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;
}
}
我在揚鞭UI看到的只是:
SuperModel {
foo (string)
}
我發現的例子在這個網站:https://github.com/swagger-api/swagger-core/wiki/Annotations#apiresponses-apiresponse但它不工作:-(
任何想法非常感謝!
[Swagger Inheritance and Composition]的可能重複(http://stackoverflow.com/questions/27862407/swagger-inheritance-and-composition) –