jhthorsen / openapi-client

A client for talking to an Open API powered server
11 stars 17 forks source link

"array" type query params not respecting API doc #38

Closed rabbiveesh closed 2 years ago

rabbiveesh commented 2 years ago

Right now, query params are added to the URL object as an arrayref, which causes them to be rendered as repeated key/vals https://github.com/jhthorsen/openapi-client/blob/7f6b81aceaac362846e3fa6c7cbb627c7a9a2459/lib/OpenAPI/Client.pm#L163-L168

That means that if we have a query param called "things":

call({ things => [ qw/one two three/ ] })

It gets rendered to the URL as ?things=one&things=two&things=three.

This is not the correct behavior. For OpenAPI v2, for example, the default (as per the docs) is to connect them via commas, i.e. ?things=one,two,three.

I would love to write up a patch for this, I would just need some guidance as to how to get the correct format from the OpenAPI spec

jhthorsen commented 2 years ago

This also requires a change in J::V::Schema::OpenAPIv2, since it doesn't support the default "collectionFormat" when "type" is "array".

https://github.com/jhthorsen/json-validator/commit/1fdf12cf80b871e65b05194288fae8bc9f303199