Api response looks as:
{
"posts": [
{
"id": 1,
....
}
],
"pagination": {
"page": 1,
....
}
}
You need te create an additional schema which those 2 properties, you can either define that schema inside the response, but when it is used more than once you could also create a separate schema (Definition in v2) and use a reference to that.
An example of how to write it in v3:
/**
* @OA\Get(path="/api/posts",
* @OA\Response(
* response=200,
* description="List posts",
* @OA\JsonContent(
* @OA\Property(
* property="posts",
* type="array",
* @OA\Items(ref="#/components/schemas/Post")
* ),
* @OA\Property(
* property="pagination",
* ref="#/components/schemas/pagination"
* )
* )
* )
* )
*/
/**
* @OA\Schema(
* schema="Post",
* @OA\Property(
* property="id",
* type="integer"
* )
* )
*/
/**
* @OA\Schema(
* schema="pagination",
* @OA\Property(
* property="page",
* type="integer",
* minimum=1
* )
* )
*/
You need te create an additional schema which those 2 properties, you can either define that schema inside the response, but when it is used more than once you could also create a separate schema (Definition in v2) and use a reference to that.
An example of how to write it in v3:
/** * @OA\Get(path="/api/posts", * @OA\Response( * response=200, * description="List posts", * @OA\JsonContent( * @OA\Property( * property="posts", * type="array", * @OA\Items(ref="#/components/schemas/Post") * ), * @OA\Property( * property="pagination", * ref="#/components/schemas/pagination" * ) * ) * ) * ) */ /** * @OA\Schema( * schema="Post", * @OA\Property( * property="id", * type="integer" * ) * ) */ /** * @OA\Schema( * schema="pagination", * @OA\Property( * property="page", * type="integer", * minimum=1 * ) * ) */
this worked for me
Most helpful comment
You need te create an additional schema which those 2 properties, you can either define that schema inside the response, but when it is used more than once you could also create a separate schema (Definition in v2) and use a reference to that.
An example of how to write it in v3: