Skip to content

Commit 485186e

Browse files
committed
Merge pull request #1418 from ampem/master
[Perl] Ensure parameters to "each" is a hash in TO_JSON and from_hash
2 parents 0f75b05 + 1ac6842 commit 485186e

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

modules/swagger-codegen/src/main/resources/perl/BaseObject.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ sub to_hash {
2828
sub TO_JSON {
2929
my $self = shift;
3030
my $_data = {};
31-
foreach my $_key (keys $self->get_attribute_map) {
31+
foreach my $_key (keys %{$self->get_attribute_map}) {
3232
if (defined $self->{$_key}) {
3333
$_data->{$self->get_attribute_map->{$_key}} = $self->{$_key};
3434
}
@@ -40,7 +40,7 @@ sub TO_JSON {
4040
sub from_hash {
4141
my ($self, $hash) = @_;
4242
# loop through attributes and use swagger_types to deserialize the data
43-
while ( my ($_key, $_type) = each $self->get_swagger_types ) {
43+
while ( my ($_key, $_type) = each %{$self->get_swagger_types} ) {
4444
if ($_type =~ /^array\[/i) { # array
4545
my $_subclass = substr($_type, 6, -1);
4646
my @_array = ();

samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/BaseObject.pm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ sub to_hash {
2828
sub TO_JSON {
2929
my $self = shift;
3030
my $_data = {};
31-
foreach my $_key (keys $self->get_attribute_map) {
31+
foreach my $_key (keys %{$self->get_attribute_map}) {
3232
if (defined $self->{$_key}) {
3333
$_data->{$self->get_attribute_map->{$_key}} = $self->{$_key};
3434
}
@@ -40,7 +40,7 @@ sub TO_JSON {
4040
sub from_hash {
4141
my ($self, $hash) = @_;
4242
# loop through attributes and use swagger_types to deserialize the data
43-
while ( my ($_key, $_type) = each $self->get_swagger_types ) {
43+
while ( my ($_key, $_type) = each %{$self->get_swagger_types} ) {
4444
if ($_type =~ /^array\[/i) { # array
4545
my $_subclass = substr($_type, 6, -1);
4646
my @_array = ();

0 commit comments

Comments
 (0)