代码之家  ›  专栏  ›  技术社区  ›  Bengall

在没有模型引用的情况下为正文中的请求编写自夸文档

  •  1
  • Bengall  · 技术社区  · 7 年前

    在没有模型引用的情况下,如何在主体中为请求编写自夸文档?

    例如:

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

    我试过用描述的方式来描述,但这行不通。 因为它必须在 Edit Value 字段。

    类似的要求,也一样。

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

    1 回复  |  直到 7 年前
        1
  •  1
  •   Karol Samborski    7 年前

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

    /**
     * @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"
     *                  )
     *          )
     *      )
     *  )
     * )
     */
    
    推荐文章