I use Laravel + Swagger PHP. In one of my services, I handle parameters like this :
$params = [
'addressChild' => [
'address' => ' ... ',
'city' => ' ... ',
],
'addressParent' => [
'address' => ' ... ',
'city' => ' ... ',
],
];
I am trying to describe this schema in Swagger Annotations, using OpenApi 3 :
/**
* @OA\Post(
* path="/entity/{entity}/addresses",
* @OA\Response(
* response=200,
* @OA\JsonContent()
* ),
* @OA\RequestBody(
* description="Addresses to store",
* required=true,
* @OA\JsonContent(
* type="object",
* @OA\Property()
* ),
* ),
* )
*
*/
public function update(Request $request)
{
// ...
}
I tried many things like :
@OA\JsonContent(
type="object",
@OA\Property(name="addressKid", ref="#/components/schemas/ParkingAddressRequest") // error
),
My address data is described in ref="#/components/schemas/ParkingAddressRequest" schema, how can I set it as an array in RequestBody ?
If I understood your problem, you could do it like this
/**
* @OA\Post(
* path="/entity/{entity}/addresses",
* @OA\Response(
* response=200,
* @OA\JsonContent()
* ),
* @OA\RequestBody(
* description="Addresses to store",
* required=true,
* @OA\JsonContent(
* type="array",
* @OA\Items(ref="#/components/schemas/ParkingAddressRequest")
* ),
* ),
* )
*
*/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With