首页 > 解决方案 > 使用 JSONObject 作为 @RequestParam 的 Rest 服务的 Spring REST 文档

问题描述

我正在尝试为接受 JSONObject 作为@RequestParam 的休息服务编写 Spring 休息文档。前任:

URL - http://localhost:9090/report?request={cdomain:automation,date:20190920}

我还需要发布 cdomain 的描述和日期以供理解。我可以使用以下代码为 @PathVariable 生成其余文档:

URL - http://localhost:9090/report/11

this.mockMvc.perform(RestDocumentationRequestBuilders.get("/report/{id}",1))
                .andExpect(status().isOk())
                .andExpect(content().contentType("application/json;charset=UTF-8"))
                .andDo(document("fin-report/balance-sheet",
                        pathParameters(parameterWithName("id")
                                .description("Identifier of the person to be obtained.")),
                        responseFields()...

请让我知道如何以 @RequestParam 为 JSONObject 做文档,如下面的代码和 URL:

Code - @RequestMapping(method = RequestMethod.GET, produces = "application/json", path = "report)
    public String getReport(@RequestParam(value="request") JSONObject jobjparam) {...}

URL - http://localhost:9090/report?request={cdomain:automation,date:20190920}

标签: spring-bootspring-restspring-restdocs

解决方案


推荐阅读