如何使用Springfox在Swagger中隐藏会话参数

时间:2017-07-04 03:30:39

标签: spring-boot swagger-ui

    @ApiOperation(value = "获取打卡信息", notes = "获取打卡信息")
@RequestMapping(method = RequestMethod.GET, value = "/{mPhone}/{mPassword}/{date}")
@ApiImplicitParams({ 
        @ApiImplicitParam(name = "mPhone", value = "手机号", required = true, dataType = "String",defaultValue="13268690268",paramType="Path"),
        @ApiImplicitParam(name = "mPassword", value = "密码", required = true, dataType = "String",defaultValue="111111",paramType="Path"),
        @ApiImplicitParam(name = "date", value = "日期", required = true, dataType = "String",defaultValue="2017-07-04",paramType="Path"),
        @ApiImplicitParam(name = "httpSession", value = "Session", required = false)})
public @ResponseBody String getSignInfo(@PathVariable String mPhone, @PathVariable String mPassword,
        @PathVariable String date, 
        HttpSession httpSession) {
.......
 }

enter image description here

我想从文档中删除此参数(httpSession),我需要帮助。

1 个答案:

答案 0 :(得分:0)

默认情况下,Springfox不会显示这些值。 httpSession在您的案例中可见的原因是因为您自己将其添加为隐式参数:

@ApiImplicitParam(name = "httpSession", value = "Session", required = false)

如果您不想弹出httpSession,请从隐式参数中删除它。此外,您甚至不必使用@ApiImplicitParam,您可以使用@ApiParam

@ApiOperation(value = "获取打卡信息", notes = "获取打卡信息")
@RequestMapping(method = RequestMethod.GET, value = "/{mPhone}/{mPassword}/{date}")
public @ResponseBody String getSignInfo(
        @ApiParam(value = "手机号", required = true, dataType = "String",defaultValue="13268690268")
        @PathVariable String mPhone,
        @ApiParam(value = "密码", required = true, dataType = "String",defaultValue="111111")
        @PathVariable String mPassword,
        @ApiParam(value = "日期", required = true, dataType = "String",defaultValue="2017-07-04")
        @PathVariable String date, 
        HttpSession httpSession) {
    // ...
 }