【发布时间】:2020-05-13 10:31:54
【问题描述】:
我想为我使用 Springfox 的 Swagger (Spring REST API) 制作的 API 文档自定义模型。
这是我的代码示例:
@ApiOperation("Creating a kafka topic")
@ApiImplicitParams(
@ApiImplicitParam(name = "requestBody", value = "The body of request", required = true,
example = "{\"server\": \"localhost:9092\",\"topic\": \"test\", \"parmas\":{...}}")
)
public ResponseEntity<String> createTopic(@RequestBody String requestBody) {
TopicCreationRequest request = gson.fromJson(requestBody, TopicCreationRequest.class);
...
return ResponseEntity.ok().body(response.toString());
}
有可能吗?
【问题讨论】:
-
为什么不创建请求体的POJO呢?虽然看起来像你呢?
TopicCreationRequest?为什么不使用它作为 Param 而不是 String?
标签: spring-boot swagger-ui swagger-2.0 springfox