Building document content using Swagger2

Source: Internet
Author: User
Tags int size
Build document content using Swagger2
Import io.swagger.annotations.*; Import Lombok.
Allargsconstructor; Import Lombok.
Data; Import Lombok.
Noargsconstructor;
Import lombok.experimental.Accessors;
Import org.springframework.web.bind.annotation.GetMapping;
Import org.springframework.web.bind.annotation.PostMapping;
Import org.springframework.web.bind.annotation.RequestMapping;

Import Org.springframework.web.bind.annotation.RestController; /** * @author Created by Tan Jian on 2018/4/13 0013. Friday.
 9:30. *©all Rights Reserved. * */** * used in class, description of the use of class/@Api (tags = {"Swagger2 Controller"}) @RequestMapping ("/swagger2") @RestController public class swagger 2Controller {/** * used in methods to illustrate the purpose of the method/@ApiOperation (value = "Get Method", notes = "get")/** * used in method, the use of the parameter/@ApiImplicitParams ({@ApiImplicitParam (name = "S", value = "Join", required = True, DEFA Ultvalue = "OK"})/** * used in the method, the way to describe the response * * * @ApiResponses ({@ApiResponse (code =, mess Age = "Request succeeded", response = Exception.class), @ApiResponse (code = 404, message = "Request Path Error", response = Exception.class)}) @GetM
    Apping ("/get") Public String get (string s) {return s; @PostMapping ("/post") public Swaggerclass post () {return new Swaggerclass (). SetName ("document"). SetSize (5000
    ). Setdescribe ("Automatically generated documents"); /** * is used on the response class, stating that the response class */@ApiModel (description = "Returned response class") @Data @NoArgsConstructor @AllArg
        Sconstructor @Accessors (chain = true) public class swaggerclass{@ApiModelProperty (value = "Name")
        private String name;
        @ApiModelProperty (value = "size") private int size;

    @ApiModelProperty (value = "description") private String describe;
 }
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.