support object response

This commit is contained in:
wing328 2015-06-04 21:12:26 +08:00
parent afe816efb6
commit 0423e0a2df
3 changed files with 6 additions and 4 deletions

View File

@ -27,8 +27,8 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig {
public PerlClientCodegen() { public PerlClientCodegen() {
super(); super();
modelPackage = "/Object"; modelPackage = File.separatorChar + "Object";
outputFolder = "generated-code/perl"; outputFolder = "generated-code" + File.separatorChar + "perl";
modelTemplateFiles.put("object.mustache", ".pm"); modelTemplateFiles.put("object.mustache", ".pm");
apiTemplateFiles.put("api.mustache", ".pm"); apiTemplateFiles.put("api.mustache", ".pm");
templateDir = "perl"; templateDir = "perl";
@ -63,6 +63,7 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig {
languageSpecificPrimitives.add("DateTime"); languageSpecificPrimitives.add("DateTime");
languageSpecificPrimitives.add("ARRAY"); languageSpecificPrimitives.add("ARRAY");
languageSpecificPrimitives.add("HASH"); languageSpecificPrimitives.add("HASH");
languageSpecificPrimitives.add("object");
typeMapping.put("integer", "int"); typeMapping.put("integer", "int");
typeMapping.put("long", "int"); typeMapping.put("long", "int");
@ -75,6 +76,7 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig {
typeMapping.put("password", "string"); typeMapping.put("password", "string");
typeMapping.put("array", "ARRAY"); typeMapping.put("array", "ARRAY");
typeMapping.put("map", "HASH"); typeMapping.put("map", "HASH");
typeMapping.put("object", "object");
supportingFiles.add(new SupportingFile("ApiClient.mustache", ("lib/WWW/" + invokerPackage).replace('/', File.separatorChar), "ApiClient.pm")); supportingFiles.add(new SupportingFile("ApiClient.mustache", ("lib/WWW/" + invokerPackage).replace('/', File.separatorChar), "ApiClient.pm"));
supportingFiles.add(new SupportingFile("Configuration.mustache", ("lib/WWW/" + invokerPackage).replace('/', File.separatorChar), "Configuration.pm")); supportingFiles.add(new SupportingFile("Configuration.mustache", ("lib/WWW/" + invokerPackage).replace('/', File.separatorChar), "Configuration.pm"));

View File

@ -216,7 +216,7 @@ sub deserialize
$_result = \@_values; $_result = \@_values;
} elsif ($class eq 'DateTime') { } elsif ($class eq 'DateTime') {
$_result = DateTime->from_epoch(epoch => str2time($data)); $_result = DateTime->from_epoch(epoch => str2time($data));
} elsif (grep /^$data$/, ('string', 'int', 'float', 'bool')) { #TODO revise the primitive type } elsif (grep /^$class$/, ('string', 'int', 'float', 'bool', 'object')) { #TODO revise the primitive type
$_result= $data; $_result= $data;
} else { # model } else { # model
my $_instance = use_module("WWW::{{invokerPackage}}::Object::$class")->new; my $_instance = use_module("WWW::{{invokerPackage}}::Object::$class")->new;

View File

@ -216,7 +216,7 @@ sub deserialize
$_result = \@_values; $_result = \@_values;
} elsif ($class eq 'DateTime') { } elsif ($class eq 'DateTime') {
$_result = DateTime->from_epoch(epoch => str2time($data)); $_result = DateTime->from_epoch(epoch => str2time($data));
} elsif (grep /^$data$/, ('string', 'int', 'float', 'bool')) { #TODO revise the primitive type } elsif (grep /^$class$/, ('string', 'int', 'float', 'bool', 'object')) { #TODO revise the primitive type
$_result= $data; $_result= $data;
} else { # model } else { # model
my $_instance = use_module("WWW::SwaggerClient::Object::$class")->new; my $_instance = use_module("WWW::SwaggerClient::Object::$class")->new;