Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to understand ApiOperation comments

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report