1

怎么让 Swagger UI 展示 @ApiResponse 的多个 examples?

 2 years ago
source link: https://www.v2ex.com/t/811951
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

V2EX  ›  程序员

怎么让 Swagger UI 展示 @ApiResponse 的多个 examples?

  JasonLaw · 1 小时 7 分钟前 · 60 次点击

我有如下代码

@ApiResponses(
        {
                @ApiResponse(
                        code = 500, message = "业务异常", response = ErrorResponse.class,
                        examples = @Example(value = {
                                @ExampleProperty(mediaType = MediaType.APPLICATION_JSON_VALUE, value = "{\"error\": {\"code\": \"BUSINESS_EXCEPTION\", \"message\": \"xxx\"}}"),
                                @ExampleProperty(mediaType = MediaType.APPLICATION_JSON_VALUE, value = "{\"error\": {\"code\": \"BUSINESS_EXCEPTION\", \"message\": \"---\", \"data\": [\"item1\", \"item2\"]}}")
                        })
                )
        }
)

但是 Swagger UI 却只展示了其中一个 example ,怎么让它展示出所有 examples 呢?


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK