如何在OpenAPI 3上表示类型为可选<T>的属性

时间:2019-07-09 08:38:51

标签: java swagger openapi

我正在为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)。

这是正确的吗?

0 个答案:

没有答案
相关问题