我正在为Servlet编写OpenAPI 3规范。
这是一段代码:
Protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
Dao dao = new Dao();
Optional<String> requestBody = request.getReader() //*** Question: we retreive the informationJson from idJson? is it a body parameter ?
.lines()
.reduce((identity, accumulator) -> identity + " " + accumulator);
String informationIdJson = null;
if (requestBody.isPresent())
informationIdJson = requestBody.get()
...
}
我尝试按如下所示的定义定义此请求对象:
...
/ServletName: #OK
post:
tags:
- ServletName
requestBody:
description: Optional description in *Markdown*
required: true
...
知道requestBody可以包含String值或空值(非null)。
这是正确的吗?