Nelmioapidocbundle: How to use the dataType array

Created on 23 Mar 2017  路  4Comments  路  Source: nelmio/NelmioApiDocBundle

How can I make the sandbox send an array to the controller?

     *     parameters= {
     *       {
     *         "name"="roles",
     *         "dataType"="array",
     *         "required"=true,
     *         "description"="Roles to patch for the logged user"
     *       }
     *     },

This turns a string.

Am I missing something? I checked the documentation but couldn't find anything related to arrays.

Most helpful comment

Note that this is supported in 3.0:
```php
/**

  • @SWG\Parameter(
  • name="parameters",
  • in="query",
  • type="array",
  • collectionFormat="multi",
  • @SWG\Items(
  • type="string"
  • )
  • )
    */

All 4 comments

I've found a CHEATING (note the caps) for this... please don't hate me:

image

You can just trick the url by passing & and [] into the same parameter. Note that you have to smuggle the first parameter value in before adding more &parameters[]=

Note that this is supported in 3.0:
```php
/**

  • @SWG\Parameter(
  • name="parameters",
  • in="query",
  • type="array",
  • collectionFormat="multi",
  • @SWG\Items(
  • type="string"
  • )
  • )
    */

i am closing old tickets without activity. feel free to open a new issue if needed.

Update for open-api 3.0

     * @OA\Parameter(
     *      name="filter",
     *      in="query",
     *      description="The field used to filter items",
     *      @OA\Schema(
     *          type="array",
     *          @OA\Items(
     *              type="string",
     *          )
     *      )
     * )
Was this page helpful?
0 / 5 - 0 ratings