Skip to content

Commit eef07f4

Browse files
committed
add new files for perl, php, ruby
1 parent f23031f commit eef07f4

File tree

13 files changed

+1135
-0
lines changed

13 files changed

+1135
-0
lines changed
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
package WWW::SwaggerClient::Object::Animal;
2+
3+
require 5.6.0;
4+
use strict;
5+
use warnings;
6+
use utf8;
7+
use JSON qw(decode_json);
8+
use Data::Dumper;
9+
use Module::Runtime qw(use_module);
10+
use Log::Any qw($log);
11+
use Date::Parse;
12+
use DateTime;
13+
14+
use base ("Class::Accessor", "Class::Data::Inheritable");
15+
16+
17+
#
18+
#
19+
#
20+
#NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
21+
#
22+
23+
__PACKAGE__->mk_classdata('attribute_map' => {});
24+
__PACKAGE__->mk_classdata('swagger_types' => {});
25+
__PACKAGE__->mk_classdata('method_documentation' => {});
26+
__PACKAGE__->mk_classdata('class_documentation' => {});
27+
28+
# new object
29+
sub new {
30+
my ($class, %args) = @_;
31+
32+
my $self = bless {}, $class;
33+
34+
foreach my $attribute (keys %{$class->attribute_map}) {
35+
my $args_key = $class->attribute_map->{$attribute};
36+
$self->$attribute( $args{ $args_key } );
37+
}
38+
39+
return $self;
40+
}
41+
42+
# return perl hash
43+
sub to_hash {
44+
return decode_json(JSON->new->convert_blessed->encode( shift ));
45+
}
46+
47+
# used by JSON for serialization
48+
sub TO_JSON {
49+
my $self = shift;
50+
my $_data = {};
51+
foreach my $_key (keys %{$self->attribute_map}) {
52+
if (defined $self->{$_key}) {
53+
$_data->{$self->attribute_map->{$_key}} = $self->{$_key};
54+
}
55+
}
56+
return $_data;
57+
}
58+
59+
# from Perl hashref
60+
sub from_hash {
61+
my ($self, $hash) = @_;
62+
63+
# loop through attributes and use swagger_types to deserialize the data
64+
while ( my ($_key, $_type) = each %{$self->swagger_types} ) {
65+
my $_json_attribute = $self->attribute_map->{$_key};
66+
if ($_type =~ /^array\[/i) { # array
67+
my $_subclass = substr($_type, 6, -1);
68+
my @_array = ();
69+
foreach my $_element (@{$hash->{$_json_attribute}}) {
70+
push @_array, $self->_deserialize($_subclass, $_element);
71+
}
72+
$self->{$_key} = \@_array;
73+
} elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
74+
$self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute});
75+
} else {
76+
$log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
77+
}
78+
}
79+
80+
return $self;
81+
}
82+
83+
# deserialize non-array data
84+
sub _deserialize {
85+
my ($self, $type, $data) = @_;
86+
$log->debugf("deserializing %s with %s",Dumper($data), $type);
87+
88+
if ($type eq 'DateTime') {
89+
return DateTime->from_epoch(epoch => str2time($data));
90+
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
91+
return $data;
92+
} else { # hash(model)
93+
my $_instance = eval "WWW::SwaggerClient::Object::$type->new()";
94+
return $_instance->from_hash($data);
95+
}
96+
}
97+
98+
99+
100+
__PACKAGE__->class_documentation({description => '',
101+
class => 'Animal',
102+
required => [], # TODO
103+
} );
104+
105+
__PACKAGE__->method_documentation({
106+
'class_name' => {
107+
datatype => 'string',
108+
base_name => 'className',
109+
description => '',
110+
format => '',
111+
read_only => '',
112+
},
113+
114+
});
115+
116+
__PACKAGE__->swagger_types( {
117+
'class_name' => 'string'
118+
} );
119+
120+
__PACKAGE__->attribute_map( {
121+
'class_name' => 'className'
122+
} );
123+
124+
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
125+
126+
127+
1;
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
package WWW::SwaggerClient::Object::Cat;
2+
3+
require 5.6.0;
4+
use strict;
5+
use warnings;
6+
use utf8;
7+
use JSON qw(decode_json);
8+
use Data::Dumper;
9+
use Module::Runtime qw(use_module);
10+
use Log::Any qw($log);
11+
use Date::Parse;
12+
use DateTime;
13+
14+
use base ("Class::Accessor", "Class::Data::Inheritable");
15+
16+
17+
#
18+
#
19+
#
20+
#NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
21+
#
22+
23+
__PACKAGE__->mk_classdata('attribute_map' => {});
24+
__PACKAGE__->mk_classdata('swagger_types' => {});
25+
__PACKAGE__->mk_classdata('method_documentation' => {});
26+
__PACKAGE__->mk_classdata('class_documentation' => {});
27+
28+
# new object
29+
sub new {
30+
my ($class, %args) = @_;
31+
32+
my $self = bless {}, $class;
33+
34+
foreach my $attribute (keys %{$class->attribute_map}) {
35+
my $args_key = $class->attribute_map->{$attribute};
36+
$self->$attribute( $args{ $args_key } );
37+
}
38+
39+
return $self;
40+
}
41+
42+
# return perl hash
43+
sub to_hash {
44+
return decode_json(JSON->new->convert_blessed->encode( shift ));
45+
}
46+
47+
# used by JSON for serialization
48+
sub TO_JSON {
49+
my $self = shift;
50+
my $_data = {};
51+
foreach my $_key (keys %{$self->attribute_map}) {
52+
if (defined $self->{$_key}) {
53+
$_data->{$self->attribute_map->{$_key}} = $self->{$_key};
54+
}
55+
}
56+
return $_data;
57+
}
58+
59+
# from Perl hashref
60+
sub from_hash {
61+
my ($self, $hash) = @_;
62+
63+
# loop through attributes and use swagger_types to deserialize the data
64+
while ( my ($_key, $_type) = each %{$self->swagger_types} ) {
65+
my $_json_attribute = $self->attribute_map->{$_key};
66+
if ($_type =~ /^array\[/i) { # array
67+
my $_subclass = substr($_type, 6, -1);
68+
my @_array = ();
69+
foreach my $_element (@{$hash->{$_json_attribute}}) {
70+
push @_array, $self->_deserialize($_subclass, $_element);
71+
}
72+
$self->{$_key} = \@_array;
73+
} elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
74+
$self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute});
75+
} else {
76+
$log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
77+
}
78+
}
79+
80+
return $self;
81+
}
82+
83+
# deserialize non-array data
84+
sub _deserialize {
85+
my ($self, $type, $data) = @_;
86+
$log->debugf("deserializing %s with %s",Dumper($data), $type);
87+
88+
if ($type eq 'DateTime') {
89+
return DateTime->from_epoch(epoch => str2time($data));
90+
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
91+
return $data;
92+
} else { # hash(model)
93+
my $_instance = eval "WWW::SwaggerClient::Object::$type->new()";
94+
return $_instance->from_hash($data);
95+
}
96+
}
97+
98+
99+
100+
__PACKAGE__->class_documentation({description => '',
101+
class => 'Cat',
102+
required => [], # TODO
103+
} );
104+
105+
__PACKAGE__->method_documentation({
106+
'class_name' => {
107+
datatype => 'string',
108+
base_name => 'className',
109+
description => '',
110+
format => '',
111+
read_only => '',
112+
},
113+
'declawed' => {
114+
datatype => 'boolean',
115+
base_name => 'declawed',
116+
description => '',
117+
format => '',
118+
read_only => '',
119+
},
120+
121+
});
122+
123+
__PACKAGE__->swagger_types( {
124+
'class_name' => 'string',
125+
'declawed' => 'boolean'
126+
} );
127+
128+
__PACKAGE__->attribute_map( {
129+
'class_name' => 'className',
130+
'declawed' => 'declawed'
131+
} );
132+
133+
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
134+
135+
136+
1;

0 commit comments

Comments
 (0)