Swagger註解

在Controller代碼中使用swagger提供的註解,暴露Api。json

類註解

@Api

說明該類的做用app

  • tags 標籤,用於邏輯分組,若是不使用,生成的文檔會使用方法名
  • protocols 使用的協議
  • description 描述

@ApiIgnore

隱藏Apiui

方法註解

@ApiOperation

說明方法的做用.net

  • value 方法概要,120字符之內
  • notes 方法詳述
  • consumes content格式,如"application/json, application/xml","- multipart/form-data"(用於Swagger文件上傳)

@ApiImplicitParams / @ApiImplicitParam

說明單個參數code

  • name 參數名
  • value 參數的意思
  • required 參數是否必須傳
  • dataType 參數數據類型(類類型)
  • paramType 參數類型,能夠爲path,query,body,header,form
@ApiImplicitParams({
            @ApiImplicitParam(value = "id", name = "user_id", dataType = "Integer", paramType = "path"),
            @ApiImplicitParam(value = "字段", name = "fields", dataType = "String", paramType = "query", required = true)
    })

@ApiResponses / @ApiResponse

後者只能用在前者中,若是是通用的返回碼,應該註解類orm

  • code 返回碼
  • message 說明
  • response 返回實體
相關文章
相關標籤/搜索