DarkaOnLine / L5-Swagger

OpenApi or Swagger integration to Laravel

Home Page:https://github.com/DarkaOnLine/L5-Swagger

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Objects in an array

KyryloRiznychenko opened this issue · comments

  • L5-Swagger Version: 8.5.1
  • PHP Version: 8.2.9
  • OS: Linux (Ubuntu)

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

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

I hope that It'll help someone