mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-08 11:23:58 +00:00
Merge pull request #1507 from wing328/perl_support_ouath
[Perl] add oauth2 support for Perl
This commit is contained in:
commit
a3b90c516d
@ -323,7 +323,7 @@ sub update_params_for_auth {
|
|||||||
}
|
}
|
||||||
{{#authMethods}}elsif ($auth eq '{{name}}') {
|
{{#authMethods}}elsif ($auth eq '{{name}}') {
|
||||||
{{#isApiKey}}{{#isKeyInHeader}}$header_params->{'{{keyParamName}}'} = $self->get_api_key_with_prefix('{{keyParamName}}');{{/isKeyInHeader}}{{#isKeyInQuery}}$query_params->{'{{keyParamName}}'} = $self->get_api_key_with_prefix('{{keyParamName}}');{{/isKeyInQuery}}{{/isApiKey}}{{#isBasic}}$header_params->{'Authorization'} = 'Basic '.encode_base64($WWW::{{moduleName}}::Configuration::username.":".$WWW::{{moduleName}}::Configuration::password);{{/isBasic}}
|
{{#isApiKey}}{{#isKeyInHeader}}$header_params->{'{{keyParamName}}'} = $self->get_api_key_with_prefix('{{keyParamName}}');{{/isKeyInHeader}}{{#isKeyInQuery}}$query_params->{'{{keyParamName}}'} = $self->get_api_key_with_prefix('{{keyParamName}}');{{/isKeyInQuery}}{{/isApiKey}}{{#isBasic}}$header_params->{'Authorization'} = 'Basic '.encode_base64($WWW::{{moduleName}}::Configuration::username.":".$WWW::{{moduleName}}::Configuration::password);{{/isBasic}}
|
||||||
{{#isOAuth}}# TODO support oauth{{/isOAuth}}
|
{{#isOAuth}}$header_params->{'Authorization'} = 'Bearer ' . $WWW::{{moduleName}}::Configuration::access_token;{{/isOAuth}}
|
||||||
}
|
}
|
||||||
{{/authMethods}}
|
{{/authMethods}}
|
||||||
else {
|
else {
|
||||||
|
@ -17,8 +17,12 @@ our $http_user_agent = 'Perl-Swagger';
|
|||||||
# authenticaiton setting
|
# authenticaiton setting
|
||||||
our $api_key = {};
|
our $api_key = {};
|
||||||
our $api_key_prefix = {};
|
our $api_key_prefix = {};
|
||||||
our $username;
|
|
||||||
our $password;
|
|
||||||
|
|
||||||
|
# username and password for HTTP basic authentication
|
||||||
|
our $username = '';
|
||||||
|
our $password = '';
|
||||||
|
|
||||||
|
# access token for OAuth
|
||||||
|
our $access_token = '';
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
@ -327,7 +327,7 @@ sub update_params_for_auth {
|
|||||||
}
|
}
|
||||||
elsif ($auth eq 'petstore_auth') {
|
elsif ($auth eq 'petstore_auth') {
|
||||||
|
|
||||||
# TODO support oauth
|
$header_params->{'Authorization'} = 'Bearer ' . $WWW::SwaggerClient::Configuration::access_token;
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
|
@ -17,8 +17,12 @@ our $http_user_agent = 'Perl-Swagger';
|
|||||||
# authenticaiton setting
|
# authenticaiton setting
|
||||||
our $api_key = {};
|
our $api_key = {};
|
||||||
our $api_key_prefix = {};
|
our $api_key_prefix = {};
|
||||||
our $username;
|
|
||||||
our $password;
|
|
||||||
|
|
||||||
|
# username and password for HTTP basic authentication
|
||||||
|
our $username = '';
|
||||||
|
our $password = '';
|
||||||
|
|
||||||
|
# access token for OAuth
|
||||||
|
our $access_token = '';
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use Test::More tests => 42;
|
use Test::More tests => 41;
|
||||||
use Test::Exception;
|
use Test::Exception;
|
||||||
|
|
||||||
use lib 'lib';
|
use lib 'lib';
|
||||||
@ -22,7 +22,8 @@ is $store_api->{api_client}->{base_url}, 'http://petstore.swagger.io/v2', 'get t
|
|||||||
|
|
||||||
my $get_inventory_response = $store_api->get_inventory();
|
my $get_inventory_response = $store_api->get_inventory();
|
||||||
|
|
||||||
like ($get_inventory_response->{pending}, qr/^\d+$/, "pending is numeric");
|
# comment out pending check as sometimes there's no object with pending status
|
||||||
|
#like ($get_inventory_response->{pending}, qr/^\d+$/, "pending is numeric");
|
||||||
like ($get_inventory_response->{sold}, qr/^\d+$/, "sold is numeric");
|
like ($get_inventory_response->{sold}, qr/^\d+$/, "sold is numeric");
|
||||||
|
|
||||||
my $pet_json = <<JSON;
|
my $pet_json = <<JSON;
|
||||||
|
Loading…
Reference in New Issue
Block a user