From 65d788396b7e92ae26766e29e10d01c79d44aee0 Mon Sep 17 00:00:00 2001 From: Larry Bordowitz Date: Mon, 18 Sep 2017 19:11:38 -0700 Subject: [PATCH] [6313] Add imports to perl objects. (#6500) --- .../src/main/resources/perl/object.mustache | 4 + .../petstore-security-test/perl/README.md | 24 +-- .../perl/deep_module_test/README.md | 24 +-- .../perl/deep_module_test/docs/FakeApi.md | 4 +- .../lib/Something/Deep/ApiClient.pm | 33 ++-- .../lib/Something/Deep/ApiFactory.pm | 27 ++-- .../lib/Something/Deep/Configuration.pm | 141 +++++++++++++----- .../lib/Something/Deep/FakeApi.pm | 19 +-- .../lib/Something/Deep/Object/ModelReturn.pm | 1 + .../lib/Something/Deep/Role.pm | 23 ++- .../perl/docs/FakeApi.md | 4 +- .../perl/lib/WWW/SwaggerClient/ApiClient.pm | 33 ++-- .../perl/lib/WWW/SwaggerClient/ApiFactory.pm | 27 ++-- .../lib/WWW/SwaggerClient/Configuration.pm | 141 +++++++++++++----- .../perl/lib/WWW/SwaggerClient/FakeApi.pm | 19 +-- .../WWW/SwaggerClient/Object/ModelReturn.pm | 1 + .../perl/lib/WWW/SwaggerClient/Role.pm | 23 ++- .../petstore/perl/.swagger-codegen/VERSION | 2 +- samples/client/petstore/perl/README.md | 10 ++ .../petstore/perl/docs/AnotherfakeApi.md | 60 ++++++++ samples/client/petstore/perl/docs/FakeApi.md | 50 ++++++- .../perl/docs/FakeClassnameTags123Api.md | 7 +- .../lib/WWW/SwaggerClient/AnotherfakeApi.pm | 116 ++++++++++++++ .../perl/lib/WWW/SwaggerClient/ApiClient.pm | 7 + .../perl/lib/WWW/SwaggerClient/FakeApi.pm | 77 ++++++++++ .../SwaggerClient/FakeClassnameTags123Api.pm | 2 +- .../Object/AdditionalPropertiesClass.pm | 1 + .../lib/WWW/SwaggerClient/Object/Animal.pm | 1 + .../WWW/SwaggerClient/Object/AnimalFarm.pm | 2 + .../WWW/SwaggerClient/Object/ApiResponse.pm | 1 + .../Object/ArrayOfArrayOfNumberOnly.pm | 2 + .../SwaggerClient/Object/ArrayOfNumberOnly.pm | 2 + .../lib/WWW/SwaggerClient/Object/ArrayTest.pm | 2 + .../SwaggerClient/Object/Capitalization.pm | 1 + .../perl/lib/WWW/SwaggerClient/Object/Cat.pm | 2 + .../lib/WWW/SwaggerClient/Object/Category.pm | 1 + .../WWW/SwaggerClient/Object/ClassModel.pm | 1 + .../lib/WWW/SwaggerClient/Object/Client.pm | 1 + .../perl/lib/WWW/SwaggerClient/Object/Dog.pm | 2 + .../WWW/SwaggerClient/Object/EnumArrays.pm | 1 + .../lib/WWW/SwaggerClient/Object/EnumClass.pm | 1 + .../lib/WWW/SwaggerClient/Object/EnumTest.pm | 2 + .../WWW/SwaggerClient/Object/FormatTest.pm | 3 + .../SwaggerClient/Object/HasOnlyReadOnly.pm | 1 + .../perl/lib/WWW/SwaggerClient/Object/List.pm | 1 + .../lib/WWW/SwaggerClient/Object/MapTest.pm | 1 + ...dPropertiesAndAdditionalPropertiesClass.pm | 3 + .../SwaggerClient/Object/Model200Response.pm | 1 + .../WWW/SwaggerClient/Object/ModelReturn.pm | 1 + .../perl/lib/WWW/SwaggerClient/Object/Name.pm | 1 + .../WWW/SwaggerClient/Object/NumberOnly.pm | 2 + .../lib/WWW/SwaggerClient/Object/Order.pm | 1 + .../WWW/SwaggerClient/Object/OuterBoolean.pm | 1 + .../SwaggerClient/Object/OuterComposite.pm | 4 + .../lib/WWW/SwaggerClient/Object/OuterEnum.pm | 1 + .../WWW/SwaggerClient/Object/OuterNumber.pm | 1 + .../WWW/SwaggerClient/Object/OuterString.pm | 1 + .../perl/lib/WWW/SwaggerClient/Object/Pet.pm | 3 + .../WWW/SwaggerClient/Object/ReadOnlyFirst.pm | 1 + .../SwaggerClient/Object/SpecialModelName.pm | 1 + .../perl/lib/WWW/SwaggerClient/Object/Tag.pm | 1 + .../perl/lib/WWW/SwaggerClient/Object/User.pm | 1 + .../petstore/perl/t/AnotherfakeApiTest.t | 41 +++++ 63 files changed, 777 insertions(+), 196 deletions(-) create mode 100644 samples/client/petstore/perl/docs/AnotherfakeApi.md create mode 100644 samples/client/petstore/perl/lib/WWW/SwaggerClient/AnotherfakeApi.pm create mode 100644 samples/client/petstore/perl/t/AnotherfakeApiTest.t diff --git a/modules/swagger-codegen/src/main/resources/perl/object.mustache b/modules/swagger-codegen/src/main/resources/perl/object.mustache index bb19479c61d..d5d8fdd8f40 100644 --- a/modules/swagger-codegen/src/main/resources/perl/object.mustache +++ b/modules/swagger-codegen/src/main/resources/perl/object.mustache @@ -19,6 +19,10 @@ use Log::Any qw($log); use Date::Parse; use DateTime; +{{#imports}} +use {{moduleName}}::Object::{{.}}; +{{/imports}} + use base ("Class::Accessor", "Class::Data::Inheritable"); diff --git a/samples/client/petstore-security-test/perl/README.md b/samples/client/petstore-security-test/perl/README.md index 18e4b925509..c60bcf8bc30 100644 --- a/samples/client/petstore-security-test/perl/README.md +++ b/samples/client/petstore-security-test/perl/README.md @@ -88,37 +88,37 @@ you are accessing. Usually `prefix` and `in` will be determined by the code gene the spec and you will not need to set them at run time. If not, `in` will default to 'head' and `prefix` to the empty string. -The tokens will be placed in the `WWW::SwaggerClient::Configuration` namespace +The tokens will be placed in a L instance as follows, but you don't need to know about this. -- `$WWW::SwaggerClient::Configuration::username` +- `$cfg->{username}` String. The username for basic auth. -- `$WWW::SwaggerClient::Configuration::password` +- `$cfg->{password}` String. The password for basic auth. -- `$WWW::SwaggerClient::Configuration::api_key` +- `$cfg->{api_key}` Hashref. Keyed on the name of each key (there can be multiple tokens). - $WWW::SwaggerClient::Configuration::api_key = { + $cfg->{api_key} = { secretKey => 'aaaabbbbccccdddd', anotherKey => '1111222233334444', }; -- `$WWW::SwaggerClient::Configuration::api_key_prefix` +- `$cfg->{api_key_prefix}` Hashref. Keyed on the name of each key (there can be multiple tokens). Note not all api keys require a prefix. - $WWW::SwaggerClient::Configuration::api_key_prefix = { + $cfg->{api_key_prefix} = { secretKey => 'string', anotherKey => 'same or some other string', }; -- `$WWW::SwaggerClient::Configuration::access_token` +- `$cfg->{access_token}` String. The OAuth access token. @@ -127,8 +127,7 @@ as follows, but you don't need to know about this. ## `base_url` The generated code has the `base_url` already set as a default value. This method -returns (and optionally sets, but only if the API client has not been -created yet) the current value of `base_url`. +returns the current value of `base_url`. ## `api_factory` @@ -247,10 +246,11 @@ use WWW::SwaggerClient::Object::ModelReturn; # for displaying the API response data use Data::Dumper; -use WWW::SwaggerClient::Configuration; use WWW::SwaggerClient::; -my $api_instance = WWW::SwaggerClient::FakeApi->new(); +my $api_instance = WWW::SwaggerClient::->new( +); + my $test code inject */ ' " =end __ \r\n \n \r = 'test code inject */ ' " =end __ \r\n \n \r_example'; # string | To test code injection */ ' \" =_end -- \\r\\n \\n \\r eval { diff --git a/samples/client/petstore-security-test/perl/deep_module_test/README.md b/samples/client/petstore-security-test/perl/deep_module_test/README.md index 148bc2cf017..dfbd75f4abc 100644 --- a/samples/client/petstore-security-test/perl/deep_module_test/README.md +++ b/samples/client/petstore-security-test/perl/deep_module_test/README.md @@ -88,37 +88,37 @@ you are accessing. Usually `prefix` and `in` will be determined by the code gene the spec and you will not need to set them at run time. If not, `in` will default to 'head' and `prefix` to the empty string. -The tokens will be placed in the `Something::Deep::Configuration` namespace +The tokens will be placed in a L instance as follows, but you don't need to know about this. -- `$Something::Deep::Configuration::username` +- `$cfg->{username}` String. The username for basic auth. -- `$Something::Deep::Configuration::password` +- `$cfg->{password}` String. The password for basic auth. -- `$Something::Deep::Configuration::api_key` +- `$cfg->{api_key}` Hashref. Keyed on the name of each key (there can be multiple tokens). - $Something::Deep::Configuration::api_key = { + $cfg->{api_key} = { secretKey => 'aaaabbbbccccdddd', anotherKey => '1111222233334444', }; -- `$Something::Deep::Configuration::api_key_prefix` +- `$cfg->{api_key_prefix}` Hashref. Keyed on the name of each key (there can be multiple tokens). Note not all api keys require a prefix. - $Something::Deep::Configuration::api_key_prefix = { + $cfg->{api_key_prefix} = { secretKey => 'string', anotherKey => 'same or some other string', }; -- `$Something::Deep::Configuration::access_token` +- `$cfg->{access_token}` String. The OAuth access token. @@ -127,8 +127,7 @@ as follows, but you don't need to know about this. ## `base_url` The generated code has the `base_url` already set as a default value. This method -returns (and optionally sets, but only if the API client has not been -created yet) the current value of `base_url`. +returns the current value of `base_url`. ## `api_factory` @@ -247,10 +246,11 @@ use Something::Deep::Object::ModelReturn; # for displaying the API response data use Data::Dumper; -use Something::Deep::Configuration; use Something::Deep::; -my $api_instance = Something::Deep::FakeApi->new(); +my $api_instance = Something::Deep::->new( +); + my $test code inject */ ' " =end __ \r\n \n \r = 'test code inject */ ' " =end __ \r\n \n \r_example'; # string | To test code injection */ ' \" =_end -- \\r\\n \\n \\r eval { diff --git a/samples/client/petstore-security-test/perl/deep_module_test/docs/FakeApi.md b/samples/client/petstore-security-test/perl/deep_module_test/docs/FakeApi.md index ec4678ea49c..35f56434164 100644 --- a/samples/client/petstore-security-test/perl/deep_module_test/docs/FakeApi.md +++ b/samples/client/petstore-security-test/perl/deep_module_test/docs/FakeApi.md @@ -20,10 +20,10 @@ To test code injection */ ' \" =_end -- \\r\\n \\n \\r ### Example ```perl use Data::Dumper; -use Something::Deep::Configuration; use Something::Deep::FakeApi; +my $api_instance = Something::Deep::FakeApi->new( +); -my $api_instance = Something::Deep::FakeApi->new(); my $test code inject */ ' " =end __ \r\n \n \r = 'test code inject */ ' " =end __ \r\n \n \r_example'; # string | To test code injection */ ' \" =_end -- \\r\\n \\n \\r eval { diff --git a/samples/client/petstore-security-test/perl/deep_module_test/lib/Something/Deep/ApiClient.pm b/samples/client/petstore-security-test/perl/deep_module_test/lib/Something/Deep/ApiClient.pm index 205df200d63..91025c6df55 100644 --- a/samples/client/petstore-security-test/perl/deep_module_test/lib/Something/Deep/ApiClient.pm +++ b/samples/client/petstore-security-test/perl/deep_module_test/lib/Something/Deep/ApiClient.pm @@ -39,22 +39,25 @@ use Module::Runtime qw(use_module); use Something::Deep::Configuration; -use base 'Class::Singleton'; -sub _new_instance -{ +sub new { my $class = shift; + + my $config; + if ( $_[0] && ref $_[0] && ref $_[0] eq 'Something::Deep::Configuration' ) { + $config = $_[0]; + } else { + $config = Something::Deep::Configuration->new(@_); + } + my (%args) = ( 'ua' => LWP::UserAgent->new, - 'base_url' => 'https://petstore.swagger.io */ ' \" =_end -- \\r\\n \\n \\r/v2 */ ' \" =_end -- \\r\\n \\n \\r', - @_ + 'config' => $config, ); return bless \%args, $class; } -sub _cfg {'Something::Deep::Configuration'} - # Set the user agent of the API client # # @param string $user_agent The user agent of the API client @@ -91,7 +94,7 @@ sub call_api { $self->update_params_for_auth($header_params, $query_params, $auth_settings); - my $_url = $self->{base_url} . $resource_path; + my $_url = $self->{config}{base_url} . $resource_path; # build query if (%$query_params) { @@ -138,8 +141,8 @@ sub call_api { else { } - $self->{ua}->timeout($self->{http_timeout} || $Something::Deep::Configuration::http_timeout); - $self->{ua}->agent($self->{http_user_agent} || $Something::Deep::Configuration::http_user_agent); + $self->{ua}->timeout($self->{http_timeout} || $self->{config}{http_timeout}); + $self->{ua}->agent($self->{http_user_agent} || $self->{config}{http_user_agent}); $log->debugf("REQUEST: %s", $_request->as_string); my $_response = $self->{ua}->request($_request); @@ -313,11 +316,11 @@ sub get_api_key_with_prefix { my ($self, $key_name) = @_; - my $api_key = $Something::Deep::Configuration::api_key->{$key_name}; + my $api_key = $self->{config}{api_key}{$key_name}; return unless $api_key; - my $prefix = $Something::Deep::Configuration::api_key_prefix->{$key_name}; + my $prefix = $self->{config}{api_key_prefix}{$key_name}; return $prefix ? "$prefix $api_key" : $api_key; } @@ -347,8 +350,8 @@ sub update_params_for_auth { } elsif ($auth eq 'petstore_auth') { - if ($Something::Deep::Configuration::access_token) { - $header_params->{'Authorization'} = 'Bearer ' . $Something::Deep::Configuration::access_token; + if ($self->{config}{access_token}) { + $header_params->{'Authorization'} = 'Bearer ' . $self->{config}{access_token}; } } else { @@ -364,7 +367,7 @@ elsif ($auth eq 'petstore_auth') { sub _global_auth_setup { my ($self, $header_params, $query_params) = @_; - my $tokens = $self->_cfg->get_tokens; + my $tokens = $self->{config}->get_tokens; return unless keys %$tokens; # basic diff --git a/samples/client/petstore-security-test/perl/deep_module_test/lib/Something/Deep/ApiFactory.pm b/samples/client/petstore-security-test/perl/deep_module_test/lib/Something/Deep/ApiFactory.pm index 39a23aa2a80..c75b5daeac9 100644 --- a/samples/client/petstore-security-test/perl/deep_module_test/lib/Something/Deep/ApiFactory.pm +++ b/samples/client/petstore-security-test/perl/deep_module_test/lib/Something/Deep/ApiFactory.pm @@ -62,19 +62,28 @@ my %_apis = map { $_ =~ /^Something::Deep::(.*)$/; $1 => $_ } grep {$_ =~ /Api$/} usesub 'Something::Deep'; -=head1 new() +=head1 new($api_client) - Any parameters are optional, and are passed to and stored on the api_client object. - - base_url: (optional) - supply this to change the default base URL taken from the Swagger definition. + create a new Something::Deep::ApiFactory instance with the given Something::Deep::ApiClient instance. + +=head1 new(%paramters) + + Any parameters are optional, and are passed to and stored on the api_client object. + See L and L for valid paramters + =cut sub new { - my ($class, %p) = (shift, @_); - $p{api_client} = Something::Deep::ApiClient->instance(%p); - return bless \%p, $class; + my ($class) = shift; + + my $api_client; + if ($_[0] && ref $_[0] && ref $_[0] eq 'Something::Deep::ApiClient' ) { + $api_client = $_[0]; + } else { + $api_client = Something::Deep::ApiClient->new(@_); + } + bless { api_client => $api_client }, $class; } =head1 get_api($which) @@ -91,7 +100,7 @@ sub get_api { my ($self, $which) = @_; croak "API not specified" unless $which; my $api_class = $_apis{"${which}Api"} || croak "No known API for '$which'"; - return $api_class->new(api_client => $self->api_client); + return $api_class->new($self->api_client); } =head1 api_client() diff --git a/samples/client/petstore-security-test/perl/deep_module_test/lib/Something/Deep/Configuration.pm b/samples/client/petstore-security-test/perl/deep_module_test/lib/Something/Deep/Configuration.pm index 559fcce8e4f..b903af61ea6 100644 --- a/samples/client/petstore-security-test/perl/deep_module_test/lib/Something/Deep/Configuration.pm +++ b/samples/client/petstore-security-test/perl/deep_module_test/lib/Something/Deep/Configuration.pm @@ -28,71 +28,142 @@ use Carp; use constant VERSION => '1.0.0'; -# class/static variables -our $http_timeout = 180; -our $http_user_agent = 'Swagger-Codegen/1.0.0/perl'; +=head1 Name -# authentication setting -our $api_key = {}; -our $api_key_prefix = {}; -our $api_key_in = {}; + Something::Deep::Configuration - holds the configuration for all Something::Deep Modules -# username and password for HTTP basic authentication -our $username = ''; -our $password = ''; +=head1 new(%paramters) + +=over 4 + +=item http_timeout: (optional) + +Integer. timeout for HTTP requests in seconds + +default: 180 + +=item http_user_agent: (optional) + +String. custom UserAgent header + +default: Swagger-Codegen/1.0.0/perl + +=item api_key: (optional) + +Hashref. Keyed on the name of each key (there can be multiple tokens). + + api_key => { + secretKey => 'aaaabbbbccccdddd', + anotherKey => '1111222233334444', + }; + +=item api_key_prefix: (optional) + +Hashref. Keyed on the name of each key (there can be multiple tokens). Note not all api keys require a prefix. + + api_key_prefix => { + secretKey => 'string', + anotherKey => 'same or some other string', + }; + +=item api_key_in: (optional) + +=item username: (optional) + +String. The username for basic auth. + +=item password: (optional) + +String. The password for basic auth. + +=item access_token: (optional) + +String. The OAuth access token. + +=item base_url: (optional) + +String. The base URL of the API + +default: https://petstore.swagger.io */ ' \" =_end -- \\r\\n \\n \\r/v2 */ ' \" =_end -- \\r\\n \\n \\r + +=back + +=cut + +sub new { + my ($self, %p) = (shift,@_); + + # class/static variables + $p{http_timeout} //= 180; + $p{http_user_agent} //= 'Swagger-Codegen/1.0.0/perl'; + + # authentication setting + $p{api_key} //= {}; + $p{api_key_prefix} //= {}; + $p{api_key_in} //= {}; + + # username and password for HTTP basic authentication + $p{username} //= ''; + $p{password} //= ''; + + # access token for OAuth + $p{access_token} //= ''; + + # base_url + $p{base_url} //= 'https://petstore.swagger.io */ ' \" =_end -- \\r\\n \\n \\r/v2 */ ' \" =_end -- \\r\\n \\n \\r'; + + return bless \%p => $self; +} -# access token for OAuth -our $access_token = ''; sub get_tokens { - my $class = shift; + my $self = shift; my $tokens = {}; - $tokens->{username} = $username if $username; - $tokens->{password} = $password if $password; - $tokens->{access_token} = $access_token if $access_token; + $tokens->{username} = $self->{username} if $self->{username}; + $tokens->{password} = $self->{password} if $self->{password}; + $tokens->{access_token} = $self->{access_token} if $self->{access_token}; - foreach my $token_name (keys %{ $api_key }) { - $tokens->{$token_name}->{token} = $api_key->{$token_name}; - $tokens->{$token_name}->{prefix} = $api_key_prefix->{$token_name}; - $tokens->{$token_name}->{in} = $api_key_in->{$token_name}; + foreach my $token_name (keys %{ $self->{api_key} }) { + $tokens->{$token_name}->{token} = $self->{api_key}{$token_name}; + $tokens->{$token_name}->{prefix} = $self->{api_key_prefix}{$token_name}; + $tokens->{$token_name}->{in} = $self->{api_key_in}{$token_name}; } return $tokens; } sub clear_tokens { - my $class = shift; - my %tokens = %{$class->get_tokens}; # copy + my $self = shift; + my %tokens = %{$self->get_tokens}; # copy - $username = undef; - $password = undef; - $access_token = undef; + $self->{username} = ''; + $self->{password} = ''; + $self->{access_token} = ''; - $api_key = {}; - $api_key_prefix = {}; - $api_key_in = {}; + $self->{api_key} = {}; + $self->{api_key_prefix} = {}; + $self->{api_key_in} = {}; return \%tokens; } sub accept_tokens { - my ($class, $tokens) = @_; + my ($self, $tokens) = @_; foreach my $known_name (qw(username password access_token)) { next unless $tokens->{$known_name}; - eval "\$$known_name = delete \$tokens->{\$known_name}"; - die $@ if $@; + $self->{$known_name} = delete $tokens->{$known_name}; } foreach my $token_name (keys %$tokens) { - $api_key->{$token_name} = $tokens->{$token_name}->{token}; - if ($tokens->{$token_name}->{prefix}) { - $api_key_prefix->{$token_name} = $tokens->{$token_name}->{prefix}; + $self->{api_key}{$token_name} = $tokens->{$token_name}{token}; + if ($tokens->{$token_name}{prefix}) { + $self->{api_key_prefix}{$token_name} = $tokens->{$token_name}{prefix}; } my $in = $tokens->{$token_name}->{in} || 'head'; croak "Tokens can only go in 'head' or 'query' (not in '$in')" unless $in =~ /^(?:head|query)$/; - $api_key_in->{$token_name} = $in; + $self->{api_key_in}{$token_name} = $in; } } diff --git a/samples/client/petstore-security-test/perl/deep_module_test/lib/Something/Deep/FakeApi.pm b/samples/client/petstore-security-test/perl/deep_module_test/lib/Something/Deep/FakeApi.pm index ca16c6f21fd..33c0f7b3936 100644 --- a/samples/client/petstore-security-test/perl/deep_module_test/lib/Something/Deep/FakeApi.pm +++ b/samples/client/petstore-security-test/perl/deep_module_test/lib/Something/Deep/FakeApi.pm @@ -28,25 +28,22 @@ use Carp qw( croak ); use Log::Any qw($log); use Something::Deep::ApiClient; -use Something::Deep::Configuration; use base "Class::Data::Inheritable"; __PACKAGE__->mk_classdata('method_documentation' => {}); sub new { - my $class = shift; - my (%self) = ( - 'api_client' => Something::Deep::ApiClient->instance, - @_ - ); + my $class = shift; + my $api_client; - #my $self = { - # #api_client => $options->{api_client} - # api_client => $default_api_client - #}; + if ($_[0] && ref $_[0] && ref $_[0] eq 'Something::Deep::ApiClient' ) { + $api_client = $_[0]; + } else { + $api_client = Something::Deep::ApiClient->new(@_); + } - bless \%self, $class; + bless { api_client => $api_client }, $class; } diff --git a/samples/client/petstore-security-test/perl/deep_module_test/lib/Something/Deep/Object/ModelReturn.pm b/samples/client/petstore-security-test/perl/deep_module_test/lib/Something/Deep/Object/ModelReturn.pm index 4e42c5e0698..248a672c60e 100644 --- a/samples/client/petstore-security-test/perl/deep_module_test/lib/Something/Deep/Object/ModelReturn.pm +++ b/samples/client/petstore-security-test/perl/deep_module_test/lib/Something/Deep/Object/ModelReturn.pm @@ -30,6 +30,7 @@ use Log::Any qw($log); use Date::Parse; use DateTime; + use base ("Class::Accessor", "Class::Data::Inheritable"); diff --git a/samples/client/petstore-security-test/perl/deep_module_test/lib/Something/Deep/Role.pm b/samples/client/petstore-security-test/perl/deep_module_test/lib/Something/Deep/Role.pm index 5723472b1cc..f82a7808f6f 100644 --- a/samples/client/petstore-security-test/perl/deep_module_test/lib/Something/Deep/Role.pm +++ b/samples/client/petstore-security-test/perl/deep_module_test/lib/Something/Deep/Role.pm @@ -47,8 +47,8 @@ has tokens => ( is => 'ro', ); has _cfg => ( is => 'ro', - isa => 'Str', - default => 'Something::Deep::Configuration', + isa => 'Something::Deep::Configuration', + default => sub { Something::Deep::Configuration->new() }, ); has version_info => ( is => 'ro', @@ -201,39 +201,39 @@ you are accessing. Usually C and C will be determined by the code ge the spec and you will not need to set them at run time. If not, C will default to 'head' and C to the empty string. -The tokens will be placed in the C namespace +The tokens will be placed in a L instance as follows, but you don't need to know about this. =over 4 -=item C<$Something::Deep::Configuration::username> +=item C<$cfg-\>{username}> String. The username for basic auth. -=item C<$Something::Deep::Configuration::password> +=item C<$cfg-\>{password}> String. The password for basic auth. -=item C<$Something::Deep::Configuration::api_key> +=item C<$cfg-\>{api_key}> Hashref. Keyed on the name of each key (there can be multiple tokens). - $Something::Deep::Configuration::api_key = { + $cfg->{api_key} = { secretKey => 'aaaabbbbccccdddd', anotherKey => '1111222233334444', }; -=item C<$Something::Deep::Configuration::api_key_prefix> +=item C<$cfg->{api_key_prefix}> Hashref. Keyed on the name of each key (there can be multiple tokens). Note not all api keys require a prefix. - $Something::Deep::Configuration::api_key_prefix = { + $cfg->{api_key_prefix} = { secretKey => 'string', anotherKey => 'same or some other string', }; -=item C<$Something::Deep::Configuration::access_token> +=item C<$config-\>{access_token}> String. The OAuth access token. @@ -244,8 +244,7 @@ String. The OAuth access token. =head2 C The generated code has the C already set as a default value. This method -returns (and optionally sets, but only if the API client has not been -created yet) the current value of C. +returns the current value of C. =head2 C diff --git a/samples/client/petstore-security-test/perl/docs/FakeApi.md b/samples/client/petstore-security-test/perl/docs/FakeApi.md index 7caee1454f1..fbea6c1fc8d 100644 --- a/samples/client/petstore-security-test/perl/docs/FakeApi.md +++ b/samples/client/petstore-security-test/perl/docs/FakeApi.md @@ -20,10 +20,10 @@ To test code injection */ ' \" =_end -- \\r\\n \\n \\r ### Example ```perl use Data::Dumper; -use WWW::SwaggerClient::Configuration; use WWW::SwaggerClient::FakeApi; +my $api_instance = WWW::SwaggerClient::FakeApi->new( +); -my $api_instance = WWW::SwaggerClient::FakeApi->new(); my $test code inject */ ' " =end __ \r\n \n \r = 'test code inject */ ' " =end __ \r\n \n \r_example'; # string | To test code injection */ ' \" =_end -- \\r\\n \\n \\r eval { diff --git a/samples/client/petstore-security-test/perl/lib/WWW/SwaggerClient/ApiClient.pm b/samples/client/petstore-security-test/perl/lib/WWW/SwaggerClient/ApiClient.pm index 48770b587a7..1a3c23c1f7b 100644 --- a/samples/client/petstore-security-test/perl/lib/WWW/SwaggerClient/ApiClient.pm +++ b/samples/client/petstore-security-test/perl/lib/WWW/SwaggerClient/ApiClient.pm @@ -39,22 +39,25 @@ use Module::Runtime qw(use_module); use WWW::SwaggerClient::Configuration; -use base 'Class::Singleton'; -sub _new_instance -{ +sub new { my $class = shift; + + my $config; + if ( $_[0] && ref $_[0] && ref $_[0] eq 'WWW::SwaggerClient::Configuration' ) { + $config = $_[0]; + } else { + $config = WWW::SwaggerClient::Configuration->new(@_); + } + my (%args) = ( 'ua' => LWP::UserAgent->new, - 'base_url' => 'https://petstore.swagger.io */ ' \" =_end -- \\r\\n \\n \\r/v2 */ ' \" =_end -- \\r\\n \\n \\r', - @_ + 'config' => $config, ); return bless \%args, $class; } -sub _cfg {'WWW::SwaggerClient::Configuration'} - # Set the user agent of the API client # # @param string $user_agent The user agent of the API client @@ -91,7 +94,7 @@ sub call_api { $self->update_params_for_auth($header_params, $query_params, $auth_settings); - my $_url = $self->{base_url} . $resource_path; + my $_url = $self->{config}{base_url} . $resource_path; # build query if (%$query_params) { @@ -138,8 +141,8 @@ sub call_api { else { } - $self->{ua}->timeout($self->{http_timeout} || $WWW::SwaggerClient::Configuration::http_timeout); - $self->{ua}->agent($self->{http_user_agent} || $WWW::SwaggerClient::Configuration::http_user_agent); + $self->{ua}->timeout($self->{http_timeout} || $self->{config}{http_timeout}); + $self->{ua}->agent($self->{http_user_agent} || $self->{config}{http_user_agent}); $log->debugf("REQUEST: %s", $_request->as_string); my $_response = $self->{ua}->request($_request); @@ -313,11 +316,11 @@ sub get_api_key_with_prefix { my ($self, $key_name) = @_; - my $api_key = $WWW::SwaggerClient::Configuration::api_key->{$key_name}; + my $api_key = $self->{config}{api_key}{$key_name}; return unless $api_key; - my $prefix = $WWW::SwaggerClient::Configuration::api_key_prefix->{$key_name}; + my $prefix = $self->{config}{api_key_prefix}{$key_name}; return $prefix ? "$prefix $api_key" : $api_key; } @@ -347,8 +350,8 @@ sub update_params_for_auth { } elsif ($auth eq 'petstore_auth') { - if ($WWW::SwaggerClient::Configuration::access_token) { - $header_params->{'Authorization'} = 'Bearer ' . $WWW::SwaggerClient::Configuration::access_token; + if ($self->{config}{access_token}) { + $header_params->{'Authorization'} = 'Bearer ' . $self->{config}{access_token}; } } else { @@ -364,7 +367,7 @@ elsif ($auth eq 'petstore_auth') { sub _global_auth_setup { my ($self, $header_params, $query_params) = @_; - my $tokens = $self->_cfg->get_tokens; + my $tokens = $self->{config}->get_tokens; return unless keys %$tokens; # basic diff --git a/samples/client/petstore-security-test/perl/lib/WWW/SwaggerClient/ApiFactory.pm b/samples/client/petstore-security-test/perl/lib/WWW/SwaggerClient/ApiFactory.pm index 14d9027a554..96f68cbde1e 100644 --- a/samples/client/petstore-security-test/perl/lib/WWW/SwaggerClient/ApiFactory.pm +++ b/samples/client/petstore-security-test/perl/lib/WWW/SwaggerClient/ApiFactory.pm @@ -62,19 +62,28 @@ my %_apis = map { $_ =~ /^WWW::SwaggerClient::(.*)$/; $1 => $_ } grep {$_ =~ /Api$/} usesub 'WWW::SwaggerClient'; -=head1 new() +=head1 new($api_client) - Any parameters are optional, and are passed to and stored on the api_client object. - - base_url: (optional) - supply this to change the default base URL taken from the Swagger definition. + create a new WWW::SwaggerClient::ApiFactory instance with the given WWW::SwaggerClient::ApiClient instance. + +=head1 new(%paramters) + + Any parameters are optional, and are passed to and stored on the api_client object. + See L and L for valid paramters + =cut sub new { - my ($class, %p) = (shift, @_); - $p{api_client} = WWW::SwaggerClient::ApiClient->instance(%p); - return bless \%p, $class; + my ($class) = shift; + + my $api_client; + if ($_[0] && ref $_[0] && ref $_[0] eq 'WWW::SwaggerClient::ApiClient' ) { + $api_client = $_[0]; + } else { + $api_client = WWW::SwaggerClient::ApiClient->new(@_); + } + bless { api_client => $api_client }, $class; } =head1 get_api($which) @@ -91,7 +100,7 @@ sub get_api { my ($self, $which) = @_; croak "API not specified" unless $which; my $api_class = $_apis{"${which}Api"} || croak "No known API for '$which'"; - return $api_class->new(api_client => $self->api_client); + return $api_class->new($self->api_client); } =head1 api_client() diff --git a/samples/client/petstore-security-test/perl/lib/WWW/SwaggerClient/Configuration.pm b/samples/client/petstore-security-test/perl/lib/WWW/SwaggerClient/Configuration.pm index 61428f94280..488e608169f 100644 --- a/samples/client/petstore-security-test/perl/lib/WWW/SwaggerClient/Configuration.pm +++ b/samples/client/petstore-security-test/perl/lib/WWW/SwaggerClient/Configuration.pm @@ -28,71 +28,142 @@ use Carp; use constant VERSION => '1.0.0'; -# class/static variables -our $http_timeout = 180; -our $http_user_agent = 'Swagger-Codegen/1.0.0/perl'; +=head1 Name -# authentication setting -our $api_key = {}; -our $api_key_prefix = {}; -our $api_key_in = {}; + WWW::SwaggerClient::Configuration - holds the configuration for all WWW::SwaggerClient Modules -# username and password for HTTP basic authentication -our $username = ''; -our $password = ''; +=head1 new(%paramters) + +=over 4 + +=item http_timeout: (optional) + +Integer. timeout for HTTP requests in seconds + +default: 180 + +=item http_user_agent: (optional) + +String. custom UserAgent header + +default: Swagger-Codegen/1.0.0/perl + +=item api_key: (optional) + +Hashref. Keyed on the name of each key (there can be multiple tokens). + + api_key => { + secretKey => 'aaaabbbbccccdddd', + anotherKey => '1111222233334444', + }; + +=item api_key_prefix: (optional) + +Hashref. Keyed on the name of each key (there can be multiple tokens). Note not all api keys require a prefix. + + api_key_prefix => { + secretKey => 'string', + anotherKey => 'same or some other string', + }; + +=item api_key_in: (optional) + +=item username: (optional) + +String. The username for basic auth. + +=item password: (optional) + +String. The password for basic auth. + +=item access_token: (optional) + +String. The OAuth access token. + +=item base_url: (optional) + +String. The base URL of the API + +default: https://petstore.swagger.io */ ' \" =_end -- \\r\\n \\n \\r/v2 */ ' \" =_end -- \\r\\n \\n \\r + +=back + +=cut + +sub new { + my ($self, %p) = (shift,@_); + + # class/static variables + $p{http_timeout} //= 180; + $p{http_user_agent} //= 'Swagger-Codegen/1.0.0/perl'; + + # authentication setting + $p{api_key} //= {}; + $p{api_key_prefix} //= {}; + $p{api_key_in} //= {}; + + # username and password for HTTP basic authentication + $p{username} //= ''; + $p{password} //= ''; + + # access token for OAuth + $p{access_token} //= ''; + + # base_url + $p{base_url} //= 'https://petstore.swagger.io */ ' \" =_end -- \\r\\n \\n \\r/v2 */ ' \" =_end -- \\r\\n \\n \\r'; + + return bless \%p => $self; +} -# access token for OAuth -our $access_token = ''; sub get_tokens { - my $class = shift; + my $self = shift; my $tokens = {}; - $tokens->{username} = $username if $username; - $tokens->{password} = $password if $password; - $tokens->{access_token} = $access_token if $access_token; + $tokens->{username} = $self->{username} if $self->{username}; + $tokens->{password} = $self->{password} if $self->{password}; + $tokens->{access_token} = $self->{access_token} if $self->{access_token}; - foreach my $token_name (keys %{ $api_key }) { - $tokens->{$token_name}->{token} = $api_key->{$token_name}; - $tokens->{$token_name}->{prefix} = $api_key_prefix->{$token_name}; - $tokens->{$token_name}->{in} = $api_key_in->{$token_name}; + foreach my $token_name (keys %{ $self->{api_key} }) { + $tokens->{$token_name}->{token} = $self->{api_key}{$token_name}; + $tokens->{$token_name}->{prefix} = $self->{api_key_prefix}{$token_name}; + $tokens->{$token_name}->{in} = $self->{api_key_in}{$token_name}; } return $tokens; } sub clear_tokens { - my $class = shift; - my %tokens = %{$class->get_tokens}; # copy + my $self = shift; + my %tokens = %{$self->get_tokens}; # copy - $username = undef; - $password = undef; - $access_token = undef; + $self->{username} = ''; + $self->{password} = ''; + $self->{access_token} = ''; - $api_key = {}; - $api_key_prefix = {}; - $api_key_in = {}; + $self->{api_key} = {}; + $self->{api_key_prefix} = {}; + $self->{api_key_in} = {}; return \%tokens; } sub accept_tokens { - my ($class, $tokens) = @_; + my ($self, $tokens) = @_; foreach my $known_name (qw(username password access_token)) { next unless $tokens->{$known_name}; - eval "\$$known_name = delete \$tokens->{\$known_name}"; - die $@ if $@; + $self->{$known_name} = delete $tokens->{$known_name}; } foreach my $token_name (keys %$tokens) { - $api_key->{$token_name} = $tokens->{$token_name}->{token}; - if ($tokens->{$token_name}->{prefix}) { - $api_key_prefix->{$token_name} = $tokens->{$token_name}->{prefix}; + $self->{api_key}{$token_name} = $tokens->{$token_name}{token}; + if ($tokens->{$token_name}{prefix}) { + $self->{api_key_prefix}{$token_name} = $tokens->{$token_name}{prefix}; } my $in = $tokens->{$token_name}->{in} || 'head'; croak "Tokens can only go in 'head' or 'query' (not in '$in')" unless $in =~ /^(?:head|query)$/; - $api_key_in->{$token_name} = $in; + $self->{api_key_in}{$token_name} = $in; } } diff --git a/samples/client/petstore-security-test/perl/lib/WWW/SwaggerClient/FakeApi.pm b/samples/client/petstore-security-test/perl/lib/WWW/SwaggerClient/FakeApi.pm index f8502625686..79318d9180b 100644 --- a/samples/client/petstore-security-test/perl/lib/WWW/SwaggerClient/FakeApi.pm +++ b/samples/client/petstore-security-test/perl/lib/WWW/SwaggerClient/FakeApi.pm @@ -28,25 +28,22 @@ use Carp qw( croak ); use Log::Any qw($log); use WWW::SwaggerClient::ApiClient; -use WWW::SwaggerClient::Configuration; use base "Class::Data::Inheritable"; __PACKAGE__->mk_classdata('method_documentation' => {}); sub new { - my $class = shift; - my (%self) = ( - 'api_client' => WWW::SwaggerClient::ApiClient->instance, - @_ - ); + my $class = shift; + my $api_client; - #my $self = { - # #api_client => $options->{api_client} - # api_client => $default_api_client - #}; + if ($_[0] && ref $_[0] && ref $_[0] eq 'WWW::SwaggerClient::ApiClient' ) { + $api_client = $_[0]; + } else { + $api_client = WWW::SwaggerClient::ApiClient->new(@_); + } - bless \%self, $class; + bless { api_client => $api_client }, $class; } diff --git a/samples/client/petstore-security-test/perl/lib/WWW/SwaggerClient/Object/ModelReturn.pm b/samples/client/petstore-security-test/perl/lib/WWW/SwaggerClient/Object/ModelReturn.pm index c87fc7c970e..b58bee43fc6 100644 --- a/samples/client/petstore-security-test/perl/lib/WWW/SwaggerClient/Object/ModelReturn.pm +++ b/samples/client/petstore-security-test/perl/lib/WWW/SwaggerClient/Object/ModelReturn.pm @@ -30,6 +30,7 @@ use Log::Any qw($log); use Date::Parse; use DateTime; + use base ("Class::Accessor", "Class::Data::Inheritable"); diff --git a/samples/client/petstore-security-test/perl/lib/WWW/SwaggerClient/Role.pm b/samples/client/petstore-security-test/perl/lib/WWW/SwaggerClient/Role.pm index 100770cacfe..b04fa8d54bd 100644 --- a/samples/client/petstore-security-test/perl/lib/WWW/SwaggerClient/Role.pm +++ b/samples/client/petstore-security-test/perl/lib/WWW/SwaggerClient/Role.pm @@ -47,8 +47,8 @@ has tokens => ( is => 'ro', ); has _cfg => ( is => 'ro', - isa => 'Str', - default => 'WWW::SwaggerClient::Configuration', + isa => 'WWW::SwaggerClient::Configuration', + default => sub { WWW::SwaggerClient::Configuration->new() }, ); has version_info => ( is => 'ro', @@ -201,39 +201,39 @@ you are accessing. Usually C and C will be determined by the code ge the spec and you will not need to set them at run time. If not, C will default to 'head' and C to the empty string. -The tokens will be placed in the C namespace +The tokens will be placed in a L instance as follows, but you don't need to know about this. =over 4 -=item C<$WWW::SwaggerClient::Configuration::username> +=item C<$cfg-\>{username}> String. The username for basic auth. -=item C<$WWW::SwaggerClient::Configuration::password> +=item C<$cfg-\>{password}> String. The password for basic auth. -=item C<$WWW::SwaggerClient::Configuration::api_key> +=item C<$cfg-\>{api_key}> Hashref. Keyed on the name of each key (there can be multiple tokens). - $WWW::SwaggerClient::Configuration::api_key = { + $cfg->{api_key} = { secretKey => 'aaaabbbbccccdddd', anotherKey => '1111222233334444', }; -=item C<$WWW::SwaggerClient::Configuration::api_key_prefix> +=item C<$cfg->{api_key_prefix}> Hashref. Keyed on the name of each key (there can be multiple tokens). Note not all api keys require a prefix. - $WWW::SwaggerClient::Configuration::api_key_prefix = { + $cfg->{api_key_prefix} = { secretKey => 'string', anotherKey => 'same or some other string', }; -=item C<$WWW::SwaggerClient::Configuration::access_token> +=item C<$config-\>{access_token}> String. The OAuth access token. @@ -244,8 +244,7 @@ String. The OAuth access token. =head2 C The generated code has the C already set as a default value. This method -returns (and optionally sets, but only if the API client has not been -created yet) the current value of C. +returns the current value of C. =head2 C diff --git a/samples/client/petstore/perl/.swagger-codegen/VERSION b/samples/client/petstore/perl/.swagger-codegen/VERSION index 7fea99011a6..f9f7450d135 100644 --- a/samples/client/petstore/perl/.swagger-codegen/VERSION +++ b/samples/client/petstore/perl/.swagger-codegen/VERSION @@ -1 +1 @@ -2.2.3-SNAPSHOT \ No newline at end of file +2.3.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/perl/README.md b/samples/client/petstore/perl/README.md index 2a404df51e8..32e5e359b1d 100644 --- a/samples/client/petstore/perl/README.md +++ b/samples/client/petstore/perl/README.md @@ -226,6 +226,7 @@ use WWW::SwaggerClient::FakeClassnameTags123Api; use WWW::SwaggerClient::PetApi; use WWW::SwaggerClient::StoreApi; use WWW::SwaggerClient::UserApi; +use WWW::SwaggerClient::AnotherfakeApi; ``` @@ -283,6 +284,7 @@ use WWW::SwaggerClient::FakeClassnameTags123Api; use WWW::SwaggerClient::PetApi; use WWW::SwaggerClient::StoreApi; use WWW::SwaggerClient::UserApi; +use WWW::SwaggerClient::AnotherfakeApi; # load the models use WWW::SwaggerClient::Object::AdditionalPropertiesClass; @@ -354,6 +356,7 @@ Class | Method | HTTP request | Description *FakeApi* | [**test_client_model**](docs/FakeApi.md#test_client_model) | **PATCH** /fake | To test \"client\" model *FakeApi* | [**test_endpoint_parameters**](docs/FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 *FakeApi* | [**test_enum_parameters**](docs/FakeApi.md#test_enum_parameters) | **GET** /fake | To test enum parameters +*FakeApi* | [**test_json_form_data**](docs/FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data *FakeClassnameTags123Api* | [**test_classname**](docs/FakeClassnameTags123Api.md#test_classname) | **PATCH** /fake_classname_test | To test class name in snake case *PetApi* | [**add_pet**](docs/PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store *PetApi* | [**delete_pet**](docs/PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet @@ -375,6 +378,7 @@ Class | Method | HTTP request | Description *UserApi* | [**login_user**](docs/UserApi.md#login_user) | **GET** /user/login | Logs user into the system *UserApi* | [**logout_user**](docs/UserApi.md#logout_user) | **GET** /user/logout | Logs out current logged in user session *UserApi* | [**update_user**](docs/UserApi.md#update_user) | **PUT** /user/{username} | Updated user +*AnotherfakeApi* | [**test_special_tags**](docs/AnotherfakeApi.md#test_special_tags) | **PATCH** /another-fake/dummy | To test special tags # DOCUMENTATION FOR MODELS @@ -424,6 +428,12 @@ Class | Method | HTTP request | Description - **API key parameter name**: api_key - **Location**: HTTP header +## api_key_query + +- **Type**: API key +- **API key parameter name**: api_key_query +- **Location**: URL query string + ## http_basic_test - **Type**: HTTP basic authentication diff --git a/samples/client/petstore/perl/docs/AnotherfakeApi.md b/samples/client/petstore/perl/docs/AnotherfakeApi.md new file mode 100644 index 00000000000..29a06be2e94 --- /dev/null +++ b/samples/client/petstore/perl/docs/AnotherfakeApi.md @@ -0,0 +1,60 @@ +# WWW::SwaggerClient::AnotherfakeApi + +## Load the API package +```perl +use WWW::SwaggerClient::Object::AnotherfakeApi; +``` + +All URIs are relative to *http://petstore.swagger.io:80/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**test_special_tags**](AnotherfakeApi.md#test_special_tags) | **PATCH** /another-fake/dummy | To test special tags + + +# **test_special_tags** +> Client test_special_tags(body => $body) + +To test special tags + +To test special tags + +### Example +```perl +use Data::Dumper; +use WWW::SwaggerClient::AnotherfakeApi; +my $api_instance = WWW::SwaggerClient::AnotherfakeApi->new( +); + +my $body = WWW::SwaggerClient::Object::Client->new(); # Client | client model + +eval { + my $result = $api_instance->test_special_tags(body => $body); + print Dumper($result); +}; +if ($@) { + warn "Exception when calling AnotherfakeApi->test_special_tags: $@\n"; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Client**](Client.md)| client model | + +### Return type + +[**Client**](Client.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/perl/docs/FakeApi.md b/samples/client/petstore/perl/docs/FakeApi.md index 3449f1e7aca..2ac74f17f5d 100644 --- a/samples/client/petstore/perl/docs/FakeApi.md +++ b/samples/client/petstore/perl/docs/FakeApi.md @@ -16,6 +16,7 @@ Method | HTTP request | Description [**test_client_model**](FakeApi.md#test_client_model) | **PATCH** /fake | To test \"client\" model [**test_endpoint_parameters**](FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 [**test_enum_parameters**](FakeApi.md#test_enum_parameters) | **GET** /fake | To test enum parameters +[**test_json_form_data**](FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data # **fake_outer_boolean_serialize** @@ -269,7 +270,7 @@ my $api_instance = WWW::SwaggerClient::FakeApi->new( my $number = 3.4; # Number | None my $double = 1.2; # double | None my $pattern_without_delimiter = 'pattern_without_delimiter_example'; # string | None -my $byte = 'B'; # string | None +my $byte = 'byte_example'; # string | None my $integer = 56; # int | None my $int32 = 56; # int | None my $int64 = 789; # int | None @@ -382,3 +383,50 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) +# **test_json_form_data** +> test_json_form_data(param => $param, param2 => $param2) + +test json serialization of form data + + + +### Example +```perl +use Data::Dumper; +use WWW::SwaggerClient::FakeApi; +my $api_instance = WWW::SwaggerClient::FakeApi->new( +); + +my $param = 'param_example'; # string | field1 +my $param2 = 'param2_example'; # string | field2 + +eval { + $api_instance->test_json_form_data(param => $param, param2 => $param2); +}; +if ($@) { + warn "Exception when calling FakeApi->test_json_form_data: $@\n"; +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **param** | **string**| field1 | + **param2** | **string**| field2 | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/perl/docs/FakeClassnameTags123Api.md b/samples/client/petstore/perl/docs/FakeClassnameTags123Api.md index b9e2893026f..ae6da4daf6c 100644 --- a/samples/client/petstore/perl/docs/FakeClassnameTags123Api.md +++ b/samples/client/petstore/perl/docs/FakeClassnameTags123Api.md @@ -22,6 +22,11 @@ To test class name in snake case use Data::Dumper; use WWW::SwaggerClient::FakeClassnameTags123Api; my $api_instance = WWW::SwaggerClient::FakeClassnameTags123Api->new( + + # Configure API key authorization: api_key_query + api_key => {'api_key_query' => 'YOUR_API_KEY'}, + # uncomment below to setup prefix (e.g. Bearer) for API key, if needed + #api_key_prefix => {'api_key_query' => 'Bearer'}, ); my $body = WWW::SwaggerClient::Object::Client->new(); # Client | client model @@ -47,7 +52,7 @@ Name | Type | Description | Notes ### Authorization -No authorization required +[api_key_query](../README.md#api_key_query) ### HTTP request headers diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/AnotherfakeApi.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/AnotherfakeApi.pm new file mode 100644 index 00000000000..48debee7dd1 --- /dev/null +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/AnotherfakeApi.pm @@ -0,0 +1,116 @@ +=begin comment + +Swagger Petstore + +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git + +=end comment + +=cut + +# +# NOTE: This class is auto generated by the swagger code generator program. +# Do not edit the class manually. +# Ref: https://github.com/swagger-api/swagger-codegen +# +package WWW::SwaggerClient::AnotherfakeApi; + +require 5.6.0; +use strict; +use warnings; +use utf8; +use Exporter; +use Carp qw( croak ); +use Log::Any qw($log); + +use WWW::SwaggerClient::ApiClient; + +use base "Class::Data::Inheritable"; + +__PACKAGE__->mk_classdata('method_documentation' => {}); + +sub new { + my $class = shift; + my $api_client; + + if ($_[0] && ref $_[0] && ref $_[0] eq 'WWW::SwaggerClient::ApiClient' ) { + $api_client = $_[0]; + } else { + $api_client = WWW::SwaggerClient::ApiClient->new(@_); + } + + bless { api_client => $api_client }, $class; + +} + + +# +# test_special_tags +# +# To test special tags +# +# @param Client $body client model (required) +{ + my $params = { + 'body' => { + data_type => 'Client', + description => 'client model', + required => '1', + }, + }; + __PACKAGE__->method_documentation->{ 'test_special_tags' } = { + summary => 'To test special tags', + params => $params, + returns => 'Client', + }; +} +# @return Client +# +sub test_special_tags { + my ($self, %args) = @_; + + # verify the required parameter 'body' is set + unless (exists $args{'body'}) { + croak("Missing the required parameter 'body' when calling test_special_tags"); + } + + # parse inputs + my $_resource_path = '/another-fake/dummy'; + + my $_method = 'PATCH'; + 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'); + if ($_header_accept) { + $header_params->{'Accept'} = $_header_accept; + } + $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/json'); + + my $_body_data; + # body params + if ( exists $args{'body'}) { + $_body_data = $args{'body'}; + } + + # authentication setting, if any + my $auth_settings = [qw()]; + + # 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('Client', $response); + return $_response_object; +} + +1; diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/ApiClient.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/ApiClient.pm index 9c404b2d5bf..40a1d3d6193 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/ApiClient.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/ApiClient.pm @@ -348,6 +348,13 @@ sub update_params_for_auth { $header_params->{'api_key'} = $api_key; } } +elsif ($auth eq 'api_key_query') { + + my $api_key = $self->get_api_key_with_prefix('api_key_query'); + if ($api_key) { + $query_params->{'api_key_query'} = $api_key; + } + } elsif ($auth eq 'http_basic_test') { if ($self->{config}{username} || $self->{config}{password}) { diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/FakeApi.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/FakeApi.pm index d0cd56a018b..8f4b272637a 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/FakeApi.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/FakeApi.pm @@ -705,4 +705,81 @@ sub test_enum_parameters { return; } +# +# test_json_form_data +# +# test json serialization of form data +# +# @param string $param field1 (required) +# @param string $param2 field2 (required) +{ + my $params = { + 'param' => { + data_type => 'string', + description => 'field1', + required => '1', + }, + 'param2' => { + data_type => 'string', + description => 'field2', + required => '1', + }, + }; + __PACKAGE__->method_documentation->{ 'test_json_form_data' } = { + summary => 'test json serialization of form data', + params => $params, + returns => undef, + }; +} +# @return void +# +sub test_json_form_data { + my ($self, %args) = @_; + + # verify the required parameter 'param' is set + unless (exists $args{'param'}) { + croak("Missing the required parameter 'param' when calling test_json_form_data"); + } + + # verify the required parameter 'param2' is set + unless (exists $args{'param2'}) { + croak("Missing the required parameter 'param2' when calling test_json_form_data"); + } + + # parse inputs + my $_resource_path = '/fake/jsonFormData'; + + 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(); + if ($_header_accept) { + $header_params->{'Accept'} = $_header_accept; + } + $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/json'); + + # form params + if ( exists $args{'param'} ) { + $form_params->{'param'} = $self->{api_client}->to_form_value($args{'param'}); + } + + # form params + if ( exists $args{'param2'} ) { + $form_params->{'param2'} = $self->{api_client}->to_form_value($args{'param2'}); + } + + my $_body_data; + # authentication setting, if any + my $auth_settings = [qw()]; + + # 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/FakeClassnameTags123Api.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/FakeClassnameTags123Api.pm index 2d0550f9f82..69d8cc6defc 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/FakeClassnameTags123Api.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/FakeClassnameTags123Api.pm @@ -100,7 +100,7 @@ sub test_classname { } # authentication setting, if any - my $auth_settings = [qw()]; + my $auth_settings = [qw(api_key_query )]; # make the API Call my $response = $self->{api_client}->call_api($_resource_path, $_method, diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/AdditionalPropertiesClass.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/AdditionalPropertiesClass.pm index 3fe437aecd6..36ef2b20a78 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/AdditionalPropertiesClass.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/AdditionalPropertiesClass.pm @@ -30,6 +30,7 @@ use Log::Any qw($log); use Date::Parse; use DateTime; + use base ("Class::Accessor", "Class::Data::Inheritable"); diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Animal.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Animal.pm index 563798ac8e0..22739cd6bc2 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Animal.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Animal.pm @@ -30,6 +30,7 @@ use Log::Any qw($log); use Date::Parse; use DateTime; + use base ("Class::Accessor", "Class::Data::Inheritable"); diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/AnimalFarm.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/AnimalFarm.pm index db72a37462d..8b967bc0b57 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/AnimalFarm.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/AnimalFarm.pm @@ -30,6 +30,8 @@ use Log::Any qw($log); use Date::Parse; use DateTime; +use WWW::SwaggerClient::Object::Animal; + use base ("Class::Accessor", "Class::Data::Inheritable"); diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/ApiResponse.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/ApiResponse.pm index 5fbfaa01188..f751367d9ec 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/ApiResponse.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/ApiResponse.pm @@ -30,6 +30,7 @@ use Log::Any qw($log); use Date::Parse; use DateTime; + use base ("Class::Accessor", "Class::Data::Inheritable"); diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/ArrayOfArrayOfNumberOnly.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/ArrayOfArrayOfNumberOnly.pm index d4a29601829..76ec3c05d5c 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/ArrayOfArrayOfNumberOnly.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/ArrayOfArrayOfNumberOnly.pm @@ -30,6 +30,8 @@ use Log::Any qw($log); use Date::Parse; use DateTime; +use WWW::SwaggerClient::Object::Number; + use base ("Class::Accessor", "Class::Data::Inheritable"); diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/ArrayOfNumberOnly.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/ArrayOfNumberOnly.pm index 2ca74a07bcf..ac57470e70b 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/ArrayOfNumberOnly.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/ArrayOfNumberOnly.pm @@ -30,6 +30,8 @@ use Log::Any qw($log); use Date::Parse; use DateTime; +use WWW::SwaggerClient::Object::Number; + use base ("Class::Accessor", "Class::Data::Inheritable"); diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/ArrayTest.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/ArrayTest.pm index 06b1510491a..efafb64be74 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/ArrayTest.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/ArrayTest.pm @@ -30,6 +30,8 @@ use Log::Any qw($log); use Date::Parse; use DateTime; +use WWW::SwaggerClient::Object::ReadOnlyFirst; + use base ("Class::Accessor", "Class::Data::Inheritable"); diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Capitalization.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Capitalization.pm index a1eb4353d3d..e6308e686aa 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Capitalization.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Capitalization.pm @@ -30,6 +30,7 @@ use Log::Any qw($log); use Date::Parse; use DateTime; + use base ("Class::Accessor", "Class::Data::Inheritable"); diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Cat.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Cat.pm index ec800a25880..382789fe043 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Cat.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Cat.pm @@ -30,6 +30,8 @@ use Log::Any qw($log); use Date::Parse; use DateTime; +use WWW::SwaggerClient::Object::Animal; + use base ("Class::Accessor", "Class::Data::Inheritable"); diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Category.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Category.pm index 3f2eef68d79..21d978183f6 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Category.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Category.pm @@ -30,6 +30,7 @@ use Log::Any qw($log); use Date::Parse; use DateTime; + use base ("Class::Accessor", "Class::Data::Inheritable"); diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/ClassModel.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/ClassModel.pm index 90634705247..9be89999e73 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/ClassModel.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/ClassModel.pm @@ -30,6 +30,7 @@ use Log::Any qw($log); use Date::Parse; use DateTime; + use base ("Class::Accessor", "Class::Data::Inheritable"); diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Client.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Client.pm index 1330c3de474..4a0a668805b 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Client.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Client.pm @@ -30,6 +30,7 @@ use Log::Any qw($log); use Date::Parse; use DateTime; + use base ("Class::Accessor", "Class::Data::Inheritable"); diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Dog.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Dog.pm index f390090bb82..259eaa27c4f 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Dog.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Dog.pm @@ -30,6 +30,8 @@ use Log::Any qw($log); use Date::Parse; use DateTime; +use WWW::SwaggerClient::Object::Animal; + use base ("Class::Accessor", "Class::Data::Inheritable"); diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/EnumArrays.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/EnumArrays.pm index 0378f0da8d7..a4c44c93d43 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/EnumArrays.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/EnumArrays.pm @@ -30,6 +30,7 @@ use Log::Any qw($log); use Date::Parse; use DateTime; + use base ("Class::Accessor", "Class::Data::Inheritable"); diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/EnumClass.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/EnumClass.pm index c6f86df9650..981873845ae 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/EnumClass.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/EnumClass.pm @@ -30,6 +30,7 @@ use Log::Any qw($log); use Date::Parse; use DateTime; + use base ("Class::Accessor", "Class::Data::Inheritable"); diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/EnumTest.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/EnumTest.pm index 6b5f9317c4d..0d94500ec78 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/EnumTest.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/EnumTest.pm @@ -30,6 +30,8 @@ use Log::Any qw($log); use Date::Parse; use DateTime; +use WWW::SwaggerClient::Object::OuterEnum; + use base ("Class::Accessor", "Class::Data::Inheritable"); diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/FormatTest.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/FormatTest.pm index 99035e024ce..acbeb44796f 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/FormatTest.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/FormatTest.pm @@ -30,6 +30,9 @@ use Log::Any qw($log); use Date::Parse; use DateTime; +use WWW::SwaggerClient::Object::Number; +use WWW::SwaggerClient::Object::UUID; + use base ("Class::Accessor", "Class::Data::Inheritable"); diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/HasOnlyReadOnly.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/HasOnlyReadOnly.pm index 58f96d793df..26a049924ac 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/HasOnlyReadOnly.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/HasOnlyReadOnly.pm @@ -30,6 +30,7 @@ use Log::Any qw($log); use Date::Parse; use DateTime; + use base ("Class::Accessor", "Class::Data::Inheritable"); diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/List.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/List.pm index 0bfa14e7454..3651bdc0d47 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/List.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/List.pm @@ -30,6 +30,7 @@ use Log::Any qw($log); use Date::Parse; use DateTime; + use base ("Class::Accessor", "Class::Data::Inheritable"); diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/MapTest.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/MapTest.pm index 972bba09a68..85b3fb9f3f0 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/MapTest.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/MapTest.pm @@ -30,6 +30,7 @@ use Log::Any qw($log); use Date::Parse; use DateTime; + use base ("Class::Accessor", "Class::Data::Inheritable"); diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/MixedPropertiesAndAdditionalPropertiesClass.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/MixedPropertiesAndAdditionalPropertiesClass.pm index 23d4485fab7..7353bacdbbe 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/MixedPropertiesAndAdditionalPropertiesClass.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/MixedPropertiesAndAdditionalPropertiesClass.pm @@ -30,6 +30,9 @@ use Log::Any qw($log); use Date::Parse; use DateTime; +use WWW::SwaggerClient::Object::Animal; +use WWW::SwaggerClient::Object::UUID; + use base ("Class::Accessor", "Class::Data::Inheritable"); diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Model200Response.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Model200Response.pm index d3a8642c7f1..93d1debca41 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Model200Response.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Model200Response.pm @@ -30,6 +30,7 @@ use Log::Any qw($log); use Date::Parse; use DateTime; + use base ("Class::Accessor", "Class::Data::Inheritable"); diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/ModelReturn.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/ModelReturn.pm index d9dd154e49c..e395f7a17e2 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/ModelReturn.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/ModelReturn.pm @@ -30,6 +30,7 @@ use Log::Any qw($log); use Date::Parse; use DateTime; + use base ("Class::Accessor", "Class::Data::Inheritable"); diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Name.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Name.pm index 75008ef2859..7462ff05bc3 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Name.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Name.pm @@ -30,6 +30,7 @@ use Log::Any qw($log); use Date::Parse; use DateTime; + use base ("Class::Accessor", "Class::Data::Inheritable"); diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/NumberOnly.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/NumberOnly.pm index 46c00317e6e..c20db138e2a 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/NumberOnly.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/NumberOnly.pm @@ -30,6 +30,8 @@ use Log::Any qw($log); use Date::Parse; use DateTime; +use WWW::SwaggerClient::Object::Number; + use base ("Class::Accessor", "Class::Data::Inheritable"); diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Order.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Order.pm index 9b0f4b3fa42..de5a0ca92dc 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Order.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Order.pm @@ -30,6 +30,7 @@ use Log::Any qw($log); use Date::Parse; use DateTime; + use base ("Class::Accessor", "Class::Data::Inheritable"); diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/OuterBoolean.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/OuterBoolean.pm index 476df404705..c7bbc5700ae 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/OuterBoolean.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/OuterBoolean.pm @@ -30,6 +30,7 @@ use Log::Any qw($log); use Date::Parse; use DateTime; + use base ("Class::Accessor", "Class::Data::Inheritable"); diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/OuterComposite.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/OuterComposite.pm index 7697149a774..705ca951da9 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/OuterComposite.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/OuterComposite.pm @@ -30,6 +30,10 @@ use Log::Any qw($log); use Date::Parse; use DateTime; +use WWW::SwaggerClient::Object::OuterBoolean; +use WWW::SwaggerClient::Object::OuterNumber; +use WWW::SwaggerClient::Object::OuterString; + use base ("Class::Accessor", "Class::Data::Inheritable"); diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/OuterEnum.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/OuterEnum.pm index 344b4624d82..1b078e01ac5 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/OuterEnum.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/OuterEnum.pm @@ -30,6 +30,7 @@ use Log::Any qw($log); use Date::Parse; use DateTime; + use base ("Class::Accessor", "Class::Data::Inheritable"); diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/OuterNumber.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/OuterNumber.pm index 5bb037849c5..799fb19c80f 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/OuterNumber.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/OuterNumber.pm @@ -30,6 +30,7 @@ use Log::Any qw($log); use Date::Parse; use DateTime; + use base ("Class::Accessor", "Class::Data::Inheritable"); diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/OuterString.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/OuterString.pm index ac7e0ba5295..0c02799a35f 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/OuterString.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/OuterString.pm @@ -30,6 +30,7 @@ use Log::Any qw($log); use Date::Parse; use DateTime; + use base ("Class::Accessor", "Class::Data::Inheritable"); diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Pet.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Pet.pm index 8f023ea870f..817b627b549 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Pet.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Pet.pm @@ -30,6 +30,9 @@ use Log::Any qw($log); use Date::Parse; use DateTime; +use WWW::SwaggerClient::Object::Category; +use WWW::SwaggerClient::Object::Tag; + use base ("Class::Accessor", "Class::Data::Inheritable"); diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/ReadOnlyFirst.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/ReadOnlyFirst.pm index 22d81105352..f506c1416dc 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/ReadOnlyFirst.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/ReadOnlyFirst.pm @@ -30,6 +30,7 @@ use Log::Any qw($log); use Date::Parse; use DateTime; + use base ("Class::Accessor", "Class::Data::Inheritable"); diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/SpecialModelName.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/SpecialModelName.pm index cd7bc18b774..7f73a6d0314 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/SpecialModelName.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/SpecialModelName.pm @@ -30,6 +30,7 @@ use Log::Any qw($log); use Date::Parse; use DateTime; + use base ("Class::Accessor", "Class::Data::Inheritable"); diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Tag.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Tag.pm index f1d3249673b..c3da4f655f8 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Tag.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Tag.pm @@ -30,6 +30,7 @@ use Log::Any qw($log); use Date::Parse; use DateTime; + use base ("Class::Accessor", "Class::Data::Inheritable"); diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/User.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/User.pm index 6dd6de5e76a..8c02b6df99a 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/User.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/User.pm @@ -30,6 +30,7 @@ use Log::Any qw($log); use Date::Parse; use DateTime; + use base ("Class::Accessor", "Class::Data::Inheritable"); diff --git a/samples/client/petstore/perl/t/AnotherfakeApiTest.t b/samples/client/petstore/perl/t/AnotherfakeApiTest.t new file mode 100644 index 00000000000..35cd58c510e --- /dev/null +++ b/samples/client/petstore/perl/t/AnotherfakeApiTest.t @@ -0,0 +1,41 @@ +=begin comment + +Swagger Petstore + +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git + +=end comment + +=cut + +# +# NOTE: This class is auto generated by Swagger Codegen +# Please update the test cases below to test the API endpoints. +# Ref: https://github.com/swagger-api/swagger-codegen +# +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::AnotherfakeApi'); + +my $api = WWW::SwaggerClient::AnotherfakeApi->new(); +isa_ok($api, 'WWW::SwaggerClient::AnotherfakeApi'); + +# +# test_special_tags test +# +{ + my $body = undef; # replace NULL with a proper value + my $result = $api->test_special_tags(body => $body); +} + + +1;