2017-03-17 14 views
1

"SuperModel"클래스로부터 상속받은 "SubModel"클래스가 있습니다. 내 REST 요청은 이러한 클래스 중 하나의 객체를 반환합니다. 이제 Submodel의 객체 또는 SuperModel의 객체 중 하나가 반환되는 Swagger UI에서 문서화하려고합니다. 나는이 유스 케이스에 대한 인터넷 검색 및 @ApiModel 주석을 발견하지만 그들은 일을하지 않는다, 아무도 내가 여기에 잘못하고있는 생각을 가지고 있습니까? 내가 자신감 UI에 표시되는 내용Swagger가 상속받은 객체를 보여주지 않습니다.

@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; 
    } 
} 

가 아니라 :

SuperModel { 
    foo (string) 
} 

는이 사이트에있는 예제를 발견 https://github.com/swagger-api/swagger-core/wiki/Annotations#apiresponses-apiresponse하지만

어떤 아이디어 :-(작동 나던 많이 감사합니다?!

+0

[Swagger Inheritance and Composition]의 가능한 복제본 (http://stackoverflow.com/questions/27862407/swagger-inheritance-and-composition) –

답변

관련 문제