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 421c72f80d6..0a9733ed94e 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 @@ -14,6 +14,7 @@ import io.swagger.models.properties.Property; import java.io.File; import java.util.Arrays; import java.util.HashSet; +import java.util.regex.Matcher; import org.apache.commons.lang.StringUtils; @@ -21,7 +22,7 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig { public static final String MODULE_NAME = "moduleName"; public static final String MODULE_VERSION = "moduleVersion"; protected String moduleName = "WWW::SwaggerClient"; - protected String modulePathPart = moduleName.replaceAll("::",String.valueOf(File.separatorChar)); + protected String modulePathPart = moduleName.replaceAll("::", Matcher.quoteReplacement(File.separator)); protected String moduleVersion = "1.0.0"; public PerlClientCodegen() { diff --git a/samples/client/petstore/perl/README.md b/samples/client/petstore/perl/README.md index 576fadf5900..164ece7a326 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-04T20:36:07.450-08:00 +- Build date: 2016-01-15T15:46:17.239+08:00 - Build package: class io.swagger.codegen.languages.PerlClientCodegen - Codegen version: @@ -162,7 +162,7 @@ you could also call them on class names. See the homepage `https://github.com/swagger-api/swagger-codegen` for full details. But briefly, clone the git repository, build the codegen codebase, set up your build -config file, then run the API build script. You will need git, Java 7 and Apache +config file, then run the API build script. You will need git, Java 7 or 8 and Apache maven 3.0.3 or better already installed. The config file should specify the project name for the generated library: diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/ApiClient.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/ApiClient.pm index cf596a9918d..fb3ffe6a2e2 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/ApiClient.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/ApiClient.pm @@ -319,12 +319,6 @@ sub update_params_for_auth { if (!defined($auth)) { # TODO show warning about auth setting not defined } - elsif ($auth eq 'petstore_auth') { - - if ($WWW::SwaggerClient::Configuration::access_token) { - $header_params->{'Authorization'} = 'Bearer ' . $WWW::SwaggerClient::Configuration::access_token; - } - } elsif ($auth eq 'api_key') { my $api_key = $self->get_api_key_with_prefix('api_key'); @@ -332,6 +326,12 @@ sub update_params_for_auth { $header_params->{'api_key'} = $api_key; } } + elsif ($auth eq 'petstore_auth') { + + if ($WWW::SwaggerClient::Configuration::access_token) { + $header_params->{'Authorization'} = 'Bearer ' . $WWW::SwaggerClient::Configuration::access_token; + } + } else { # TODO show warning about security definition not found diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/PetApi.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/PetApi.pm index e6182c4e952..5caa831de85 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/PetApi.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/PetApi.pm @@ -662,5 +662,145 @@ sub upload_file { } +# +# get_pet_by_id_with_byte_array +# +# Fake endpoint to test byte array return by 'Find pet by ID' +# +# @param int $pet_id ID of pet that needs to be fetched (required) +{ + my $params = { + 'pet_id' => { + data_type => 'int', + description => 'ID of pet that needs to be fetched', + required => '1', + }, + }; + __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', + }; +} +# @return binary +# +sub get_pet_by_id_with_byte_array { + my ($self, %args) = @_; + + + # verify the required parameter 'pet_id' is set + unless (exists $args{'pet_id'}) { + croak("Missing the required parameter 'pet_id' when calling get_pet_by_id_with_byte_array"); + } + + + # parse inputs + my $_resource_path = '/pet/{petId}?testing_byte_array=true'; + $_resource_path =~ s/{format}/json/; # default format to json + + my $_method = 'GET'; + my $query_params = {}; + my $header_params = {}; + my $form_params = {}; + + # 'Accept' and 'Content-Type' header + my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml'); + if ($_header_accept) { + $header_params->{'Accept'} = $_header_accept; + } + $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type(); + + + + # path params + if ( exists $args{'pet_id'}) { + my $_base_variable = "{" . "petId" . "}"; + my $_base_value = $self->{api_client}->to_path_value($args{'pet_id'}); + $_resource_path =~ s/$_base_variable/$_base_value/g; + } + + my $_body_data; + + + # authentication setting, if any + my $auth_settings = [qw(api_key )]; + + # make the API Call + my $response = $self->{api_client}->call_api($_resource_path, $_method, + $query_params, $form_params, + $header_params, $_body_data, $auth_settings); + if (!$response) { + return; + } + my $_response_object = $self->{api_client}->deserialize('binary', $response); + return $_response_object; + +} + +# +# add_pet_using_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) +{ + my $params = { + 'body' => { + data_type => 'binary', + description => 'Pet object in the form of byte array', + required => '0', + }, + }; + __PACKAGE__->method_documentation->{ add_pet_using_byte_array } = { + summary => 'Fake endpoint to test byte array in body parameter for adding a new pet to the store', + params => $params, + returns => undef, + }; +} +# @return void +# +sub add_pet_using_byte_array { + my ($self, %args) = @_; + + + + # parse inputs + my $_resource_path = '/pet?testing_byte_array=true'; + $_resource_path =~ s/{format}/json/; # default format to json + + my $_method = 'POST'; + my $query_params = {}; + my $header_params = {}; + my $form_params = {}; + + # 'Accept' and 'Content-Type' header + my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml'); + if ($_header_accept) { + $header_params->{'Accept'} = $_header_accept; + } + $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/json', 'application/xml'); + + + + + + my $_body_data; + # body params + if ( exists $args{'body'}) { + $_body_data = $args{'body'}; + } + + # authentication setting, if any + my $auth_settings = [qw(petstore_auth )]; + + # make the API Call + + $self->{api_client}->call_api($_resource_path, $_method, + $query_params, $form_params, + $header_params, $_body_data, $auth_settings); + return; + +} + 1; diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Role.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Role.pm index 8ad294d399d..dfe63f817fa 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-04T20:36:07.450-08:00', + generated_date => '2016-01-15T15:46:17.239+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-04T20:36:07.450-08:00 +=item Build date: 2016-01-15T15:46:17.239+08:00 =item Build package: class io.swagger.codegen.languages.PerlClientCodegen @@ -264,7 +264,7 @@ you could also call them on class names. See the homepage C for full details. But briefly, clone the git repository, build the codegen codebase, set up your build -config file, then run the API build script. You will need git, Java 7 and Apache +config file, then run the API build script. You will need git, Java 7 or 8 and Apache maven 3.0.3 or better already installed. The config file should specify the project name for the generated library: