update type list in deserialize

This commit is contained in:
William Cheng 2015-05-07 22:41:50 +08:00
parent 1d4735f76d
commit 063a1ffd36
12 changed files with 49 additions and 33 deletions

View File

@ -38,7 +38,17 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig {
reservedWords = new HashSet<String> (
Arrays.asList(
"__halt_compiler", "abstract", "and", "array", "as", "break", "callable", "case", "catch", "class", "clone", "const", "continue", "declare", "default", "die", "do", "echo", "else", "elseif", "empty", "enddeclare", "endfor", "endforeach", "endif", "endswitch", "endwhile", "eval", "exit", "extends", "final", "for", "foreach", "function", "global", "goto", "if", "implements", "include", "include_once", "instanceof", "insteadof", "interface", "isset", "list", "namespace", "new", "or", "print", "private", "protected", "public", "require", "require_once", "return", "static", "switch", "throw", "trait", "try", "unset", "use", "var", "while", "xor")
"else", "lock", "qw",
"__END__", "elsif", "lt", "qx",
"__FILE__", "eq", "m", "s",
"__LINE__", "exp", "ne", "sub",
"__PACKAGE__", "for", "no", "tr",
"and", "foreach", "or", "unless",
"cmp", "ge", "package", "until",
"continue", "gt", "q", "while",
"CORE", "if", "qq", "xor",
"do", "le", "qr", "y"
)
);
additionalProperties.put("invokerPackage", invokerPackage);
@ -47,17 +57,25 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig {
additionalProperties.put("artifactVersion", artifactVersion);
languageSpecificPrimitives.add("int");
languageSpecificPrimitives.add("array");
languageSpecificPrimitives.add("map");
languageSpecificPrimitives.add("Math::BigInt");
languageSpecificPrimitives.add("double");
languageSpecificPrimitives.add("string");
languageSpecificPrimitives.add("boolean");
languageSpecificPrimitives.add("DateTime");
languageSpecificPrimitives.add("ARRAY");
languageSpecificPrimitives.add("HASH");
typeMapping.put("long", "int");
typeMapping.put("integer", "int");
typeMapping.put("Array", "array");
typeMapping.put("String", "string");
typeMapping.put("List", "array");
typeMapping.put("map", "map");
typeMapping.put("long", "Math::BigInt");
typeMapping.put("float", "double");
typeMapping.put("double", "double");
typeMapping.put("boolean", "boolean");
typeMapping.put("string", "string");
typeMapping.put("date", "DateTime");
typeMapping.put("dateTime", "DateTime");
typeMapping.put("password", "string");
typeMapping.put("array", "ARRAY");
typeMapping.put("map", "HASH");
supportingFiles.add(new SupportingFile("APIClient.mustache", "lib/WWW/" + invokerPackage, "APIClient.pm"));
supportingFiles.add(new SupportingFile("BaseObject.mustache", "lib/WWW/" + invokerPackage, "Object/BaseObject.pm"));

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -171,8 +171,8 @@ sub new {
#
# Finds Pets by status
#
# @param array[string] $status Status values that need to be considered for filter (required)
# @return array[Pet]
# @param ARRAY[string] $status Status values that need to be considered for filter (required)
# @return ARRAY[Pet]
#
sub find_pets_by_status {
my ($self, %args) = @_;
@ -215,7 +215,7 @@ sub new {
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('array[Pet]', $response);
my $_response_object = $self->{api_client}->deserialize('ARRAY[Pet]', $response);
return $_response_object;
}
@ -225,8 +225,8 @@ sub new {
#
# Finds Pets by tags
#
# @param array[string] $tags Tags to filter by (required)
# @return array[Pet]
# @param ARRAY[string] $tags Tags to filter by (required)
# @return ARRAY[Pet]
#
sub find_pets_by_tags {
my ($self, %args) = @_;
@ -269,7 +269,7 @@ sub new {
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('array[Pet]', $response);
my $_response_object = $self->{api_client}->deserialize('ARRAY[Pet]', $response);
return $_response_object;
}
@ -279,7 +279,7 @@ sub new {
#
# Find pet by ID
#
# @param int $pet_id ID of pet that needs to be fetched (required)
# @param Math::BigInt $pet_id ID of pet that needs to be fetched (required)
# @return Pet
#
sub get_pet_by_id {
@ -411,7 +411,7 @@ sub new {
# Deletes a pet
#
# @param string $api_key (required)
# @param int $pet_id Pet id to delete (required)
# @param Math::BigInt $pet_id Pet id to delete (required)
# @return void
#
sub delete_pet {
@ -472,7 +472,7 @@ sub new {
#
# uploads an image
#
# @param int $pet_id ID of pet to update (required)
# @param Math::BigInt $pet_id ID of pet to update (required)
# @param string $additional_metadata Additional data to pass to server (required)
# @param file $file file to upload (required)
# @return void

View File

@ -65,7 +65,7 @@ sub new {
#
# Returns pet inventories by status
#
# @return map[string,int]
# @return HASH[string,int]
#
sub get_inventory {
my ($self, %args) = @_;
@ -105,7 +105,7 @@ sub new {
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('map[string,int]', $response);
my $_response_object = $self->{api_client}->deserialize('HASH[string,int]', $response);
return $_response_object;
}

View File

@ -120,7 +120,7 @@ sub new {
#
# Creates list of users with given input array
#
# @param array[User] $body List of user object (required)
# @param ARRAY[User] $body List of user object (required)
# @return void
#
sub create_users_with_array_input {
@ -171,7 +171,7 @@ sub new {
#
# Creates list of users with given input array
#
# @param array[User] $body List of user object (required)
# @param ARRAY[User] $body List of user object (required)
# @return void
#
sub create_users_with_list_input {

View File

@ -37,5 +37,3 @@ print "\nupdate_pet_with_form:".Dumper $api->update_pet_with_form(pet_id => $pet
print "\ndelete_pet:".Dumper $api->delete_pet(pet_id => $pet_id);