首页 > 解决方案 > 在没有模型引用的情况下为正文中的请求编写 Swagger 文档

问题描述

如何在没有模型引用的情况下为正文中的请求编写 Swagger 文档?

例如:

@SWG\Parameter( 
    name="date",
    in="body",
    content="application/json",
    type="object",
    {custom written JSON}
)

我试图在描述中做到这一点,但这不起作用,因为它必须在Edit Value现场显示。

请求也类似。

我已经搜索了谷歌,但没有找到解决方案。
这样的事情可能吗?

标签: phpswaggersymfony4nelmioapidocbundle

解决方案


你可以做到,但不是很明显。这对我有用:

/**
 * @SWG\Get(
 *  path="/route",
 *  tags={"tag"},
 *  @SWG\Response(
 *      response="200",
 *      description="Simple list of name and value pairs ",
 *      @SWG\Schema(
 *          type="array",
 *          @SWG\Items(
 *                  @SWG\Property(
 *                      property="id",
 *                      type="string"
 *                  ),
 *                  @SWG\Property(
 *                      property="name",
 *                      type="string"
 *                  )
 *          )
 *      )
 *  )
 * )
 */

推荐阅读