forked from loafle/openapi-generator-original
automaticallay generate test cases for Perl
This commit is contained in:
parent
7b83664dd1
commit
3d9a331666
@ -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
|
||||
|
@ -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;
|
@ -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}}
|
@ -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:
|
||||
|
||||
|
@ -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',
|
||||
},
|
||||
|
@ -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
|
||||
|
||||
|
14
samples/client/petstore/perl/t/CategoryTest.t
Normal file
14
samples/client/petstore/perl/t/CategoryTest.t
Normal file
@ -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');
|
||||
|
14
samples/client/petstore/perl/t/OrderTest.t
Normal file
14
samples/client/petstore/perl/t/OrderTest.t
Normal file
@ -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');
|
||||
|
118
samples/client/petstore/perl/t/PetApiTest.t
Normal file
118
samples/client/petstore/perl/t/PetApiTest.t
Normal file
@ -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;
|
14
samples/client/petstore/perl/t/PetTest.t
Normal file
14
samples/client/petstore/perl/t/PetTest.t
Normal file
@ -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');
|
||||
|
64
samples/client/petstore/perl/t/StoreApiTest.t
Normal file
64
samples/client/petstore/perl/t/StoreApiTest.t
Normal file
@ -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;
|
14
samples/client/petstore/perl/t/TagTest.t
Normal file
14
samples/client/petstore/perl/t/TagTest.t
Normal file
@ -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');
|
||||
|
98
samples/client/petstore/perl/t/UserApiTest.t
Normal file
98
samples/client/petstore/perl/t/UserApiTest.t
Normal file
@ -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;
|
14
samples/client/petstore/perl/t/UserTest.t
Normal file
14
samples/client/petstore/perl/t/UserTest.t
Normal file
@ -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');
|
||||
|
Loading…
x
Reference in New Issue
Block a user