swagger @ApiModelProperty example value for List property

前端 未结 9 2385
温柔的废话
温柔的废话 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:41

    None of the solutions worked for me. As it is explained in this Baeldung article besides to include the Example Value in the data model with @ApiModelProperty

    @ApiModel
    public class Foo {
        private long id;
        @ApiModelProperty(name = "name", dataType = "List", example = "[\"str1\", \"str2\", \"str3\"]")
        private List name;
    

    The Controller must also be annotated with @ApiImplicitParams to let Swagger point to the data model:

    @RequestMapping(method = RequestMethod.POST, value = "/foos")
    @ResponseStatus(HttpStatus.CREATED)
    @ResponseBody
    @ApiImplicitParams({ @ApiImplicitParam(name = "foo", 
      value = "List of strings", paramType = "body", dataType = "Foo") })
    public Foo create(@RequestBody final Foo foo) {
    

    You may notice that the dataType point to the class Foo.

提交回复
热议问题