Reputation: 494
I am using zircote/swagger-php, but I am getting this error:
Warning: Unable to merge @OA\Post() ...
Can't understand why, and it is doing something bad to the final swagger.json, because some schemas are not recognizable. Like:
Definition was declared but never used in document
Let's see some code:
/**
* @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);
}
Then, inside \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
{
}
As you can see, the names are correct, but for some reason, it does not appear on swagger editor:
The only shown is another schema from the same. Am I doing something wrong?
Thanks in advance!
Upvotes: 2
Views: 3461
Reputation: 81
"Unable to merge @OA\Post() ... "
This can happen because of duplicated 'path="/delete"'. Check all 'paths'.
Upvotes: 8