(forward) Swagger Note API details

Source: Internet
Author: User

Reference: 68946676 81197448

With the development of Internet technology, the current site architecture is basically from the original back-end rendering, has become: front-end rendering, back-end separation of the form, and the front-end technology and back-end technology on their own road farther. The only connection between the front end and the back end becomes the API interface, and the API documentation becomes a link between the front and back developers, becoming more and more important, swaggeris a framework that allows you to write API documentation better. --Reference Ryugou's column API for more information

Summary of comments

Function range Api Use location
Object Properties @ApiModelProperty Used on fields in the Access parameter object
Protocol Set Description @Api For the Controller class
Protocol description @ApiOperation Used in the controller's method.
Response Set @ApiResponses Used in the controller's method.
Response @ApiResponse Used in the @ApiResponses inside
Set of non-object parameters @ApiImplicitParams Used in the controller's method.
Non-object parameter description @ApiImplicitParam Used in the @apiimplicitparams method.
Describe the meaning of the returned object Used on the Return object class Used on the Return object class

@RequestMapping recommended configuration for this note

Value, Method,produces

Example:
@ApiOperation ("Information soft Delete")    = commonstatus.ok, message = "Operation succeeded"),            = commonstatus.exception, message = "Server internal exception"),            = commonstatus.forbidden, message = "Insufficient permissions")}    )}) c10/>= "/remove.json", method = Requestmethod.get, produces = mediatype.application_json_utf8_value)    /c11> Public restfulprotocol remove (Long ID) {
}

@ApiModelProperty (value = "title")    private String  title;
@ApiImplicitParam
Property Take value Role
Paramtype Query parameter types
Path Submit data as an address
Query Automatic mapping assignment with parameter completion
Body Submit as a stream supports post only
Header Parameters are submitted inside request headers
Form Submit as Form form support post only
DataType The data type of the parameter is only described as a flag, and there is no actual validation
Long
String
Name Receive parameter names
Value Description of the meaning of the receive parameter
Required parameter is required
True Must fill in
False Not required
DefaultValue Default value

Paramtype Example Detailed path
@RequestMapping (value = "/findbyid1/{id}", method = Requestmethod.get, produces ="id") Long ID
Body
true )})  = "/findbyid3", method = Requestmethod.post, produces = Mediatype.application_json_utf8_value, consumes = mediatype.application_json_value)  @RequestBody The  parameter submitted by the Messageparam Param is a JSON of this object, It will then automatically resolve to the corresponding field, or it can receive the current request data in the form of a stream, but this and the above receive method can only use one (the stream will be closed after @requestbody)
Header
true ) })    = Request.getheader ("id");         if (Stringutils.isnumeric (idstr)) {            = Long.parselong (idstr);        }
Form
True= "/findbyid5", method = Requestmethod.post, produces = Mediatype.application_j

(forward) Swagger Note API details

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.