我正在使用 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);
}
Run Code Online (Sandbox Code Playgroud)
然后,在 \Requests\Evidences\delete.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
{
}
Run Code Online (Sandbox Code Playgroud)
如您所见,名称是正确的,但由于某种原因,它没有出现在 swagger 编辑器上:
唯一显示的是同一架构的另一个架构。难道我做错了什么?
提前致谢!
| 归档时间: |
|
| 查看次数: |
2075 次 |
| 最近记录: |