Skip to content

Commit bda93e6

Browse files
author
Larry Bordowitz
committed
Ran petstore codegen
1 parent c22a470 commit bda93e6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+537
-198
lines changed

samples/client/petstore-security-test/perl/README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -88,37 +88,37 @@ you are accessing. Usually `prefix` and `in` will be determined by the code gene
8888
the spec and you will not need to set them at run time. If not, `in` will
8989
default to 'head' and `prefix` to the empty string.
9090

91-
The tokens will be placed in the `WWW::SwaggerClient::Configuration` namespace
91+
The tokens will be placed in a L<WWW::SwaggerClient::Configuration> instance
9292
as follows, but you don't need to know about this.
9393

94-
- `$WWW::SwaggerClient::Configuration::username`
94+
- `$cfg->{username}`
9595

9696
String. The username for basic auth.
9797

98-
- `$WWW::SwaggerClient::Configuration::password`
98+
- `$cfg->{password}`
9999

100100
String. The password for basic auth.
101101

102-
- `$WWW::SwaggerClient::Configuration::api_key`
102+
- `$cfg->{api_key}`
103103

104104
Hashref. Keyed on the name of each key (there can be multiple tokens).
105105

106-
$WWW::SwaggerClient::Configuration::api_key = {
106+
$cfg->{api_key} = {
107107
secretKey => 'aaaabbbbccccdddd',
108108
anotherKey => '1111222233334444',
109109
};
110110

111-
- `$WWW::SwaggerClient::Configuration::api_key_prefix`
111+
- `$cfg->{api_key_prefix}`
112112

113113
Hashref. Keyed on the name of each key (there can be multiple tokens). Note not
114114
all api keys require a prefix.
115115

116-
$WWW::SwaggerClient::Configuration::api_key_prefix = {
116+
$cfg->{api_key_prefix} = {
117117
secretKey => 'string',
118118
anotherKey => 'same or some other string',
119119
};
120120

121-
- `$WWW::SwaggerClient::Configuration::access_token`
121+
- `$cfg->{access_token}`
122122

123123
String. The OAuth access token.
124124

@@ -127,8 +127,7 @@ as follows, but you don't need to know about this.
127127
## `base_url`
128128

129129
The generated code has the `base_url` already set as a default value. This method
130-
returns (and optionally sets, but only if the API client has not been
131-
created yet) the current value of `base_url`.
130+
returns the current value of `base_url`.
132131

133132
## `api_factory`
134133

@@ -247,10 +246,11 @@ use WWW::SwaggerClient::Object::ModelReturn;
247246
248247
# for displaying the API response data
249248
use Data::Dumper;
250-
use WWW::SwaggerClient::Configuration;
251249
use WWW::SwaggerClient::;
252250
253-
my $api_instance = WWW::SwaggerClient::FakeApi->new();
251+
my $api_instance = WWW::SwaggerClient::->new(
252+
);
253+
254254
my $test code inject */ &#39; &quot; &#x3D;end __ \r\n \n \r = 'test code inject */ ' " =end __ \r\n \n \r_example'; # string | To test code injection */ ' \" =_end -- \\r\\n \\n \\r
255255
256256
eval {

samples/client/petstore-security-test/perl/deep_module_test/README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -88,37 +88,37 @@ you are accessing. Usually `prefix` and `in` will be determined by the code gene
8888
the spec and you will not need to set them at run time. If not, `in` will
8989
default to 'head' and `prefix` to the empty string.
9090

91-
The tokens will be placed in the `Something::Deep::Configuration` namespace
91+
The tokens will be placed in a L<Something::Deep::Configuration> instance
9292
as follows, but you don't need to know about this.
9393

94-
- `$Something::Deep::Configuration::username`
94+
- `$cfg->{username}`
9595

9696
String. The username for basic auth.
9797

98-
- `$Something::Deep::Configuration::password`
98+
- `$cfg->{password}`
9999

100100
String. The password for basic auth.
101101

102-
- `$Something::Deep::Configuration::api_key`
102+
- `$cfg->{api_key}`
103103

104104
Hashref. Keyed on the name of each key (there can be multiple tokens).
105105

106-
$Something::Deep::Configuration::api_key = {
106+
$cfg->{api_key} = {
107107
secretKey => 'aaaabbbbccccdddd',
108108
anotherKey => '1111222233334444',
109109
};
110110

111-
- `$Something::Deep::Configuration::api_key_prefix`
111+
- `$cfg->{api_key_prefix}`
112112

113113
Hashref. Keyed on the name of each key (there can be multiple tokens). Note not
114114
all api keys require a prefix.
115115

116-
$Something::Deep::Configuration::api_key_prefix = {
116+
$cfg->{api_key_prefix} = {
117117
secretKey => 'string',
118118
anotherKey => 'same or some other string',
119119
};
120120

121-
- `$Something::Deep::Configuration::access_token`
121+
- `$cfg->{access_token}`
122122

123123
String. The OAuth access token.
124124

@@ -127,8 +127,7 @@ as follows, but you don't need to know about this.
127127
## `base_url`
128128

129129
The generated code has the `base_url` already set as a default value. This method
130-
returns (and optionally sets, but only if the API client has not been
131-
created yet) the current value of `base_url`.
130+
returns the current value of `base_url`.
132131

133132
## `api_factory`
134133

@@ -247,10 +246,11 @@ use Something::Deep::Object::ModelReturn;
247246
248247
# for displaying the API response data
249248
use Data::Dumper;
250-
use Something::Deep::Configuration;
251249
use Something::Deep::;
252250
253-
my $api_instance = Something::Deep::FakeApi->new();
251+
my $api_instance = Something::Deep::->new(
252+
);
253+
254254
my $test code inject */ &#39; &quot; &#x3D;end __ \r\n \n \r = 'test code inject */ ' " =end __ \r\n \n \r_example'; # string | To test code injection */ ' \" =_end -- \\r\\n \\n \\r
255255
256256
eval {

samples/client/petstore-security-test/perl/deep_module_test/docs/FakeApi.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ To test code injection */ ' \" =_end -- \\r\\n \\n \\r
2020
### Example
2121
```perl
2222
use Data::Dumper;
23-
use Something::Deep::Configuration;
2423
use Something::Deep::FakeApi;
24+
my $api_instance = Something::Deep::FakeApi->new(
25+
);
2526

26-
my $api_instance = Something::Deep::FakeApi->new();
2727
my $test code inject */ &#39; &quot; &#x3D;end __ \r\n \n \r = 'test code inject */ ' " =end __ \r\n \n \r_example'; # string | To test code injection */ ' \" =_end -- \\r\\n \\n \\r
2828

2929
eval {

samples/client/petstore-security-test/perl/deep_module_test/lib/Something/Deep/ApiClient.pm

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,25 @@ use Module::Runtime qw(use_module);
3939

4040
use Something::Deep::Configuration;
4141

42-
use base 'Class::Singleton';
4342

44-
sub _new_instance
45-
{
43+
sub new {
4644
my $class = shift;
45+
46+
my $config;
47+
if ( $_[0] && ref $_[0] && ref $_[0] eq 'Something::Deep::Configuration' ) {
48+
$config = $_[0];
49+
} else {
50+
$config = Something::Deep::Configuration->new(@_);
51+
}
52+
4753
my (%args) = (
4854
'ua' => LWP::UserAgent->new,
49-
'base_url' => 'https://petstore.swagger.io */ ' \" =_end -- \\r\\n \\n \\r/v2 */ ' \" =_end -- \\r\\n \\n \\r',
50-
@_
55+
'config' => $config,
5156
);
5257

5358
return bless \%args, $class;
5459
}
5560

56-
sub _cfg {'Something::Deep::Configuration'}
57-
5861
# Set the user agent of the API client
5962
#
6063
# @param string $user_agent The user agent of the API client
@@ -91,7 +94,7 @@ sub call_api {
9194
$self->update_params_for_auth($header_params, $query_params, $auth_settings);
9295

9396

94-
my $_url = $self->{base_url} . $resource_path;
97+
my $_url = $self->{config}{base_url} . $resource_path;
9598

9699
# build query
97100
if (%$query_params) {
@@ -138,8 +141,8 @@ sub call_api {
138141
else {
139142
}
140143

141-
$self->{ua}->timeout($self->{http_timeout} || $Something::Deep::Configuration::http_timeout);
142-
$self->{ua}->agent($self->{http_user_agent} || $Something::Deep::Configuration::http_user_agent);
144+
$self->{ua}->timeout($self->{http_timeout} || $self->{config}{http_timeout});
145+
$self->{ua}->agent($self->{http_user_agent} || $self->{config}{http_user_agent});
143146

144147
$log->debugf("REQUEST: %s", $_request->as_string);
145148
my $_response = $self->{ua}->request($_request);
@@ -313,11 +316,11 @@ sub get_api_key_with_prefix
313316
{
314317
my ($self, $key_name) = @_;
315318

316-
my $api_key = $Something::Deep::Configuration::api_key->{$key_name};
319+
my $api_key = $self->{config}{api_key}{$key_name};
317320

318321
return unless $api_key;
319322

320-
my $prefix = $Something::Deep::Configuration::api_key_prefix->{$key_name};
323+
my $prefix = $self->{config}{api_key_prefix}{$key_name};
321324
return $prefix ? "$prefix $api_key" : $api_key;
322325
}
323326

@@ -347,8 +350,8 @@ sub update_params_for_auth {
347350
}
348351
elsif ($auth eq 'petstore_auth') {
349352

350-
if ($Something::Deep::Configuration::access_token) {
351-
$header_params->{'Authorization'} = 'Bearer ' . $Something::Deep::Configuration::access_token;
353+
if ($self->{config}{access_token}) {
354+
$header_params->{'Authorization'} = 'Bearer ' . $self->{config}{access_token};
352355
}
353356
}
354357
else {
@@ -364,7 +367,7 @@ elsif ($auth eq 'petstore_auth') {
364367
sub _global_auth_setup {
365368
my ($self, $header_params, $query_params) = @_;
366369

367-
my $tokens = $self->_cfg->get_tokens;
370+
my $tokens = $self->{config}->get_tokens;
368371
return unless keys %$tokens;
369372

370373
# basic

samples/client/petstore-security-test/perl/deep_module_test/lib/Something/Deep/ApiFactory.pm

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,19 +62,28 @@ my %_apis = map { $_ =~ /^Something::Deep::(.*)$/; $1 => $_ }
6262
grep {$_ =~ /Api$/}
6363
usesub 'Something::Deep';
6464

65-
=head1 new()
65+
=head1 new($api_client)
6666
67-
Any parameters are optional, and are passed to and stored on the api_client object.
68-
69-
base_url: (optional)
70-
supply this to change the default base URL taken from the Swagger definition.
67+
create a new Something::Deep::ApiFactory instance with the given Something::Deep::ApiClient instance.
68+
69+
=head1 new(%paramters)
70+
71+
Any parameters are optional, and are passed to and stored on the api_client object.
7172
73+
See L<Something::Deep::ApiClient> and L<Something::Deep::Configuration> for valid paramters
74+
7275
=cut
7376

7477
sub new {
75-
my ($class, %p) = (shift, @_);
76-
$p{api_client} = Something::Deep::ApiClient->instance(%p);
77-
return bless \%p, $class;
78+
my ($class) = shift;
79+
80+
my $api_client;
81+
if ($_[0] && ref $_[0] && ref $_[0] eq 'Something::Deep::ApiClient' ) {
82+
$api_client = $_[0];
83+
} else {
84+
$api_client = Something::Deep::ApiClient->new(@_);
85+
}
86+
bless { api_client => $api_client }, $class;
7887
}
7988

8089
=head1 get_api($which)
@@ -91,7 +100,7 @@ sub get_api {
91100
my ($self, $which) = @_;
92101
croak "API not specified" unless $which;
93102
my $api_class = $_apis{"${which}Api"} || croak "No known API for '$which'";
94-
return $api_class->new(api_client => $self->api_client);
103+
return $api_class->new($self->api_client);
95104
}
96105

97106
=head1 api_client()

0 commit comments

Comments
 (0)