how to make object of object in swagger in laravel?

Viewed 390

I use swagger in laravel and I want to show this json response:

{
   "status": "yearly",
   "result": [
       {
           "visitCount": {
               "1399": 31,
               "1400": 1
           },
           "visitorCount": {
               "1399": 30,
               "1400": 1
           },
           "submitCount": {
               "1399": 22,
               "1400": 1
           }
       }
   ]
}

result is contains of (visitCount, visitorCount, submitCount) , I want to make a object for each. For example:

    "visitCount": {
               "1399": 31,
               "1400": 1
           }

I can't do it in swaager. could you help me.

My code is :

@OA\Response(
              response=200,
              description="ok",
           @OA\JsonContent( anyOf={
     
               @OA\Schema(
                    type="object",
                         @OA\Property(property="status", type="string", default="yearly"),
                          @OA\Property(property="result", type="array",
                              @OA\Items(type="object",
                                  
                                   @OA\Property(property="visitCount", type="object"),
     
                                   @OA\Property(property="visitorCount", type="object"),
    
                                   @OA\Property(property="submitCount", type="object")
     
                                       ),
                          ),
                         ),
1 Answers

you can add it on your example field.

@OA\Property(property="visitCount", type="string", format="array", example={"1399":"1","1400":"2"})  

Related