Reputation: 113
I have a object like
public GenericBO {
private int id;
private String code;
private int parentId;
private List<GenericBO> child = new ArrayList<GenericBO>();
//getters and setters respectively
}
How can I create the model for the same in swagger?
Upvotes: 1
Views: 4256
Reputation: 2152
There is no difference between annotating nested or not nested Swagger models.
You have to add io.swagger.annotations.ApiModelProperty
annotation to each attribute of the model.
public GenericModel {
@ApiModelProperty(value = "ID")
private int id;
@ApiModelProperty(value = "Code")
private String code;
@ApiModelProperty(value = "Parent Id")
private int parentId;
@ApiModelProperty(value = "Children")
private List<GenericModel> children = new ArrayList<>();
...
}
If the list object is a collection of other models you must annotate the corresponding model (with @ApiModelProperty
annotations) as well.
Upvotes: 1