DarkaOnLine / L5-Swagger

OpenApi or Swagger integration to Laravel
https://github.com/DarkaOnLine/L5-Swagger
MIT License
2.64k stars 394 forks source link

Objects in an array #560

Closed KyryloRiznychenko closed 11 months ago

KyryloRiznychenko commented 11 months ago

Description:

I try to make a schema for a request class where I want the sizes parameter to be objects in an array. But the Swagger generates it like JSON instead of objects in an array.

.....
-F 'sizes={
  "size": "5x5",
  "count": 0
},{
  "size": "6x6",
  "count": 0
}'
....

What am I doing wrong?

/**
 *  @OA\Schema(
 *      schema="fooTestSchema",
 *      type="object",
 *      required={"sizes"},
 *      @OA\Property(
 *          property="sizes",
 *          type="array",
 *          @OA\Items(
 *              type="object",
 *              @OA\Property(
 *                  property="size",
 *                  type="string",
 *                  description="Size of the item"
 *              ),
 *              @OA\Property(
 *                  property="count",
 *                  type="integer",
 *                  description="Count of the item"
 *              )
 *          )
 *      )
 *  )
 */

I apologize if my question is easy, but I can't understand where I made a mistake. I'll be glad for any help. Thanks

KyryloRiznychenko commented 11 months ago

I found that the problem was in the incorrect format. I also noticed that to get the correct Swagger CURL (UI), I need to make a hint for Swagger. In my case, it was example={{"propety":'value"},{"propety":'value"}} and Swager generated it as array of objects

KyryloRiznychenko commented 11 months ago

I hope that It'll help someone