警告:无法合并@OA\Post()、Zircote、PHP

xxslljrj  于 2023-01-29  发布在  PHP
关注(0)|答案(1)|浏览(279)

我正在使用zircote/swagger-php,但我得到这个错误:
Warning: Unable to merge @OA\Post() ...
不明白为什么,它对最终的swagger.json做了一些不好的事情,因为有些模式是不可识别的。
Definition was declared but never used in document
让我们看一些代码:

/**
     * @OA\POST(
     *     path="/delete",
     *     summary="Delete Evidences Request",
     *     description="Delete Evidences Request",
     *     tags={"Evidences"},
     *     @OA\RequestBody(
     *         @OA\MediaType(
     *             mediaType="application/json",
     *             @OA\Schema(ref="#/components/schemas/DeleteEvidencesRequest")
     *         )
     *     ),
     *     @OA\Response(
     *          response=200,
     *          description="JSON API response",
     *          @OA\MediaType(
     *             mediaType="application/json",
     *             @OA\Schema(ref="#/components/schemas/DeleteEvidencesResponse")
     *         )
     *     )
     * )
     */ 
    protected function Delete(array &$data)
    {
        if (!isset($data['id'])) {
            echo $this->Response()->setErrorMessage("Evidence ID is required");
            return;
        }

        $evidence = new Evidence($data['id'], $this->_organization);
        $this->_evidenceDLL->Delete($evidence);
        echo $this->Response()->setStatus($evidence->_response)->setMessage($evidence->_message);
    }

然后,在\请求\证据\删除. inc中:

<?php 

use OpenApi\Annotations as OA;

/**
 * @OA\Schema(
 *      schema="DeleteEvidencesRequest",
 *      title="Delete Evidences Request",
 *      @OA\Property(
 *          property="object",
 *          type="string",
 *          example="evidence"
 *      ),
 *      @OA\Property(
 *          property="action",
 *          type="string",
 *          example="delete"
 *      ),
 *      @OA\Property(
 *          property="data",
 *          type="object",
 *              @OA\Items(
 *                  @OA\Property(
 *                      property="id",
 *                      type="string",
 *                      example="60"
 *                  ),
 *                  @OA\Property(
 *                      property="entity_id",
 *                      type="string",
 *                      example="177"
 *                  ),
  *                 @OA\Property(
 *                      property="entity_type",
 *                      type="string",
 *                      example="task"
 *                  ),
 *              ),
 *      ),
 *      @OA\Property(
 *          property="organization",
 *          type="string",
 *          example="1"
 *      ),
 *      @OA\Property(
 *          property="site",
 *          oneOf={
 *              @OA\Schema(type="string"),
 *              @OA\Schema(type="boolean"),
 *          },
 *          example="1 | false"
 *      )
 * )
 */
class DeleteEvidencesRequest
{

}

如您所见,名称是正确的,但由于某种原因,它没有出现在swagger editor上:

唯一显示的是来自同一个模式的另一个模式。我做错了什么吗?
先谢了!

46scxncf

46scxncf1#

“无法合并@OA\Post()...“
这可能是因为重复的“path="/delete”“。请检查所有”paths“。

相关问题