我可以在Swagger2中将模型属性隐藏在一个地方,然后在另一个地方显示吗?

时间:2019-09-28 10:07:42

标签: rest spring-boot swagger-ui swagger-2.0 springfox

我对两个单独的控制器使用相同的模型。在一个控制器中,我想隐藏id,在另一个控制器中,我想显示它。 这是我要隐藏PaymentCardDto的ID的地方:

@RequestMapping(method = arrayOf(RequestMethod.POST), path = arrayOf("/api/card/add"))
@ResponseBody
fun addCustomerCard(@RequestBody paymentCardDto: PaymentCardDto,
                    @RequestParam(required = false, name = "set_current") setAsCurrent: String? = null,
                    @Autowired request: HttpServletRequest): CardVerificationResponseDto

在这里我想在PaymentCardDto中显示ID:

@RequestMapping(
        method = arrayOf(RequestMethod.POST),
        path = arrayOf("/api/card/edit/{payment_card_id}")
)
@ResponseBody
fun editCardCompanyInfo(@PathVariable("payment_card_id") paymentCardId: Long,
                        @RequestBody newCardInfo: PaymentCardDto,
                        @Autowired request: HttpServletRequest): PaymentCardDto

这是我的PaymentCardDto:

data class PaymentCardDto(
    @ApiModelProperty(value = "id of payment card in customer context", example = "1651564")
    var id: Long?,
    ...)

0 个答案:

没有答案