zoukankan      html  css  js  c++  java
  • swagger注释API详细说明

    API详细说明

    注释汇总

    @RequestMapping此注解的推荐配置 
    value 
    method 
    produces

    示例:

        @ApiOperation("信息软删除")
        @ApiResponses({ @ApiResponse(code = CommonStatus.OK, message = "操作成功"),
                @ApiResponse(code = CommonStatus.EXCEPTION, message = "服务器内部异常"),
                @ApiResponse(code = CommonStatus.FORBIDDEN, message = "权限不足") })
        @ApiImplicitParams({ @ApiImplicitParam(paramType = "query", dataType = "Long", name = "id", value = "信息id", required = true) })
        @RequestMapping(value = "/remove.json", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
        public RestfulProtocol remove(Long id) {
         @ApiModelProperty(value = "标题")   private String title;
      }

    @ApiImplicitParam

    paramType 示例详解

    path

    @RequestMapping(value = "/findById1/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    
     @PathVariable(name = "id") Long id

    body

    @ApiImplicitParams({ @ApiImplicitParam(paramType = "body", dataType = "MessageParam", name = "param", value = "信息参数", required = true) })
      @RequestMapping(value = "/findById3", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
    
      @RequestBody MessageParam param
    
      提交的参数是这个对象的一个json,然后会自动解析到对应的字段上去,也可以通过流的形式接收当前的请求数据,但是这个和上面的接收方式仅能使用一个(用@RequestBody之后流就会关闭了)

    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);
    }


    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)

  • 相关阅读:
    javascript编程——闭包概念
    Chromium源码编译和初步的代码阅读
    No Code 趋势小记
    Electron中require报错的解决与分析
    C# 值类型与引用类型
    C# 静态成员 和 实例成员
    C# 标识符 和 关键字
    C# 基础知识
    Taghepler
    JQuery 速查表
  • 原文地址:https://www.cnblogs.com/songsong003/p/10772478.html
Copyright © 2011-2022 走看看