2

I am struggling to write a parameter annotation for a field that would have to result as indexed array of integers:

voucher_products[0]: 23
voucher_products[1]: 102
voucher_products[2]: 233

I tried the following

 *     @OA\Parameter(
 *         name="voucher_products",
 *         in="query",
 *         description="",
 *         required=false,
 *         @OA\Schema(
 *             type="array",
 *               @OA\Items(
 *                 type="integer",
 *               )
 *         )
 *     ),
 

I complete the form this way: form

The result I get in the query string parameters is

voucher_products: 23
voucher_products: 102
voucher_products: 233

If I check this field in $_POST its final value is voucher_products=233, since this doesn't turn to be an array.

What am I doing wrong?

1 Answer 1

0

OpenAPI Specification curently doesn't have a way to represent query strings containing an indexed array such as

?arr[0]=val1&arr[1]=val2&arr[2]=val3&...

Here's are the related issues in the OpenAPI Specification repository:
Are indexes in the query parameter array representable?
Support deep objects for query parameters with deepObject style


However, if your API can accept the array with just square brackets but without the indexes

?voucher_products[]=23&voucher_products[]=102&voucher_products[]=233

then you can define it as a parameter with name="voucher_products[]".

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.