update type mapping, update test.pl to use local file for testing upload

This commit is contained in:
William Cheng 2015-05-08 03:56:35 +08:00
parent 063a1ffd36
commit fc43828c20
10 changed files with 14 additions and 15 deletions

View File

@ -57,7 +57,6 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig {
additionalProperties.put("artifactVersion", artifactVersion); additionalProperties.put("artifactVersion", artifactVersion);
languageSpecificPrimitives.add("int"); languageSpecificPrimitives.add("int");
languageSpecificPrimitives.add("Math::BigInt");
languageSpecificPrimitives.add("double"); languageSpecificPrimitives.add("double");
languageSpecificPrimitives.add("string"); languageSpecificPrimitives.add("string");
languageSpecificPrimitives.add("boolean"); languageSpecificPrimitives.add("boolean");
@ -66,7 +65,7 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig {
languageSpecificPrimitives.add("HASH"); languageSpecificPrimitives.add("HASH");
typeMapping.put("integer", "int"); typeMapping.put("integer", "int");
typeMapping.put("long", "Math::BigInt"); typeMapping.put("long", "int");
typeMapping.put("float", "double"); typeMapping.put("float", "double");
typeMapping.put("double", "double"); typeMapping.put("double", "double");
typeMapping.put("boolean", "boolean"); typeMapping.put("boolean", "boolean");

View File

@ -65,7 +65,7 @@ sub _deserialize {
if ($type eq 'DateTime') { if ($type eq 'DateTime') {
return DateTime->from_epoch(epoch => str2time($data)); return DateTime->from_epoch(epoch => str2time($data));
} elsif ( grep( /^$type$/, ('int', 'Math::BigInt', 'double', 'string', 'boolean'))) { } elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
return $data; return $data;
} else { # hash(model) } else { # hash(model)
my $_instance = eval "WWW::{{invokerPackage}}::Object::$type->new()"; my $_instance = eval "WWW::{{invokerPackage}}::Object::$type->new()";

View File

@ -65,7 +65,7 @@ sub _deserialize {
if ($type eq 'DateTime') { if ($type eq 'DateTime') {
return DateTime->from_epoch(epoch => str2time($data)); return DateTime->from_epoch(epoch => str2time($data));
} elsif ( grep( /^$type$/, ('int', 'Math::BigInt', 'double', 'string', 'boolean'))) { } elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
return $data; return $data;
} else { # hash(model) } else { # hash(model)
my $_instance = eval "WWW::SwaggerClient::Object::$type->new()"; my $_instance = eval "WWW::SwaggerClient::Object::$type->new()";

View File

@ -20,7 +20,7 @@ use base "WWW::SwaggerClient::Object::BaseObject";
# #
my $swagger_types = { my $swagger_types = {
'id' => 'Math::BigInt', 'id' => 'int',
'name' => 'string' 'name' => 'string'
}; };

View File

@ -20,8 +20,8 @@ use base "WWW::SwaggerClient::Object::BaseObject";
# #
my $swagger_types = { my $swagger_types = {
'id' => 'Math::BigInt', 'id' => 'int',
'pet_id' => 'Math::BigInt', 'pet_id' => 'int',
'quantity' => 'int', 'quantity' => 'int',
'ship_date' => 'DateTime', 'ship_date' => 'DateTime',
'status' => 'string', 'status' => 'string',

View File

@ -20,7 +20,7 @@ use base "WWW::SwaggerClient::Object::BaseObject";
# #
my $swagger_types = { my $swagger_types = {
'id' => 'Math::BigInt', 'id' => 'int',
'category' => 'Category', 'category' => 'Category',
'name' => 'string', 'name' => 'string',
'photo_urls' => 'ARRAY[string]', 'photo_urls' => 'ARRAY[string]',

View File

@ -20,7 +20,7 @@ use base "WWW::SwaggerClient::Object::BaseObject";
# #
my $swagger_types = { my $swagger_types = {
'id' => 'Math::BigInt', 'id' => 'int',
'name' => 'string' 'name' => 'string'
}; };

View File

@ -20,7 +20,7 @@ use base "WWW::SwaggerClient::Object::BaseObject";
# #
my $swagger_types = { my $swagger_types = {
'id' => 'Math::BigInt', 'id' => 'int',
'username' => 'string', 'username' => 'string',
'first_name' => 'string', 'first_name' => 'string',
'last_name' => 'string', 'last_name' => 'string',

View File

@ -279,7 +279,7 @@ sub new {
# #
# Find pet by ID # Find pet by ID
# #
# @param Math::BigInt $pet_id ID of pet that needs to be fetched (required) # @param int $pet_id ID of pet that needs to be fetched (required)
# @return Pet # @return Pet
# #
sub get_pet_by_id { sub get_pet_by_id {
@ -411,7 +411,7 @@ sub new {
# Deletes a pet # Deletes a pet
# #
# @param string $api_key (required) # @param string $api_key (required)
# @param Math::BigInt $pet_id Pet id to delete (required) # @param int $pet_id Pet id to delete (required)
# @return void # @return void
# #
sub delete_pet { sub delete_pet {
@ -472,7 +472,7 @@ sub new {
# #
# uploads an image # uploads an image
# #
# @param Math::BigInt $pet_id ID of pet to update (required) # @param int $pet_id ID of pet to update (required)
# @param string $additional_metadata Additional data to pass to server (required) # @param string $additional_metadata Additional data to pass to server (required)
# @param file $file file to upload (required) # @param file $file file to upload (required)
# @return void # @return void

View File

@ -15,7 +15,7 @@ use DateTime;
my $api = WWW::SwaggerClient::PetApi->new(); my $api = WWW::SwaggerClient::PetApi->new();
my $pet_id = 88; my $pet_id = 10008;
my $category = WWW::SwaggerClient::Object::Category->new('id' => '2', 'name' => 'perl'); my $category = WWW::SwaggerClient::Object::Category->new('id' => '2', 'name' => 'perl');
my $tag = WWW::SwaggerClient::Object::Tag->new('id' => '1', 'name' => 'just kidding'); my $tag = WWW::SwaggerClient::Object::Tag->new('id' => '1', 'name' => 'just kidding');
@ -30,7 +30,7 @@ $new_pet = $new_pet->from_hash($pet->to_hash);
print "new_pet(hash):".Dumper($new_pet->to_hash); print "new_pet(hash):".Dumper($new_pet->to_hash);
print "\nTest Petstore endpoints\n"; print "\nTest Petstore endpoints\n";
print "\nupload_file:".Dumper $api->upload_file(pet_id => $pet_id, additional_metadata => 'testabc', file => '/var/tmp/f5.jpg'); print "\nupload_file:".Dumper $api->upload_file(pet_id => $pet_id, additional_metadata => 'testabc', file => './test.pl');
print "\nadd_pet:".Dumper $api->add_pet(body => $pet); print "\nadd_pet:".Dumper $api->add_pet(body => $pet);
print "\nget_pet_by_id:".Dumper $api->get_pet_by_id(pet_id => $pet_id); print "\nget_pet_by_id:".Dumper $api->get_pet_by_id(pet_id => $pet_id);
print "\nupdate_pet_with_form:".Dumper $api->update_pet_with_form(pet_id => $pet_id, name => 'test_name', status => 'test status'); print "\nupdate_pet_with_form:".Dumper $api->update_pet_with_form(pet_id => $pet_id, name => 'test_name', status => 'test status');