【问题标题】:Writing Swagger documentation for requests in body without model referencing在没有模型引用的情况下为正文中的请求编写 Swagger 文档
【发布时间】:2018-12-01 21:45:33
【问题描述】:

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

例如:

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

我已尝试在描述中这样做,但这不起作用 因为它必须显示在Edit Value 字段中。

请求也类似。

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

【问题讨论】:

    标签: php swagger symfony4 nelmioapidocbundle


    【解决方案1】:

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

    /**
     * @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"
     *                  )
     *          )
     *      )
     *  )
     * )
     */
    

    【讨论】:

    • 这行得通,但我将如何处理值,例如:{ "data": { "type": "success", "id": "734234" } } 我已经尝试了描述,但没有运气。
    猜你喜欢
    • 2015-11-29
    • 2016-06-15
    • 1970-01-01
    • 2013-03-18
    • 2020-09-27
    • 1970-01-01
    • 1970-01-01
    • 2011-12-06
    • 2014-11-29
    相关资源
    最近更新 更多