Swagger Note API Detail description

Source: Internet
Author: User

API Detailed Description

Summary of comments

function Range API Use location
Object Properties @ApiModelProperty
Protocol Set description @Api
Protocol Description @ApiOperation
Response Set @ApiResponses
Response @ApiResponse
Non-object parameter set @ApiImplicitParams
non-object parameter description @ApiImplicitParam
describes the meaning of the returned object @ApiModel

@RequestMapping recommended configuration for this note
Value
Method
Produces

Example:
    @ApiOperation ("Soft deletion of information")@ApiResponses ({@ApiResponse (code = COMMONSTATUS.OK, message = "Operation succeeded"),  @ApiResponse (code = commonstatus.exception, message =  "server internal exception"),  @ApiResponse (code = Commonstatus.forbidden, message =  "Insufficient Permissions")}) @ Apiimplicitparams ({ @ApiImplicitParam (Paramtype =  "query" , DataType =  "Long", name =  "id", value =  "information id", required = true)})  @RequestMapping (value =  "/remove.json", method = Requestmethod.get, produces = Mediatype.application_json_utf8_value) public Restfulprotocol remove (Long ID) {       
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    @ApiModelProperty(value = "标题")    private String  title;
    • 1
    • 2
@ApiImplicitParam
Properties Take value function
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 = MediaType.APPLICATION_JSON_UTF8_VALUE) @PathVariable(name = "id") Long id
    • 1
    • 2
    • 3
Body
  @ApiImplicitParams ({   @ApiImplicitParam (Paramtype =  "body", DataType = " Messageparam ", name = " param ", value = " Information parameters ", Required = true)})  @RequestMapping (value = "/findbyid3 ", method = requestmethod. POST, produces = mediatype. Application_json_utf8_value, consumes = mediatype. Application_json_value)  @RequestBody messageparam param The submitted parameter is a JSON of this object, which is then automatically parsed into 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 (with @ Requestbody after the stream is closed)              
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
Header
  @ApiImplicitParams({ @ApiImplicitParam(paramType = "header", dataType = "Long", name = "id", value = "信息id", required = true) }) String idstr = request.getHeader("id"); if (StringUtils.isNumeric(idstr)) { id = Long.parseLong(idstr); }
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
Form
@ApiImplicitParams({ @ApiImplicitParam(paramType = "form", dataType = "Long", name = "id", value = "信息id", required = true) }) @RequestMapping(value = "/findById5", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
    • 1
    • 2
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced, reproduced please attach the original link to explain the source. 68946676

Swagger Note API Detail description

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.