swagger 定义自己的状态码

1.去掉swagger默认的状态码

For 1.0.2 or prior

  new SwaggerSpringMvcPlugin(...)
        //More config
        .useDefaultResponseMessages(false) //<-- this should be false
  ...;

For 2.x

  new Docket()
        //More config
        .useDefaultResponseMessages(false) //<-- this should be false
  ...;

2.在接口中定义状态码

    @RequestMapping(value="/async/data", method=RequestMethod.GET, produces="application/json")
    @ApiOperation(value = "Gets data", notes="Gets data asynchronously")
    @ApiResponses(value={@ApiResponse(code=200, message="OK")})
    public Callable> getData(){
        return ( () -> {return dataService.loadData();} );
    }

你可能感兴趣的:(工具)