forked from loafle/openapi-generator-original
update perl auth to skip null apikey/username&password
This commit is contained in:
parent
e4ac6ef033
commit
1d47ca69fe
@ -317,10 +317,24 @@ sub update_params_for_auth {
|
|||||||
foreach my $auth (@$auth_settings) {
|
foreach my $auth (@$auth_settings) {
|
||||||
# determine which one to use
|
# determine which one to use
|
||||||
if (!defined($auth)) {
|
if (!defined($auth)) {
|
||||||
|
# TODO show warning about auth setting not defined
|
||||||
}
|
}
|
||||||
{{#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}}
|
||||||
{{#isOAuth}}$header_params->{'Authorization'} = 'Bearer ' . $WWW::{{moduleName}}::Configuration::access_token;{{/isOAuth}}
|
my $api_key = $self->get_api_key_with_prefix('{{keyParamName}}');
|
||||||
|
if ($api_key) {
|
||||||
|
$header_params->{'{{keyParamName}}'} = $api_key;
|
||||||
|
}{{/isKeyInHeader}}{{#isKeyInQuery}}
|
||||||
|
my $api_key = $self->get_api_key_with_prefix('{{keyParamName}}');
|
||||||
|
if ($api_key) {
|
||||||
|
$query_params->{'{{keyParamName}}'} = $api_key;
|
||||||
|
}{{/isKeyInQuery}}{{/isApiKey}}{{#isBasic}}
|
||||||
|
if ($WWW::{{moduleName}}::Configuration::username || $WWW::{{moduleName}}::Configuration::password) {
|
||||||
|
$header_params->{'Authorization'} = 'Basic ' . encode_base64($WWW::{{moduleName}}::Configuration::username . ":" . $WWW::{{moduleName}}::Configuration::password);
|
||||||
|
}{{/isBasic}}{{#isOAuth}}
|
||||||
|
if ($WWW::{{moduleName}}::Configuration::access_token) {
|
||||||
|
$header_params->{'Authorization'} = 'Bearer ' . $WWW::{{moduleName}}::Configuration::access_token;
|
||||||
|
}{{/isOAuth}}
|
||||||
}
|
}
|
||||||
{{/authMethods}}
|
{{/authMethods}}
|
||||||
else {
|
else {
|
||||||
|
@ -317,15 +317,21 @@ sub update_params_for_auth {
|
|||||||
foreach my $auth (@$auth_settings) {
|
foreach my $auth (@$auth_settings) {
|
||||||
# determine which one to use
|
# determine which one to use
|
||||||
if (!defined($auth)) {
|
if (!defined($auth)) {
|
||||||
|
# TODO show warning about auth setting not defined
|
||||||
}
|
}
|
||||||
elsif ($auth eq 'api_key') {
|
elsif ($auth eq 'api_key') {
|
||||||
$header_params->{'api_key'} = $self->get_api_key_with_prefix('api_key');
|
|
||||||
|
|
||||||
|
my $api_key = $self->get_api_key_with_prefix('api_key');
|
||||||
|
if ($api_key) {
|
||||||
|
$header_params->{'api_key'} = $api_key;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
elsif ($auth eq 'petstore_auth') {
|
elsif ($auth eq 'petstore_auth') {
|
||||||
|
|
||||||
|
if ($WWW::SwaggerClient::Configuration::access_token) {
|
||||||
$header_params->{'Authorization'} = 'Bearer ' . $WWW::SwaggerClient::Configuration::access_token;
|
$header_params->{'Authorization'} = 'Bearer ' . $WWW::SwaggerClient::Configuration::access_token;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
# TODO show warning about security definition not found
|
# TODO show warning about security definition not found
|
||||||
|
@ -37,7 +37,7 @@ has version_info => ( is => 'ro',
|
|||||||
default => sub { {
|
default => sub { {
|
||||||
app_name => 'Swagger Petstore',
|
app_name => 'Swagger Petstore',
|
||||||
app_version => '1.0.0',
|
app_version => '1.0.0',
|
||||||
generated_date => '2015-11-13T20:46:43.271Z',
|
generated_date => '2015-11-20T17:35:18.902+08:00',
|
||||||
generator_class => 'class io.swagger.codegen.languages.PerlClientCodegen',
|
generator_class => 'class io.swagger.codegen.languages.PerlClientCodegen',
|
||||||
} },
|
} },
|
||||||
documentation => 'Information about the application version and the codegen codebase version'
|
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
|
=over 4
|
||||||
|
|
||||||
=item Build date: 2015-11-13T20:46:43.271Z
|
=item Build date: 2015-11-20T17:35:18.902+08:00
|
||||||
|
|
||||||
=item Build package: class io.swagger.codegen.languages.PerlClientCodegen
|
=item Build package: class io.swagger.codegen.languages.PerlClientCodegen
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user