diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PerlClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PerlClientCodegen.java
index 4948d3cf7f8..edb54828468 100644
--- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PerlClientCodegen.java
+++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PerlClientCodegen.java
@@ -30,6 +30,8 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig {
outputFolder = "generated-code" + File.separatorChar + "perl";
modelTemplateFiles.put("object.mustache", ".pm");
apiTemplateFiles.put("api.mustache", ".pm");
+ modelTestTemplateFiles.put("object_test.mustache", ".t");
+ apiTestTemplateFiles.put("api_test.mustache", ".t");
embeddedTemplateDir = templateDir = "perl";
@@ -142,6 +144,17 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig {
return (outputFolder + "/lib/" + modulePathPart + modelPackage()).replace('/', File.separatorChar);
}
+
+ @Override
+ public String apiTestFileFolder() {
+ return (outputFolder + "/t").replace('/', File.separatorChar);
+ }
+
+ @Override
+ public String modelTestFileFolder() {
+ return (outputFolder + "/t").replace('/', File.separatorChar);
+ }
+
@Override
public String getTypeDeclaration(Property p) {
if (p instanceof ArrayProperty) {
@@ -218,6 +231,16 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig {
return toModelName(name);
}
+ @Override
+ public String toModelTestFilename(String name) {
+ return toModelFilename(name) + "Test";
+ }
+
+ @Override
+ public String toApiTestFilename(String name) {
+ return toApiFilename(name) + "Test";
+ }
+
@Override
public String toApiFilename(String name) {
// replace - with _ e.g. created-at => created_at
diff --git a/modules/swagger-codegen/src/main/resources/perl/api_test.mustache b/modules/swagger-codegen/src/main/resources/perl/api_test.mustache
new file mode 100644
index 00000000000..2bab3f8aa86
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/perl/api_test.mustache
@@ -0,0 +1,46 @@
+#
+# Copyright 2016 SmartBear Software
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+# NOTE: This class is auto generated by the swagger code generator program.
+# Do not edit the class manually.
+#
+use Test::More tests => 1; #TODO update number of test cases
+use Test::Exception;
+
+use lib 'lib';
+use strict;
+use warnings;
+
+use_ok('{{moduleName}}::{{classname}}');
+
+my $api = {{moduleName}}::{{classname}}->new();
+isa_ok($api, '{{moduleName}}::{{classname}}');
+
+{{#operations}}
+{{#operation}}
+#
+# {{{nickname}}} test
+#
+{
+{{#allParams}} my ${{paramName}} = undef; # replace NULL with a proper value
+{{/allParams}}
+ my $result = $api->{{nickname}}({{#allParams}}{{paramName}} => ${{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
+}
+
+{{/operation}}
+{{/operations}}
+
+1;
diff --git a/modules/swagger-codegen/src/main/resources/perl/object_test.mustache b/modules/swagger-codegen/src/main/resources/perl/object_test.mustache
new file mode 100644
index 00000000000..acefaf569d6
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/perl/object_test.mustache
@@ -0,0 +1,18 @@
+use Test::More tests => 2;
+use Test::Exception;
+
+use lib 'lib';
+use strict;
+use warnings;
+
+{{#models}}
+{{#model}}
+
+use_ok('{{moduleName}}::Object::{{classname}}');
+
+my $instance = {{moduleName}}::Object::{{classname}}->new();
+
+isa_ok($instance, '{{moduleName}}::Object::{{classname}}');
+
+{{/model}}
+{{/models}}
diff --git a/samples/client/petstore/perl/README.md b/samples/client/petstore/perl/README.md
index e2685dd2468..d0e4d50476e 100644
--- a/samples/client/petstore/perl/README.md
+++ b/samples/client/petstore/perl/README.md
@@ -8,7 +8,7 @@ WWW::SwaggerClient::Role - a Moose role for the Swagger Petstore
Automatically generated by the Perl Swagger Codegen project:
-- Build date: 2016-01-17T19:21:19.346+08:00
+- Build date: 2016-02-11T08:22:52.982+08:00
- Build package: class io.swagger.codegen.languages.PerlClientCodegen
- Codegen version:
diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/PetApi.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/PetApi.pm
index 5caa831de85..47dd6b1acc9 100644
--- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/PetApi.pm
+++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/PetApi.pm
@@ -679,10 +679,10 @@ sub upload_file {
__PACKAGE__->method_documentation->{ get_pet_by_id_with_byte_array } = {
summary => 'Fake endpoint to test byte array return by 'Find pet by ID'',
params => $params,
- returns => 'binary',
+ returns => 'string',
};
}
-# @return binary
+# @return string
#
sub get_pet_by_id_with_byte_array {
my ($self, %args) = @_;
@@ -732,7 +732,7 @@ sub get_pet_by_id_with_byte_array {
if (!$response) {
return;
}
- my $_response_object = $self->{api_client}->deserialize('binary', $response);
+ my $_response_object = $self->{api_client}->deserialize('string', $response);
return $_response_object;
}
@@ -742,11 +742,11 @@ sub get_pet_by_id_with_byte_array {
#
# Fake endpoint to test byte array in body parameter for adding a new pet to the store
#
-# @param binary $body Pet object in the form of byte array (optional)
+# @param string $body Pet object in the form of byte array (optional)
{
my $params = {
'body' => {
- data_type => 'binary',
+ data_type => 'string',
description => 'Pet object in the form of byte array',
required => '0',
},
diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Role.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Role.pm
index cc1e39c6657..98484b46c6e 100644
--- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Role.pm
+++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Role.pm
@@ -37,7 +37,7 @@ has version_info => ( is => 'ro',
default => sub { {
app_name => 'Swagger Petstore',
app_version => '1.0.0',
- generated_date => '2016-01-17T19:21:19.346+08:00',
+ generated_date => '2016-02-11T08:22:52.982+08:00',
generator_class => 'class io.swagger.codegen.languages.PerlClientCodegen',
} },
documentation => 'Information about the application version and the codegen codebase version'
@@ -103,7 +103,7 @@ Automatically generated by the Perl Swagger Codegen project:
=over 4
-=item Build date: 2016-01-17T19:21:19.346+08:00
+=item Build date: 2016-02-11T08:22:52.982+08:00
=item Build package: class io.swagger.codegen.languages.PerlClientCodegen
diff --git a/samples/client/petstore/perl/pom.xml b/samples/client/petstore/perl/pom.xml
index 4aa0040f82e..d761d022cd6 100644
--- a/samples/client/petstore/perl/pom.xml
+++ b/samples/client/petstore/perl/pom.xml
@@ -35,7 +35,7 @@
perl
- t/01_pet_api.t
+ tests/01_pet_api.t
@@ -48,7 +48,7 @@
perl
- t/02_store_api.t
+ tests/02_store_api.t
@@ -61,7 +61,7 @@
perl
- t/03_api_factory.t
+ tests/03_api_factory.t
@@ -74,7 +74,7 @@
perl
- t/04_role.t
+ tests/04_role.t
diff --git a/samples/client/petstore/perl/t/CategoryTest.t b/samples/client/petstore/perl/t/CategoryTest.t
new file mode 100644
index 00000000000..93534938102
--- /dev/null
+++ b/samples/client/petstore/perl/t/CategoryTest.t
@@ -0,0 +1,14 @@
+use Test::More tests => 2;
+use Test::Exception;
+
+use lib 'lib';
+use strict;
+use warnings;
+
+
+use_ok('WWW::SwaggerClient::Object::Category');
+
+my $instance = WWW::SwaggerClient::Object::Category->new();
+
+isa_ok($instance, 'WWW::SwaggerClient::Object::Category');
+
diff --git a/samples/client/petstore/perl/t/OrderTest.t b/samples/client/petstore/perl/t/OrderTest.t
new file mode 100644
index 00000000000..5ec9b3d9802
--- /dev/null
+++ b/samples/client/petstore/perl/t/OrderTest.t
@@ -0,0 +1,14 @@
+use Test::More tests => 2;
+use Test::Exception;
+
+use lib 'lib';
+use strict;
+use warnings;
+
+
+use_ok('WWW::SwaggerClient::Object::Order');
+
+my $instance = WWW::SwaggerClient::Object::Order->new();
+
+isa_ok($instance, 'WWW::SwaggerClient::Object::Order');
+
diff --git a/samples/client/petstore/perl/t/PetApiTest.t b/samples/client/petstore/perl/t/PetApiTest.t
new file mode 100644
index 00000000000..5bc2a6fbab8
--- /dev/null
+++ b/samples/client/petstore/perl/t/PetApiTest.t
@@ -0,0 +1,118 @@
+#
+# Copyright 2016 SmartBear Software
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+# NOTE: This class is auto generated by the swagger code generator program.
+# Do not edit the class manually.
+#
+use Test::More tests => 1; #TODO update number of test cases
+use Test::Exception;
+
+use lib 'lib';
+use strict;
+use warnings;
+
+use_ok('WWW::SwaggerClient::PetApi');
+
+my $api = WWW::SwaggerClient::PetApi->new();
+isa_ok($api, 'WWW::SwaggerClient::PetApi');
+
+#
+# update_pet test
+#
+{
+ my $body = undef; # replace NULL with a proper value
+ my $result = $api->update_pet(body => $body);
+}
+
+#
+# add_pet test
+#
+{
+ my $body = undef; # replace NULL with a proper value
+ my $result = $api->add_pet(body => $body);
+}
+
+#
+# find_pets_by_status test
+#
+{
+ my $status = undef; # replace NULL with a proper value
+ my $result = $api->find_pets_by_status(status => $status);
+}
+
+#
+# find_pets_by_tags test
+#
+{
+ my $tags = undef; # replace NULL with a proper value
+ my $result = $api->find_pets_by_tags(tags => $tags);
+}
+
+#
+# get_pet_by_id test
+#
+{
+ my $pet_id = undef; # replace NULL with a proper value
+ my $result = $api->get_pet_by_id(pet_id => $pet_id);
+}
+
+#
+# update_pet_with_form test
+#
+{
+ my $pet_id = undef; # replace NULL with a proper value
+ my $name = undef; # replace NULL with a proper value
+ my $status = undef; # replace NULL with a proper value
+ my $result = $api->update_pet_with_form(pet_id => $pet_id, name => $name, status => $status);
+}
+
+#
+# delete_pet test
+#
+{
+ my $pet_id = undef; # replace NULL with a proper value
+ my $api_key = undef; # replace NULL with a proper value
+ my $result = $api->delete_pet(pet_id => $pet_id, api_key => $api_key);
+}
+
+#
+# upload_file test
+#
+{
+ my $pet_id = undef; # replace NULL with a proper value
+ my $additional_metadata = undef; # replace NULL with a proper value
+ my $file = undef; # replace NULL with a proper value
+ my $result = $api->upload_file(pet_id => $pet_id, additional_metadata => $additional_metadata, file => $file);
+}
+
+#
+# get_pet_by_id_with_byte_array test
+#
+{
+ my $pet_id = undef; # replace NULL with a proper value
+ my $result = $api->get_pet_by_id_with_byte_array(pet_id => $pet_id);
+}
+
+#
+# add_pet_using_byte_array test
+#
+{
+ my $body = undef; # replace NULL with a proper value
+ my $result = $api->add_pet_using_byte_array(body => $body);
+}
+
+
+1;
diff --git a/samples/client/petstore/perl/t/PetTest.t b/samples/client/petstore/perl/t/PetTest.t
new file mode 100644
index 00000000000..bae56462a36
--- /dev/null
+++ b/samples/client/petstore/perl/t/PetTest.t
@@ -0,0 +1,14 @@
+use Test::More tests => 2;
+use Test::Exception;
+
+use lib 'lib';
+use strict;
+use warnings;
+
+
+use_ok('WWW::SwaggerClient::Object::Pet');
+
+my $instance = WWW::SwaggerClient::Object::Pet->new();
+
+isa_ok($instance, 'WWW::SwaggerClient::Object::Pet');
+
diff --git a/samples/client/petstore/perl/t/StoreApiTest.t b/samples/client/petstore/perl/t/StoreApiTest.t
new file mode 100644
index 00000000000..fa41c8e7a87
--- /dev/null
+++ b/samples/client/petstore/perl/t/StoreApiTest.t
@@ -0,0 +1,64 @@
+#
+# Copyright 2016 SmartBear Software
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+# NOTE: This class is auto generated by the swagger code generator program.
+# Do not edit the class manually.
+#
+use Test::More tests => 1; #TODO update number of test cases
+use Test::Exception;
+
+use lib 'lib';
+use strict;
+use warnings;
+
+use_ok('WWW::SwaggerClient::StoreApi');
+
+my $api = WWW::SwaggerClient::StoreApi->new();
+isa_ok($api, 'WWW::SwaggerClient::StoreApi');
+
+#
+# get_inventory test
+#
+{
+ my $result = $api->get_inventory();
+}
+
+#
+# place_order test
+#
+{
+ my $body = undef; # replace NULL with a proper value
+ my $result = $api->place_order(body => $body);
+}
+
+#
+# get_order_by_id test
+#
+{
+ my $order_id = undef; # replace NULL with a proper value
+ my $result = $api->get_order_by_id(order_id => $order_id);
+}
+
+#
+# delete_order test
+#
+{
+ my $order_id = undef; # replace NULL with a proper value
+ my $result = $api->delete_order(order_id => $order_id);
+}
+
+
+1;
diff --git a/samples/client/petstore/perl/t/TagTest.t b/samples/client/petstore/perl/t/TagTest.t
new file mode 100644
index 00000000000..49a44e4e843
--- /dev/null
+++ b/samples/client/petstore/perl/t/TagTest.t
@@ -0,0 +1,14 @@
+use Test::More tests => 2;
+use Test::Exception;
+
+use lib 'lib';
+use strict;
+use warnings;
+
+
+use_ok('WWW::SwaggerClient::Object::Tag');
+
+my $instance = WWW::SwaggerClient::Object::Tag->new();
+
+isa_ok($instance, 'WWW::SwaggerClient::Object::Tag');
+
diff --git a/samples/client/petstore/perl/t/UserApiTest.t b/samples/client/petstore/perl/t/UserApiTest.t
new file mode 100644
index 00000000000..97294919612
--- /dev/null
+++ b/samples/client/petstore/perl/t/UserApiTest.t
@@ -0,0 +1,98 @@
+#
+# Copyright 2016 SmartBear Software
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+# NOTE: This class is auto generated by the swagger code generator program.
+# Do not edit the class manually.
+#
+use Test::More tests => 1; #TODO update number of test cases
+use Test::Exception;
+
+use lib 'lib';
+use strict;
+use warnings;
+
+use_ok('WWW::SwaggerClient::UserApi');
+
+my $api = WWW::SwaggerClient::UserApi->new();
+isa_ok($api, 'WWW::SwaggerClient::UserApi');
+
+#
+# create_user test
+#
+{
+ my $body = undef; # replace NULL with a proper value
+ my $result = $api->create_user(body => $body);
+}
+
+#
+# create_users_with_array_input test
+#
+{
+ my $body = undef; # replace NULL with a proper value
+ my $result = $api->create_users_with_array_input(body => $body);
+}
+
+#
+# create_users_with_list_input test
+#
+{
+ my $body = undef; # replace NULL with a proper value
+ my $result = $api->create_users_with_list_input(body => $body);
+}
+
+#
+# login_user test
+#
+{
+ my $username = undef; # replace NULL with a proper value
+ my $password = undef; # replace NULL with a proper value
+ my $result = $api->login_user(username => $username, password => $password);
+}
+
+#
+# logout_user test
+#
+{
+ my $result = $api->logout_user();
+}
+
+#
+# get_user_by_name test
+#
+{
+ my $username = undef; # replace NULL with a proper value
+ my $result = $api->get_user_by_name(username => $username);
+}
+
+#
+# update_user test
+#
+{
+ my $username = undef; # replace NULL with a proper value
+ my $body = undef; # replace NULL with a proper value
+ my $result = $api->update_user(username => $username, body => $body);
+}
+
+#
+# delete_user test
+#
+{
+ my $username = undef; # replace NULL with a proper value
+ my $result = $api->delete_user(username => $username);
+}
+
+
+1;
diff --git a/samples/client/petstore/perl/t/UserTest.t b/samples/client/petstore/perl/t/UserTest.t
new file mode 100644
index 00000000000..edf1d66777b
--- /dev/null
+++ b/samples/client/petstore/perl/t/UserTest.t
@@ -0,0 +1,14 @@
+use Test::More tests => 2;
+use Test::Exception;
+
+use lib 'lib';
+use strict;
+use warnings;
+
+
+use_ok('WWW::SwaggerClient::Object::User');
+
+my $instance = WWW::SwaggerClient::Object::User->new();
+
+isa_ok($instance, 'WWW::SwaggerClient::Object::User');
+
diff --git a/samples/client/petstore/perl/t/01_pet_api.t b/samples/client/petstore/perl/tests/01_pet_api.t
similarity index 100%
rename from samples/client/petstore/perl/t/01_pet_api.t
rename to samples/client/petstore/perl/tests/01_pet_api.t
diff --git a/samples/client/petstore/perl/t/02_store_api.t b/samples/client/petstore/perl/tests/02_store_api.t
similarity index 100%
rename from samples/client/petstore/perl/t/02_store_api.t
rename to samples/client/petstore/perl/tests/02_store_api.t
diff --git a/samples/client/petstore/perl/t/03_api_factory.t b/samples/client/petstore/perl/tests/03_api_factory.t
similarity index 100%
rename from samples/client/petstore/perl/t/03_api_factory.t
rename to samples/client/petstore/perl/tests/03_api_factory.t
diff --git a/samples/client/petstore/perl/t/04_role.t b/samples/client/petstore/perl/tests/04_role.t
similarity index 100%
rename from samples/client/petstore/perl/t/04_role.t
rename to samples/client/petstore/perl/tests/04_role.t
diff --git a/samples/client/petstore/perl/t/05_long_module_name.t b/samples/client/petstore/perl/tests/05_long_module_name.t
similarity index 100%
rename from samples/client/petstore/perl/t/05_long_module_name.t
rename to samples/client/petstore/perl/tests/05_long_module_name.t