0

I'm using springfox-swagger2 and springfox-swagger-ui for autogenerated REST documentation.

Problem: any GET requests are documented just fine. But when it comes to POST requests, the request body parameter descriptions are not shown in the swagger ui. But why?

@RestController
public class PersonController {
    @GetMapping
    public PersonRsp findPerson(PersonDTO p) {
        //this works just fine an shows the @ApiParam fields in documentation
    } 

    @PostMapping
    public PersonRsp updatePerson(@RequestBody PersonDTO p) {
        //service logic
        return rsp;
    }
}

class PersonDTO {
    @ApiParam(required = true, value = "the persons family name")
    private String lastname;

    private String firstname;

    @ApiParam(value = "date of birth in format YYYY-MM-DD")
    private Date dob;
}

Question: how can I get the @ApiParam annotation hints being show in the swagger-ui documentation?

membersound
  • 81,582
  • 193
  • 585
  • 1,120

1 Answers1

0

Simple answer: it seems one has to use @ApiModelProperty("some description") for POST requests, and @ApiParam for GET requests.

membersound
  • 81,582
  • 193
  • 585
  • 1,120