restful-react icon indicating copy to clipboard operation
restful-react copied to clipboard

Default array query-parameter stringify format is not comply with the OAS3 spec

Open kazuki opened this issue 5 years ago • 1 comments

Describe the bug

Calling get method in below query parameter, this library generated url is http://xxxx/api?ary[0]=3&ary[1]=1&ary[2]=4

parameters:
  - in: query
    name: ary
    schema:
      type: array
      items:
        type: integer

But in spec https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#fixed-fields-10 , default is style=form and explode=true. This configuration generated url is http://xxxx/api?ary=3&ary=1&ary=4.

To Reproduce

Steps to reproduce the behavior:

  1. write query parameter with array type
  2. generate client-side code
  3. call useGet
  4. fetch to http://xxxx/api?ary[0]=3&ary[1]=1&ary[2]=4

Expected behavior

fetch to http://xxxx/api?ary=3&ary=1&ary=4

Workaround

Add queryParamStringifyOptions {arrayFormat: 'repeat'} on RestfulProvider like #278

kazuki avatar Oct 19 '20 09:10 kazuki

This is great! Looking into it!

TejasQ avatar Oct 22 '20 18:10 TejasQ