首页 > 解决方案 > 如何从外部资源为 @exampleProperty 注释提供值?

问题描述

我需要将示例属性的动态列表设置为 ApiResponse 的参数

@ApiResponses(value = {
        @ApiResponse(code = 200,message = "Successfully"),
        @ApiResponse(code = 400,
                     message = "Bad Request",
                     examples = @Example(value  ={
                             **@ExampleProperty**(mediaType = "application/json",value = "\"400\": \"The format of field Value1 is invalid.\""),
                             **@ExampleProperty**(mediaType = "application/json",value = "\"400\": \"The format of field Value2 is invalid.\""),
                             **@ExampleProperty**  ....
                            }))
})

如何从外部资源文件而不是 harcoding 为 @ExampleProperty 提供值?

标签: javaspring-bootswaggeropenapi

解决方案


推荐阅读