diff --git a/modules/swagger-codegen/src/main/resources/perl/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/perl/ApiClient.mustache index fa88dbd0333..3a36ce14073 100644 --- a/modules/swagger-codegen/src/main/resources/perl/ApiClient.mustache +++ b/modules/swagger-codegen/src/main/resources/perl/ApiClient.mustache @@ -146,8 +146,8 @@ sub to_path_value { # @return string the serialized object sub to_query_value { my ($self, $object) = @_; - if (is_array($object)) { - return implode(',', $object); + if (ref($object) eq 'ARRAY') { + return join(',', @$object); } else { return $self->to_string($object); } diff --git a/modules/swagger-codegen/src/main/resources/perl/BaseObject.mustache b/modules/swagger-codegen/src/main/resources/perl/BaseObject.mustache index 57a3e5e5fd0..4e9a4699ed3 100644 --- a/modules/swagger-codegen/src/main/resources/perl/BaseObject.mustache +++ b/modules/swagger-codegen/src/main/resources/perl/BaseObject.mustache @@ -19,7 +19,7 @@ use DateTime; # -# return json string +# return perl hash sub to_hash { return decode_json(JSON->new->convert_blessed->encode( shift )); } diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/ApiClient.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/ApiClient.pm index 9987a46ef76..6245329197a 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/ApiClient.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/ApiClient.pm @@ -146,14 +146,13 @@ sub to_path_value { # @return string the serialized object sub to_query_value { my ($self, $object) = @_; - if (is_array($object)) { - return implode(',', $object); + if (ref($object) eq 'ARRAY') { + return join(',', @$object); } else { return $self->to_string($object); } } - # Take value and turn it into a string suitable for inclusion in # the header. If it's a string, pass through unchanged # If it's a datetime object, format it in ISO8601 diff --git a/samples/client/petstore/perl/t/01_pet_api.t b/samples/client/petstore/perl/t/01_pet_api.t index bb5f163bd82..bbd1aae4c1d 100644 --- a/samples/client/petstore/perl/t/01_pet_api.t +++ b/samples/client/petstore/perl/t/01_pet_api.t @@ -77,3 +77,7 @@ is $delete_pet, undef, 'get the null response from delete_pet'; throws_ok{$api->get_pet_by_id(pet_id => $pet_id)} qr/API Exception\(404\): Not Found/, "throw 404 error about pet not found after delete"; #is $get_pet_after_delete->{status}, undef, 'get the updated status after update_pet_with_form'; +my $pets; +lives_ok {$pets = $api->find_pets_by_status(status => [qw(sold available)])} 'array query param processed correctly'; +isa_ok($pets->[0], 'WWW::SwaggerClient::Object::Pet'); +