swagger @ApiModelProperty example value for List property

前端 未结 9 2382
温柔的废话
温柔的废话 2020-12-14 00:10

I have one class in which there is one property which is List

public class MyClass {
    ....
    @ApiModelProperty(position = 2)
         


        
9条回答
  •  悲&欢浪女
    2020-12-14 00:46

    I managed to get this to work, generating a List of Strings.

    Within the ApiModelProperty with springfox 2, write your example as follows:

    example = "[\"AddLine1\",\"AddLine2\",\"AddLine3\",\"AddLine4\"]"
    

    Here is my example:

    @ApiModelProperty(value = "Address", name = "addLines", 
        example = "[\"AddLine1\",\"AddLine2\",\"AddLine3\",\"AddLine4\"]")
    

    When I render the swagger page, I get the following output:

    "addLines": [
          "AddLine1",
          "AddLine2",
          "AddLine3",
          "AddLine4"
        ],
    

提交回复
热议问题