How to understand ApiOperation comments
This article mainly explains "how to understand ApiOperation annotations". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let Xiaobian take you to learn "How to understand ApiOperation annotation"!
1.@ ApiParam, as the name suggests, is an annotation api parameter, that is, used to swagger to provide developer documentation, and the annotation content generated in the documentation. @ApiOperation( value = "Edit Announcement", notes = "Edit Announcement", httpMethod = "POST" ) @RequestMapping( value = "/edit", method = RequestMethod.POST ) public RequestResult edit( @ApiParam(name = "title", value = "announcement title", required = true) @RequestParam("title") String title, @ApiParam(name = "content", value = "announcement content", required = true) @RequestParam("content") String content){2.@ RequestParam, is to get the parameters passed by the front end to the back end, which can be in the get mode or the post mode. If the name field of the parameter passed by the front end is consistent with that of the parameter accepted by the back end, you can omit it or write @RequestParam String title directly. If it is inconsistent, you must write it completely, otherwise you cannot get it. For example, the following bis_key must be written @. ApiOperation( value = "Edit Announcement", notes = "Edit Announcement", httpMethod = "POST" ) @RequestMapping( value = "/edit", method = RequestMethod.POST ) public RequestResult edit( @ApiParam(name = "bis_key", value = "bis_key", required = true) String bisKey, @ApiParam(name = "title", value = "announcement title", required = true) @RequestParam String title, @ApiParam(name = "content", value = "announcement content", required = true) String content, 3.@ PathVariable, Get method, Parameters after url, Parameter binding @ApiOperation(value = "Delete announcement", notes = "Delete announcement", httpMethod = "POST") @RequestMapping(value = "/delete/{bisKey}", method = RequestMethod.POST) public RequestResult remove(@ApiParam(name = "bisKey", value = "announcement ids to be deleted", required = true) @PathVariable String bisKey) {At this point, I believe that everyone has a deeper understanding of "how to understand ApiOperation annotations". Let's do it in practice! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!