首页 > 解决方案 > 用于第三方类的 Spring Boot swagger ApiModel

问题描述

有最新的spring boot、swagger和maven。有简单的 REST 控制器:

@ApiOperation(value = "Simple controller")
@GetMapping("/resource/{id}")
public Money findMoney(@PathVariable String id) {
    return moneyService.findMoneyById(id);
}

金钱是我无法改变的外部阶级。但我不想显示它的所有字段。我还想在必填字段上添加一些详细信息。我想要类似的东西:

@ApiModel(description = "Money model")
public class Money {
    @ApiModelProperty(notes = "Just ignore it, hidden = true)
    private String notImportantProperty;
    @ApiModelProperty(notes = "Currency")
    private String currency;
etc...

}

标签: javaapispring-bootswagger

解决方案


推荐阅读