1. 程式人生 > >《swagger》 swagger + springboot 傳遞 物件引數, List,陣列引數

《swagger》 swagger + springboot 傳遞 物件引數, List,陣列引數

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;
	}