1、方案一:
1)对应api中写法
@ApiOperation(value = "查询厂商" , notes="查询厂商") @RequestMapping(value = "/getManufacture/{userName}/{factoryName}", method = ) @ResponseBody public List
2)对应controller也需要加上参数
public List<ManufacturerDto> getManufacture(@ApiParam(name = "userName", value = "用户名") @PathVariable(value = "userName") String userName,@ApiParam(name = "factoryName", value = "工厂名") @PathVariable(value = "factoryName") String factoryName) {}
2、方案二:注意paramType必须为path
1)@ApiOperation(value = "查询厂商" , notes="查询厂商")
@RequestMapping(value = "/getManufacture/{userName}/{factoryName}", method = )
@ResponseBody
@ApiImplicitParams({
@ApiImplicitParam(name = "userName", value = "用户名", required = false, dataType = "string", paramType = "path"),
@ApiImplicitParam(name = "factoryName", value = "工厂名称", required = false, dataType = "string", paramType = "path")
})
public List<ManufacturerDto> getManufacture( @PathVariable("userName") String userName,@PathVariable("factoryName") String factoryName);
2)对应controller也需要加上参数
public List<ManufacturerDto> getManufacture(@PathVariable(value = "userName") String userName,@PathVariable(value = "factoryName") String factoryName) {}
PS:
说明:swagger2默认的contenttype为json,上面配置类我已改成表单格式。 @Param里的name属性就是表单上的key,required表示该字段是否为必填项,value就是对属性的解释说明,type说明了该字段的数据类型,而paramType = "path"用来获取/{xx}参数,其它情况下用query即可,