My annotations is:
* @OA\RequestBody(
* required=true,
* @OA\JsonContent(
* @OA\Schema (
* type="object",
* @OA\Property(property="status", required=true, description="EventStatus", type="string"),
* @OA\Property(property="comment", required=false, description="Change Status Comment", type="string"),
* example={
* "status": "test status",
* "comment": "test comment"
* }
* )
* )
* )
I tried to add an "example" key, but it didn't work.

example key must be part of the @OA\JsonContent as below.
* @OA\RequestBody(
* required=true,
* @OA\JsonContent(
* example={
* "status": "status",
* "comment": "comment"
* },
* @OA\Schema (
* type="object",
* @OA\Property(property="status", required=true, description="Event Status", type="string"),
* @OA\Property(property="comment", required=false, description="Change Status Comment", type="string"),
* )
* )
* )
With Attributes you must use the following:
use OpenApi\Attributes as OA;
class ObjectController
{
#[OA\RequestBody(
required: true,
content: new OA\JsonContent(
type: Object::class,
example: [
"status" => "status",
"comment" => "comment"
]
)
)]
}
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