forked from loafle/openapi-generator-original
Moved object classes' constructor into base class
This commit is contained in:
parent
4264b74e40
commit
f521680c0f
@ -11,7 +11,7 @@ use Log::Any qw($log);
|
|||||||
use Date::Parse;
|
use Date::Parse;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
|
||||||
use base "Class::Accessor";
|
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -20,6 +20,22 @@ use base "Class::Accessor";
|
|||||||
#NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
#NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
__PACKAGE__->mk_classdata('attribute_map');
|
||||||
|
__PACKAGE__->mk_classdata('swagger_types');
|
||||||
|
|
||||||
|
# new object
|
||||||
|
sub new {
|
||||||
|
my ($class, %args) = @_;
|
||||||
|
|
||||||
|
my $self = bless {}, $class;
|
||||||
|
|
||||||
|
foreach my $attribute (keys %{$class->attribute_map}) {
|
||||||
|
my $args_key = $class->attribute_map->{$attribute};
|
||||||
|
$self->$attribute( $args{ $args_key } );
|
||||||
|
}
|
||||||
|
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
# return perl hash
|
# return perl hash
|
||||||
sub to_hash {
|
sub to_hash {
|
||||||
@ -30,9 +46,9 @@ sub to_hash {
|
|||||||
sub TO_JSON {
|
sub TO_JSON {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $_data = {};
|
my $_data = {};
|
||||||
foreach my $_key (keys %{$self->get_attribute_map}) {
|
foreach my $_key (keys %{$self->attribute_map}) {
|
||||||
if (defined $self->{$_key}) {
|
if (defined $self->{$_key}) {
|
||||||
$_data->{$self->get_attribute_map->{$_key}} = $self->{$_key};
|
$_data->{$self->attribute_map->{$_key}} = $self->{$_key};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $_data;
|
return $_data;
|
||||||
@ -43,8 +59,8 @@ sub from_hash {
|
|||||||
my ($self, $hash) = @_;
|
my ($self, $hash) = @_;
|
||||||
|
|
||||||
# loop through attributes and use swagger_types to deserialize the data
|
# loop through attributes and use swagger_types to deserialize the data
|
||||||
while ( my ($_key, $_type) = each %{$self->get_swagger_types} ) {
|
while ( my ($_key, $_type) = each %{$self->swagger_types} ) {
|
||||||
my $_json_attribute = $self->get_attribute_map->{$_key};
|
my $_json_attribute = $self->attribute_map->{$_key};
|
||||||
if ($_type =~ /^array\[/i) { # array
|
if ($_type =~ /^array\[/i) { # array
|
||||||
my $_subclass = substr($_type, 6, -1);
|
my $_subclass = substr($_type, 6, -1);
|
||||||
my @_array = ();
|
my @_array = ();
|
||||||
|
@ -21,39 +21,17 @@ use base "WWW::{{moduleName}}::Object::BaseObject";
|
|||||||
#NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
#NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
||||||
#
|
#
|
||||||
|
|
||||||
my $swagger_types = {
|
__PACKAGE__->swagger_types( {
|
||||||
{{#vars}}'{{name}}' => '{{{datatype}}}'{{#hasMore}},
|
{{#vars}}'{{name}}' => '{{{datatype}}}'{{#hasMore}},
|
||||||
{{/hasMore}}{{/vars}}
|
{{/hasMore}}{{/vars}}
|
||||||
};
|
} );
|
||||||
|
|
||||||
my $attribute_map = {
|
__PACKAGE__->attribute_map( {
|
||||||
{{#vars}}'{{name}}' => '{{baseName}}'{{#hasMore}},
|
{{#vars}}'{{name}}' => '{{baseName}}'{{#hasMore}},
|
||||||
{{/hasMore}}{{/vars}}
|
{{/hasMore}}{{/vars}}
|
||||||
};
|
} );
|
||||||
|
|
||||||
__PACKAGE__->mk_accessors(keys %$attribute_map);
|
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
||||||
|
|
||||||
# new object
|
|
||||||
sub new {
|
|
||||||
my ($class, %args) = @_;
|
|
||||||
my $self = {
|
|
||||||
{{#vars}}#{{#description}}{{{description}}}{{/description}}
|
|
||||||
'{{name}}' => $args{'{{baseName}}'}{{#hasMore}},
|
|
||||||
{{/hasMore}}{{/vars}}
|
|
||||||
};
|
|
||||||
|
|
||||||
return bless $self, $class;
|
|
||||||
}
|
|
||||||
|
|
||||||
# get swagger type of the attribute
|
|
||||||
sub get_swagger_types {
|
|
||||||
return $swagger_types;
|
|
||||||
}
|
|
||||||
|
|
||||||
# get attribute mappping
|
|
||||||
sub get_attribute_map {
|
|
||||||
return $attribute_map;
|
|
||||||
}
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
{{/model}}
|
{{/model}}
|
||||||
|
@ -19,43 +19,18 @@ use base "WWW::SwaggerClient::Object::BaseObject";
|
|||||||
#NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
#NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
||||||
#
|
#
|
||||||
|
|
||||||
my $swagger_types = {
|
__PACKAGE__->swagger_types( {
|
||||||
'code' => 'int',
|
'code' => 'int',
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'message' => 'string'
|
'message' => 'string'
|
||||||
};
|
} );
|
||||||
|
|
||||||
my $attribute_map = {
|
__PACKAGE__->attribute_map( {
|
||||||
'code' => 'code',
|
'code' => 'code',
|
||||||
'type' => 'type',
|
'type' => 'type',
|
||||||
'message' => 'message'
|
'message' => 'message'
|
||||||
};
|
} );
|
||||||
|
|
||||||
__PACKAGE__->mk_accessors(keys %$attribute_map);
|
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
||||||
|
|
||||||
# new object
|
|
||||||
sub new {
|
|
||||||
my ($class, %args) = @_;
|
|
||||||
my $self = {
|
|
||||||
#
|
|
||||||
'code' => $args{'code'},
|
|
||||||
#
|
|
||||||
'type' => $args{'type'},
|
|
||||||
#
|
|
||||||
'message' => $args{'message'}
|
|
||||||
};
|
|
||||||
|
|
||||||
return bless $self, $class;
|
|
||||||
}
|
|
||||||
|
|
||||||
# get swagger type of the attribute
|
|
||||||
sub get_swagger_types {
|
|
||||||
return $swagger_types;
|
|
||||||
}
|
|
||||||
|
|
||||||
# get attribute mappping
|
|
||||||
sub get_attribute_map {
|
|
||||||
return $attribute_map;
|
|
||||||
}
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
@ -11,7 +11,7 @@ use Log::Any qw($log);
|
|||||||
use Date::Parse;
|
use Date::Parse;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
|
||||||
use base "Class::Accessor";
|
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -20,6 +20,22 @@ use base "Class::Accessor";
|
|||||||
#NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
#NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
__PACKAGE__->mk_classdata('attribute_map');
|
||||||
|
__PACKAGE__->mk_classdata('swagger_types');
|
||||||
|
|
||||||
|
# new object
|
||||||
|
sub new {
|
||||||
|
my ($class, %args) = @_;
|
||||||
|
|
||||||
|
my $self = bless {}, $class;
|
||||||
|
|
||||||
|
foreach my $attribute (keys %{$class->attribute_map}) {
|
||||||
|
my $args_key = $class->attribute_map->{$attribute};
|
||||||
|
$self->$attribute( $args{ $args_key } );
|
||||||
|
}
|
||||||
|
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
# return perl hash
|
# return perl hash
|
||||||
sub to_hash {
|
sub to_hash {
|
||||||
@ -30,9 +46,9 @@ sub to_hash {
|
|||||||
sub TO_JSON {
|
sub TO_JSON {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $_data = {};
|
my $_data = {};
|
||||||
foreach my $_key (keys %{$self->get_attribute_map}) {
|
foreach my $_key (keys %{$self->attribute_map}) {
|
||||||
if (defined $self->{$_key}) {
|
if (defined $self->{$_key}) {
|
||||||
$_data->{$self->get_attribute_map->{$_key}} = $self->{$_key};
|
$_data->{$self->attribute_map->{$_key}} = $self->{$_key};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $_data;
|
return $_data;
|
||||||
@ -43,8 +59,8 @@ sub from_hash {
|
|||||||
my ($self, $hash) = @_;
|
my ($self, $hash) = @_;
|
||||||
|
|
||||||
# loop through attributes and use swagger_types to deserialize the data
|
# loop through attributes and use swagger_types to deserialize the data
|
||||||
while ( my ($_key, $_type) = each %{$self->get_swagger_types} ) {
|
while ( my ($_key, $_type) = each %{$self->swagger_types} ) {
|
||||||
my $_json_attribute = $self->get_attribute_map->{$_key};
|
my $_json_attribute = $self->attribute_map->{$_key};
|
||||||
if ($_type =~ /^array\[/i) { # array
|
if ($_type =~ /^array\[/i) { # array
|
||||||
my $_subclass = substr($_type, 6, -1);
|
my $_subclass = substr($_type, 6, -1);
|
||||||
my @_array = ();
|
my @_array = ();
|
||||||
|
@ -19,39 +19,16 @@ use base "WWW::SwaggerClient::Object::BaseObject";
|
|||||||
#NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
#NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
||||||
#
|
#
|
||||||
|
|
||||||
my $swagger_types = {
|
__PACKAGE__->swagger_types( {
|
||||||
'id' => 'int',
|
'id' => 'int',
|
||||||
'name' => 'string'
|
'name' => 'string'
|
||||||
};
|
} );
|
||||||
|
|
||||||
my $attribute_map = {
|
__PACKAGE__->attribute_map( {
|
||||||
'id' => 'id',
|
'id' => 'id',
|
||||||
'name' => 'name'
|
'name' => 'name'
|
||||||
};
|
} );
|
||||||
|
|
||||||
__PACKAGE__->mk_accessors(keys %$attribute_map);
|
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
||||||
|
|
||||||
# new object
|
|
||||||
sub new {
|
|
||||||
my ($class, %args) = @_;
|
|
||||||
my $self = {
|
|
||||||
#
|
|
||||||
'id' => $args{'id'},
|
|
||||||
#
|
|
||||||
'name' => $args{'name'}
|
|
||||||
};
|
|
||||||
|
|
||||||
return bless $self, $class;
|
|
||||||
}
|
|
||||||
|
|
||||||
# get swagger type of the attribute
|
|
||||||
sub get_swagger_types {
|
|
||||||
return $swagger_types;
|
|
||||||
}
|
|
||||||
|
|
||||||
# get attribute mappping
|
|
||||||
sub get_attribute_map {
|
|
||||||
return $attribute_map;
|
|
||||||
}
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
@ -19,55 +19,24 @@ use base "WWW::SwaggerClient::Object::BaseObject";
|
|||||||
#NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
#NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
||||||
#
|
#
|
||||||
|
|
||||||
my $swagger_types = {
|
__PACKAGE__->swagger_types( {
|
||||||
'id' => 'int',
|
'id' => 'int',
|
||||||
'pet_id' => 'int',
|
'pet_id' => 'int',
|
||||||
'quantity' => 'int',
|
'quantity' => 'int',
|
||||||
'ship_date' => 'DateTime',
|
'ship_date' => 'DateTime',
|
||||||
'status' => 'string',
|
'status' => 'string',
|
||||||
'complete' => 'boolean'
|
'complete' => 'boolean'
|
||||||
};
|
} );
|
||||||
|
|
||||||
my $attribute_map = {
|
__PACKAGE__->attribute_map( {
|
||||||
'id' => 'id',
|
'id' => 'id',
|
||||||
'pet_id' => 'petId',
|
'pet_id' => 'petId',
|
||||||
'quantity' => 'quantity',
|
'quantity' => 'quantity',
|
||||||
'ship_date' => 'shipDate',
|
'ship_date' => 'shipDate',
|
||||||
'status' => 'status',
|
'status' => 'status',
|
||||||
'complete' => 'complete'
|
'complete' => 'complete'
|
||||||
};
|
} );
|
||||||
|
|
||||||
__PACKAGE__->mk_accessors(keys %$attribute_map);
|
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
||||||
|
|
||||||
# new object
|
|
||||||
sub new {
|
|
||||||
my ($class, %args) = @_;
|
|
||||||
my $self = {
|
|
||||||
#
|
|
||||||
'id' => $args{'id'},
|
|
||||||
#
|
|
||||||
'pet_id' => $args{'petId'},
|
|
||||||
#
|
|
||||||
'quantity' => $args{'quantity'},
|
|
||||||
#
|
|
||||||
'ship_date' => $args{'shipDate'},
|
|
||||||
#Order Status
|
|
||||||
'status' => $args{'status'},
|
|
||||||
#
|
|
||||||
'complete' => $args{'complete'}
|
|
||||||
};
|
|
||||||
|
|
||||||
return bless $self, $class;
|
|
||||||
}
|
|
||||||
|
|
||||||
# get swagger type of the attribute
|
|
||||||
sub get_swagger_types {
|
|
||||||
return $swagger_types;
|
|
||||||
}
|
|
||||||
|
|
||||||
# get attribute mappping
|
|
||||||
sub get_attribute_map {
|
|
||||||
return $attribute_map;
|
|
||||||
}
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
@ -19,55 +19,24 @@ use base "WWW::SwaggerClient::Object::BaseObject";
|
|||||||
#NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
#NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
||||||
#
|
#
|
||||||
|
|
||||||
my $swagger_types = {
|
__PACKAGE__->swagger_types( {
|
||||||
'id' => 'int',
|
'id' => 'int',
|
||||||
'category' => 'Category',
|
'category' => 'Category',
|
||||||
'name' => 'string',
|
'name' => 'string',
|
||||||
'photo_urls' => 'ARRAY[string]',
|
'photo_urls' => 'ARRAY[string]',
|
||||||
'tags' => 'ARRAY[Tag]',
|
'tags' => 'ARRAY[Tag]',
|
||||||
'status' => 'string'
|
'status' => 'string'
|
||||||
};
|
} );
|
||||||
|
|
||||||
my $attribute_map = {
|
__PACKAGE__->attribute_map( {
|
||||||
'id' => 'id',
|
'id' => 'id',
|
||||||
'category' => 'category',
|
'category' => 'category',
|
||||||
'name' => 'name',
|
'name' => 'name',
|
||||||
'photo_urls' => 'photoUrls',
|
'photo_urls' => 'photoUrls',
|
||||||
'tags' => 'tags',
|
'tags' => 'tags',
|
||||||
'status' => 'status'
|
'status' => 'status'
|
||||||
};
|
} );
|
||||||
|
|
||||||
__PACKAGE__->mk_accessors(keys %$attribute_map);
|
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
||||||
|
|
||||||
# new object
|
|
||||||
sub new {
|
|
||||||
my ($class, %args) = @_;
|
|
||||||
my $self = {
|
|
||||||
#
|
|
||||||
'id' => $args{'id'},
|
|
||||||
#
|
|
||||||
'category' => $args{'category'},
|
|
||||||
#
|
|
||||||
'name' => $args{'name'},
|
|
||||||
#
|
|
||||||
'photo_urls' => $args{'photoUrls'},
|
|
||||||
#
|
|
||||||
'tags' => $args{'tags'},
|
|
||||||
#pet status in the store
|
|
||||||
'status' => $args{'status'}
|
|
||||||
};
|
|
||||||
|
|
||||||
return bless $self, $class;
|
|
||||||
}
|
|
||||||
|
|
||||||
# get swagger type of the attribute
|
|
||||||
sub get_swagger_types {
|
|
||||||
return $swagger_types;
|
|
||||||
}
|
|
||||||
|
|
||||||
# get attribute mappping
|
|
||||||
sub get_attribute_map {
|
|
||||||
return $attribute_map;
|
|
||||||
}
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
@ -19,39 +19,16 @@ use base "WWW::SwaggerClient::Object::BaseObject";
|
|||||||
#NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
#NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
||||||
#
|
#
|
||||||
|
|
||||||
my $swagger_types = {
|
__PACKAGE__->swagger_types( {
|
||||||
'id' => 'int',
|
'id' => 'int',
|
||||||
'name' => 'string'
|
'name' => 'string'
|
||||||
};
|
} );
|
||||||
|
|
||||||
my $attribute_map = {
|
__PACKAGE__->attribute_map( {
|
||||||
'id' => 'id',
|
'id' => 'id',
|
||||||
'name' => 'name'
|
'name' => 'name'
|
||||||
};
|
} );
|
||||||
|
|
||||||
__PACKAGE__->mk_accessors(keys %$attribute_map);
|
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
||||||
|
|
||||||
# new object
|
|
||||||
sub new {
|
|
||||||
my ($class, %args) = @_;
|
|
||||||
my $self = {
|
|
||||||
#
|
|
||||||
'id' => $args{'id'},
|
|
||||||
#
|
|
||||||
'name' => $args{'name'}
|
|
||||||
};
|
|
||||||
|
|
||||||
return bless $self, $class;
|
|
||||||
}
|
|
||||||
|
|
||||||
# get swagger type of the attribute
|
|
||||||
sub get_swagger_types {
|
|
||||||
return $swagger_types;
|
|
||||||
}
|
|
||||||
|
|
||||||
# get attribute mappping
|
|
||||||
sub get_attribute_map {
|
|
||||||
return $attribute_map;
|
|
||||||
}
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
@ -19,7 +19,7 @@ use base "WWW::SwaggerClient::Object::BaseObject";
|
|||||||
#NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
#NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
||||||
#
|
#
|
||||||
|
|
||||||
my $swagger_types = {
|
__PACKAGE__->swagger_types( {
|
||||||
'id' => 'int',
|
'id' => 'int',
|
||||||
'username' => 'string',
|
'username' => 'string',
|
||||||
'first_name' => 'string',
|
'first_name' => 'string',
|
||||||
@ -28,9 +28,9 @@ my $swagger_types = {
|
|||||||
'password' => 'string',
|
'password' => 'string',
|
||||||
'phone' => 'string',
|
'phone' => 'string',
|
||||||
'user_status' => 'int'
|
'user_status' => 'int'
|
||||||
};
|
} );
|
||||||
|
|
||||||
my $attribute_map = {
|
__PACKAGE__->attribute_map( {
|
||||||
'id' => 'id',
|
'id' => 'id',
|
||||||
'username' => 'username',
|
'username' => 'username',
|
||||||
'first_name' => 'firstName',
|
'first_name' => 'firstName',
|
||||||
@ -39,43 +39,8 @@ my $attribute_map = {
|
|||||||
'password' => 'password',
|
'password' => 'password',
|
||||||
'phone' => 'phone',
|
'phone' => 'phone',
|
||||||
'user_status' => 'userStatus'
|
'user_status' => 'userStatus'
|
||||||
};
|
} );
|
||||||
|
|
||||||
__PACKAGE__->mk_accessors(keys %$attribute_map);
|
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
||||||
|
|
||||||
# new object
|
|
||||||
sub new {
|
|
||||||
my ($class, %args) = @_;
|
|
||||||
my $self = {
|
|
||||||
#
|
|
||||||
'id' => $args{'id'},
|
|
||||||
#
|
|
||||||
'username' => $args{'username'},
|
|
||||||
#
|
|
||||||
'first_name' => $args{'firstName'},
|
|
||||||
#
|
|
||||||
'last_name' => $args{'lastName'},
|
|
||||||
#
|
|
||||||
'email' => $args{'email'},
|
|
||||||
#
|
|
||||||
'password' => $args{'password'},
|
|
||||||
#
|
|
||||||
'phone' => $args{'phone'},
|
|
||||||
#User Status
|
|
||||||
'user_status' => $args{'userStatus'}
|
|
||||||
};
|
|
||||||
|
|
||||||
return bless $self, $class;
|
|
||||||
}
|
|
||||||
|
|
||||||
# get swagger type of the attribute
|
|
||||||
sub get_swagger_types {
|
|
||||||
return $swagger_types;
|
|
||||||
}
|
|
||||||
|
|
||||||
# get attribute mappping
|
|
||||||
sub get_attribute_map {
|
|
||||||
return $attribute_map;
|
|
||||||
}
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user