《swagger》 swagger + springboot 传递 对象参数, List,数组参数

  • Post author:
  • Post category:其他


Swagger是最受欢迎的REST APIs文档生成工具之一, 与springboot 的restful风格的api配合, 更是让你事半功倍.

传对象,传list或数组是常遇到的问题.

传递对象参数

	@ApiOperation(value="添加Client", notes="增加Client" )
	@ApiImplicitParam(name = "client", value = "client信息", required = true, dataType = "Client")
	@PutMapping("/save")
	public Client save(@RequestBody Client client) {
		return clientService.save(client);
	}

传递List参数

	@ApiOperation(value="添加权限", notes="增加权限" )
	@ApiImplicitParams({ 
        @ApiImplicitParam(name = "clientId", value = "clientId", required = true, paramType = "query",dataType = "String", defaultValue="1"),
      })
	@PutMapping("/save")
	public Boolean save(String clientId, @RequestParam(value = "powerClientIds") @ApiParam(value = "可被访问的clientId列表") List<String> powerClientIds) {
                ........
		return true;
	}



版权声明:本文为kaige8312原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。