mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-07 19:08:52 +00:00
Minor cleanup
This commit is contained in:
parent
5f61d5465e
commit
40f8012cbc
@ -21,9 +21,7 @@ use WWW::{{moduleName}}::ApiClient;
|
||||
|
||||
use WWW::{{moduleName}}::ApiFactory;
|
||||
|
||||
my $api_factory = WWW::{{moduleName}}::ApiFactory->new( base_url => 'http://petstore.swagger.io/v2',
|
||||
..., # other args for ApiClient constructor
|
||||
);
|
||||
my $api_factory = WWW::{{moduleName}}::ApiFactory->new( ... ); # any args for ApiClient constructor
|
||||
|
||||
# later...
|
||||
my $pet_api = $api_factory->get_api('Pet');
|
||||
@ -47,23 +45,11 @@ my %_apis = map { $_ =~ /^WWW::{{moduleName}}::(.*)$/; $1 => $_ }
|
||||
|
||||
=head1 new()
|
||||
|
||||
All parameters are optional, and are passed to and stored on the api_client object.
|
||||
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.
|
||||
|
||||
auth_setup_handler_object: (optional)
|
||||
An object (or class name) that implements an auth_setup_handler() method.
|
||||
|
||||
If set, the auth_setup_handler() method will be called on the object, and
|
||||
passed a hashref with keys: api_client, query_params, header_params, auth_settings.
|
||||
|
||||
The method should implement the required auth policy, for example, by setting
|
||||
secret keys in the header, or username and password in the URL, etc.
|
||||
|
||||
This is only necessary when the API specification itself does not describe
|
||||
authentication.
|
||||
|
||||
=cut
|
||||
|
||||
sub new {
|
||||
|
@ -22,7 +22,7 @@ use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||
|
||||
__PACKAGE__->mk_classdata('attribute_map' => {});
|
||||
__PACKAGE__->mk_classdata('swagger_types' => {});
|
||||
__PACKAGE__->mk_classdata('method_documentation' => {}); # TODO
|
||||
__PACKAGE__->mk_classdata('method_documentation' => {});
|
||||
__PACKAGE__->mk_classdata('class_documentation' => {});
|
||||
|
||||
# new object
|
||||
|
@ -136,7 +136,7 @@ Returns an API factory object. You probably won't need to call this directly.
|
||||
|
||||
$self->api_factory('Pet'); # returns a WWW::{{moduleName}}::PetApi instance
|
||||
|
||||
$self->pet_api; # the same
|
||||
$self->pet_api; # the same
|
||||
|
||||
# MISSING METHODS
|
||||
|
||||
@ -207,9 +207,9 @@ namespace is used if you don't supply your own class.
|
||||
|
||||
Additional documentation for each class and method may be provided by the Swagger
|
||||
spec. If so, this is available via the `class_documentation()` and
|
||||
`method_documentation()` methods on each generated API and class:
|
||||
`method_documentation()` methods on each generated object class, and the
|
||||
`method_documentation()` method on the endpoint API classes:
|
||||
|
||||
my $cdoc = $api->pet_api->class_documentation;
|
||||
my $cmdoc = $api->pet_api->method_documentation->{$method_name};
|
||||
|
||||
my $odoc = $api->get_pet_by_id->(pet_id => $pet_id)->class_documentation;
|
||||
|
@ -8,40 +8,40 @@ use Log::Any qw($log);
|
||||
use WWW::{{moduleName}}::ApiFactory;
|
||||
|
||||
has base_url => ( is => 'ro',
|
||||
required => 0,
|
||||
isa => 'Str',
|
||||
documentation => 'Root of the server that requests are sent to',
|
||||
);
|
||||
required => 0,
|
||||
isa => 'Str',
|
||||
documentation => 'Root of the server that requests are sent to',
|
||||
);
|
||||
|
||||
has api_factory => ( is => 'ro',
|
||||
isa => 'WWW::{{moduleName}}::ApiFactory',
|
||||
builder => '_build_af',
|
||||
lazy => 1,
|
||||
documentation => 'Builds an instance of the endpoint API class',
|
||||
);
|
||||
isa => 'WWW::{{moduleName}}::ApiFactory',
|
||||
builder => '_build_af',
|
||||
lazy => 1,
|
||||
documentation => 'Builds an instance of the endpoint API class',
|
||||
);
|
||||
|
||||
has tokens => ( is => 'ro',
|
||||
isa => 'HashRef',
|
||||
required => 0,
|
||||
default => sub { {} },
|
||||
documentation => 'The auth tokens required by the application - basic, OAuth and/or API key(s)',
|
||||
);
|
||||
isa => 'HashRef',
|
||||
required => 0,
|
||||
default => sub { {} },
|
||||
documentation => 'The auth tokens required by the application - basic, OAuth and/or API key(s)',
|
||||
);
|
||||
|
||||
has _cfg => ( is => 'ro',
|
||||
isa => 'Str',
|
||||
default => 'WWW::{{moduleName}}::Configuration',
|
||||
);
|
||||
isa => 'Str',
|
||||
default => 'WWW::{{moduleName}}::Configuration',
|
||||
);
|
||||
|
||||
has version_info => ( is => 'ro',
|
||||
isa => 'HashRef',
|
||||
default => sub { {
|
||||
app_name => '{{appName}}',
|
||||
app_version => '{{appVersion}}',
|
||||
generated_date => '{{generatedDate}}',
|
||||
generator_class => '{{generatorClass}}',
|
||||
} },
|
||||
documentation => 'Information about the application version and the codegen codebase version'
|
||||
);
|
||||
isa => 'HashRef',
|
||||
default => sub { {
|
||||
app_name => '{{appName}}',
|
||||
app_version => '{{appVersion}}',
|
||||
generated_date => '{{generatedDate}}',
|
||||
generator_class => '{{generatorClass}}',
|
||||
} },
|
||||
documentation => 'Information about the application version and the codegen codebase version'
|
||||
);
|
||||
|
||||
sub BUILD {
|
||||
my $self = shift;
|
||||
@ -68,20 +68,20 @@ sub BUILD {
|
||||
}
|
||||
}
|
||||
|
||||
# build the flattened API
|
||||
foreach my $api_name ($self->api_factory->apis_available) {
|
||||
my $att_name = sprintf "%s_api", lc($api_name);
|
||||
my $api_class = $self->api_factory->classname_for($api_name);
|
||||
my @delegated = grep { $delegates{$_}->[0]->{api_name} eq $api_name } keys %delegates;
|
||||
$log->debugf("Adding API: '%s' handles %s", $att_name, join ', ', @delegated);
|
||||
$self->meta->add_attribute( $att_name => (
|
||||
is => 'ro',
|
||||
isa => $api_class,
|
||||
default => sub {$self->api_factory->get_api($api_name)},
|
||||
lazy => 1,
|
||||
handles => \@delegated,
|
||||
) );
|
||||
}
|
||||
# build the flattened API
|
||||
foreach my $api_name ($self->api_factory->apis_available) {
|
||||
my $att_name = sprintf "%s_api", lc($api_name);
|
||||
my $api_class = $self->api_factory->classname_for($api_name);
|
||||
my @delegated = grep { $delegates{$_}->[0]->{api_name} eq $api_name } keys %delegates;
|
||||
$log->debugf("Adding API: '%s' handles %s", $att_name, join ', ', @delegated);
|
||||
$self->meta->add_attribute( $att_name => (
|
||||
is => 'ro',
|
||||
isa => $api_class,
|
||||
default => sub {$self->api_factory->get_api($api_name)},
|
||||
lazy => 1,
|
||||
handles => \@delegated,
|
||||
) );
|
||||
}
|
||||
}
|
||||
|
||||
sub _build_af {
|
||||
@ -235,10 +235,10 @@ created yet) the current value of C<base_url>.
|
||||
=head2 C<api_factory>
|
||||
|
||||
Returns an API factory object. You probably won't need to call this directly.
|
||||
|
||||
$self->api_factory('Pet'); # returns a WWW::{{moduleName}}::PetApi instance
|
||||
|
||||
$self->pet_api; # the same
|
||||
$self->api_factory('Pet'); # returns a WWW::{{moduleName}}::PetApi instance
|
||||
|
||||
$self->pet_api; # the same
|
||||
|
||||
=head1 MISSING METHODS
|
||||
|
||||
@ -308,9 +308,9 @@ namespace is used if you don't supply your own class.
|
||||
|
||||
Additional documentation for each class and method may be provided by the Swagger
|
||||
spec. If so, this is available via the C<class_documentation()> and
|
||||
C<method_documentation()> methods on each generated API and class:
|
||||
C<method_documentation()> methods on each generated object class, and the
|
||||
C<method_documentation()> method on the endpoint API classes:
|
||||
|
||||
my $cdoc = $api->pet_api->class_documentation;
|
||||
my $cmdoc = $api->pet_api->method_documentation->{$method_name};
|
||||
|
||||
my $odoc = $api->get_pet_by_id->(pet_id => $pet_id)->class_documentation;
|
||||
|
@ -61,19 +61,20 @@ sub new {
|
||||
{{#allParams}}# @param {{dataType}} ${{paramName}} {{description}} {{#required}}(required){{/required}}{{^required}}(optional){{/required}}
|
||||
{{/allParams}}
|
||||
{
|
||||
my $params = {
|
||||
my $params = {
|
||||
{{#allParams}}
|
||||
'{{paramName}}' => {
|
||||
data_type => '{{dataType}}',
|
||||
description => '{{description}}',
|
||||
required => {{#required}}'1'{{/required}}{{^required}}'0'{{/required}},
|
||||
},
|
||||
'{{paramName}}' => {
|
||||
data_type => '{{dataType}}',
|
||||
description => '{{description}}',
|
||||
required => {{#required}}'1'{{/required}}{{^required}}'0'{{/required}},
|
||||
},
|
||||
{{/allParams}}
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ {{nickname}} } = { summary => '{{summary}}',
|
||||
params => $params,
|
||||
returns => {{#returnType}}'{{{returnType}}}'{{/returnType}}{{^returnType}}undef{{/returnType}},
|
||||
};
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ {{nickname}} } = {
|
||||
summary => '{{summary}}',
|
||||
params => $params,
|
||||
returns => {{#returnType}}'{{{returnType}}}'{{/returnType}}{{^returnType}}undef{{/returnType}},
|
||||
};
|
||||
}
|
||||
# @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}
|
||||
#
|
||||
|
@ -8,7 +8,7 @@ My::App
|
||||
|
||||
Automatically generated by the Perl Swagger Codegen project:
|
||||
|
||||
- Build date: 2015-11-13T18:23:57.025Z
|
||||
- Build date: 2015-11-13T20:46:43.271Z
|
||||
- Build package: class io.swagger.codegen.languages.PerlClientCodegen
|
||||
- Codegen version:
|
||||
|
||||
|
@ -21,9 +21,7 @@ use WWW::SwaggerClient::ApiClient;
|
||||
|
||||
use WWW::SwaggerClient::ApiFactory;
|
||||
|
||||
my $api_factory = WWW::SwaggerClient::ApiFactory->new( base_url => 'http://petstore.swagger.io/v2',
|
||||
..., # other args for ApiClient constructor
|
||||
);
|
||||
my $api_factory = WWW::SwaggerClient::ApiFactory->new( ... ); # any args for ApiClient constructor
|
||||
|
||||
# later...
|
||||
my $pet_api = $api_factory->get_api('Pet');
|
||||
@ -47,23 +45,11 @@ my %_apis = map { $_ =~ /^WWW::SwaggerClient::(.*)$/; $1 => $_ }
|
||||
|
||||
=head1 new()
|
||||
|
||||
All parameters are optional, and are passed to and stored on the api_client object.
|
||||
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.
|
||||
|
||||
auth_setup_handler_object: (optional)
|
||||
An object (or class name) that implements an auth_setup_handler() method.
|
||||
|
||||
If set, the auth_setup_handler() method will be called on the object, and
|
||||
passed a hashref with keys: api_client, query_params, header_params, auth_settings.
|
||||
|
||||
The method should implement the required auth policy, for example, by setting
|
||||
secret keys in the header, or username and password in the URL, etc.
|
||||
|
||||
This is only necessary when the API specification itself does not describe
|
||||
authentication.
|
||||
|
||||
=cut
|
||||
|
||||
sub new {
|
||||
|
@ -22,7 +22,7 @@ use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||
|
||||
__PACKAGE__->mk_classdata('attribute_map' => {});
|
||||
__PACKAGE__->mk_classdata('swagger_types' => {});
|
||||
__PACKAGE__->mk_classdata('method_documentation' => {}); # TODO
|
||||
__PACKAGE__->mk_classdata('method_documentation' => {});
|
||||
__PACKAGE__->mk_classdata('class_documentation' => {});
|
||||
|
||||
# new object
|
||||
|
@ -58,17 +58,18 @@ sub new {
|
||||
#
|
||||
# @param Pet $body Pet object that needs to be added to the store (optional)
|
||||
{
|
||||
my $params = {
|
||||
'body' => {
|
||||
data_type => 'Pet',
|
||||
description => 'Pet object that needs to be added to the store',
|
||||
required => '0',
|
||||
},
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ update_pet } = { summary => 'Update an existing pet',
|
||||
params => $params,
|
||||
returns => undef,
|
||||
};
|
||||
my $params = {
|
||||
'body' => {
|
||||
data_type => 'Pet',
|
||||
description => 'Pet object that needs to be added to the store',
|
||||
required => '0',
|
||||
},
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ update_pet } = {
|
||||
summary => 'Update an existing pet',
|
||||
params => $params,
|
||||
returns => undef,
|
||||
};
|
||||
}
|
||||
# @return void
|
||||
#
|
||||
@ -122,17 +123,18 @@ sub update_pet {
|
||||
#
|
||||
# @param Pet $body Pet object that needs to be added to the store (optional)
|
||||
{
|
||||
my $params = {
|
||||
'body' => {
|
||||
data_type => 'Pet',
|
||||
description => 'Pet object that needs to be added to the store',
|
||||
required => '0',
|
||||
},
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ add_pet } = { summary => 'Add a new pet to the store',
|
||||
params => $params,
|
||||
returns => undef,
|
||||
};
|
||||
my $params = {
|
||||
'body' => {
|
||||
data_type => 'Pet',
|
||||
description => 'Pet object that needs to be added to the store',
|
||||
required => '0',
|
||||
},
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ add_pet } = {
|
||||
summary => 'Add a new pet to the store',
|
||||
params => $params,
|
||||
returns => undef,
|
||||
};
|
||||
}
|
||||
# @return void
|
||||
#
|
||||
@ -186,17 +188,18 @@ sub add_pet {
|
||||
#
|
||||
# @param ARRAY[string] $status Status values that need to be considered for filter (optional)
|
||||
{
|
||||
my $params = {
|
||||
'status' => {
|
||||
data_type => 'ARRAY[string]',
|
||||
description => 'Status values that need to be considered for filter',
|
||||
required => '0',
|
||||
},
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ find_pets_by_status } = { summary => 'Finds Pets by status',
|
||||
params => $params,
|
||||
returns => 'ARRAY[Pet]',
|
||||
};
|
||||
my $params = {
|
||||
'status' => {
|
||||
data_type => 'ARRAY[string]',
|
||||
description => 'Status values that need to be considered for filter',
|
||||
required => '0',
|
||||
},
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ find_pets_by_status } = {
|
||||
summary => 'Finds Pets by status',
|
||||
params => $params,
|
||||
returns => 'ARRAY[Pet]',
|
||||
};
|
||||
}
|
||||
# @return ARRAY[Pet]
|
||||
#
|
||||
@ -253,17 +256,18 @@ sub find_pets_by_status {
|
||||
#
|
||||
# @param ARRAY[string] $tags Tags to filter by (optional)
|
||||
{
|
||||
my $params = {
|
||||
'tags' => {
|
||||
data_type => 'ARRAY[string]',
|
||||
description => 'Tags to filter by',
|
||||
required => '0',
|
||||
},
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ find_pets_by_tags } = { summary => 'Finds Pets by tags',
|
||||
params => $params,
|
||||
returns => 'ARRAY[Pet]',
|
||||
};
|
||||
my $params = {
|
||||
'tags' => {
|
||||
data_type => 'ARRAY[string]',
|
||||
description => 'Tags to filter by',
|
||||
required => '0',
|
||||
},
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ find_pets_by_tags } = {
|
||||
summary => 'Finds Pets by tags',
|
||||
params => $params,
|
||||
returns => 'ARRAY[Pet]',
|
||||
};
|
||||
}
|
||||
# @return ARRAY[Pet]
|
||||
#
|
||||
@ -320,17 +324,18 @@ sub find_pets_by_tags {
|
||||
#
|
||||
# @param int $pet_id ID of pet that needs to be fetched (required)
|
||||
{
|
||||
my $params = {
|
||||
'pet_id' => {
|
||||
data_type => 'int',
|
||||
description => 'ID of pet that needs to be fetched',
|
||||
required => '1',
|
||||
},
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ get_pet_by_id } = { summary => 'Find pet by ID',
|
||||
params => $params,
|
||||
returns => 'Pet',
|
||||
};
|
||||
my $params = {
|
||||
'pet_id' => {
|
||||
data_type => 'int',
|
||||
description => 'ID of pet that needs to be fetched',
|
||||
required => '1',
|
||||
},
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ get_pet_by_id } = {
|
||||
summary => 'Find pet by ID',
|
||||
params => $params,
|
||||
returns => 'Pet',
|
||||
};
|
||||
}
|
||||
# @return Pet
|
||||
#
|
||||
@ -396,27 +401,28 @@ sub get_pet_by_id {
|
||||
# @param string $name Updated name of the pet (optional)
|
||||
# @param string $status Updated status of the pet (optional)
|
||||
{
|
||||
my $params = {
|
||||
'pet_id' => {
|
||||
data_type => 'string',
|
||||
description => 'ID of pet that needs to be updated',
|
||||
required => '1',
|
||||
},
|
||||
'name' => {
|
||||
data_type => 'string',
|
||||
description => 'Updated name of the pet',
|
||||
required => '0',
|
||||
},
|
||||
'status' => {
|
||||
data_type => 'string',
|
||||
description => 'Updated status of the pet',
|
||||
required => '0',
|
||||
},
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ update_pet_with_form } = { summary => 'Updates a pet in the store with form data',
|
||||
params => $params,
|
||||
returns => undef,
|
||||
};
|
||||
my $params = {
|
||||
'pet_id' => {
|
||||
data_type => 'string',
|
||||
description => 'ID of pet that needs to be updated',
|
||||
required => '1',
|
||||
},
|
||||
'name' => {
|
||||
data_type => 'string',
|
||||
description => 'Updated name of the pet',
|
||||
required => '0',
|
||||
},
|
||||
'status' => {
|
||||
data_type => 'string',
|
||||
description => 'Updated status of the pet',
|
||||
required => '0',
|
||||
},
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ update_pet_with_form } = {
|
||||
summary => 'Updates a pet in the store with form data',
|
||||
params => $params,
|
||||
returns => undef,
|
||||
};
|
||||
}
|
||||
# @return void
|
||||
#
|
||||
@ -488,22 +494,23 @@ sub update_pet_with_form {
|
||||
# @param int $pet_id Pet id to delete (required)
|
||||
# @param string $api_key (optional)
|
||||
{
|
||||
my $params = {
|
||||
'pet_id' => {
|
||||
data_type => 'int',
|
||||
description => 'Pet id to delete',
|
||||
required => '1',
|
||||
},
|
||||
'api_key' => {
|
||||
data_type => 'string',
|
||||
description => '',
|
||||
required => '0',
|
||||
},
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ delete_pet } = { summary => 'Deletes a pet',
|
||||
params => $params,
|
||||
returns => undef,
|
||||
};
|
||||
my $params = {
|
||||
'pet_id' => {
|
||||
data_type => 'int',
|
||||
description => 'Pet id to delete',
|
||||
required => '1',
|
||||
},
|
||||
'api_key' => {
|
||||
data_type => 'string',
|
||||
description => '',
|
||||
required => '0',
|
||||
},
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ delete_pet } = {
|
||||
summary => 'Deletes a pet',
|
||||
params => $params,
|
||||
returns => undef,
|
||||
};
|
||||
}
|
||||
# @return void
|
||||
#
|
||||
@ -569,27 +576,28 @@ sub delete_pet {
|
||||
# @param string $additional_metadata Additional data to pass to server (optional)
|
||||
# @param file $file file to upload (optional)
|
||||
{
|
||||
my $params = {
|
||||
'pet_id' => {
|
||||
data_type => 'int',
|
||||
description => 'ID of pet to update',
|
||||
required => '1',
|
||||
},
|
||||
'additional_metadata' => {
|
||||
data_type => 'string',
|
||||
description => 'Additional data to pass to server',
|
||||
required => '0',
|
||||
},
|
||||
'file' => {
|
||||
data_type => 'file',
|
||||
description => 'file to upload',
|
||||
required => '0',
|
||||
},
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ upload_file } = { summary => 'uploads an image',
|
||||
params => $params,
|
||||
returns => undef,
|
||||
};
|
||||
my $params = {
|
||||
'pet_id' => {
|
||||
data_type => 'int',
|
||||
description => 'ID of pet to update',
|
||||
required => '1',
|
||||
},
|
||||
'additional_metadata' => {
|
||||
data_type => 'string',
|
||||
description => 'Additional data to pass to server',
|
||||
required => '0',
|
||||
},
|
||||
'file' => {
|
||||
data_type => 'file',
|
||||
description => 'file to upload',
|
||||
required => '0',
|
||||
},
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ upload_file } = {
|
||||
summary => 'uploads an image',
|
||||
params => $params,
|
||||
returns => undef,
|
||||
};
|
||||
}
|
||||
# @return void
|
||||
#
|
||||
|
@ -8,40 +8,40 @@ use Log::Any qw($log);
|
||||
use WWW::SwaggerClient::ApiFactory;
|
||||
|
||||
has base_url => ( is => 'ro',
|
||||
required => 0,
|
||||
isa => 'Str',
|
||||
documentation => 'Root of the server that requests are sent to',
|
||||
);
|
||||
required => 0,
|
||||
isa => 'Str',
|
||||
documentation => 'Root of the server that requests are sent to',
|
||||
);
|
||||
|
||||
has api_factory => ( is => 'ro',
|
||||
isa => 'WWW::SwaggerClient::ApiFactory',
|
||||
builder => '_build_af',
|
||||
lazy => 1,
|
||||
documentation => 'Builds an instance of the endpoint API class',
|
||||
);
|
||||
isa => 'WWW::SwaggerClient::ApiFactory',
|
||||
builder => '_build_af',
|
||||
lazy => 1,
|
||||
documentation => 'Builds an instance of the endpoint API class',
|
||||
);
|
||||
|
||||
has tokens => ( is => 'ro',
|
||||
isa => 'HashRef',
|
||||
required => 0,
|
||||
default => sub { {} },
|
||||
documentation => 'The auth tokens required by the application - basic, OAuth and/or API key(s)',
|
||||
);
|
||||
isa => 'HashRef',
|
||||
required => 0,
|
||||
default => sub { {} },
|
||||
documentation => 'The auth tokens required by the application - basic, OAuth and/or API key(s)',
|
||||
);
|
||||
|
||||
has _cfg => ( is => 'ro',
|
||||
isa => 'Str',
|
||||
default => 'WWW::SwaggerClient::Configuration',
|
||||
);
|
||||
isa => 'Str',
|
||||
default => 'WWW::SwaggerClient::Configuration',
|
||||
);
|
||||
|
||||
has version_info => ( is => 'ro',
|
||||
isa => 'HashRef',
|
||||
default => sub { {
|
||||
app_name => 'Swagger Petstore',
|
||||
app_version => '1.0.0',
|
||||
generated_date => '2015-11-13T18:23:57.025Z',
|
||||
generator_class => 'class io.swagger.codegen.languages.PerlClientCodegen',
|
||||
} },
|
||||
documentation => 'Information about the application version and the codegen codebase version'
|
||||
);
|
||||
isa => 'HashRef',
|
||||
default => sub { {
|
||||
app_name => 'Swagger Petstore',
|
||||
app_version => '1.0.0',
|
||||
generated_date => '2015-11-13T20:46:43.271Z',
|
||||
generator_class => 'class io.swagger.codegen.languages.PerlClientCodegen',
|
||||
} },
|
||||
documentation => 'Information about the application version and the codegen codebase version'
|
||||
);
|
||||
|
||||
sub BUILD {
|
||||
my $self = shift;
|
||||
@ -68,20 +68,20 @@ sub BUILD {
|
||||
}
|
||||
}
|
||||
|
||||
# build the flattened API
|
||||
foreach my $api_name ($self->api_factory->apis_available) {
|
||||
my $att_name = sprintf "%s_api", lc($api_name);
|
||||
my $api_class = $self->api_factory->classname_for($api_name);
|
||||
my @delegated = grep { $delegates{$_}->[0]->{api_name} eq $api_name } keys %delegates;
|
||||
$log->debugf("Adding API: '%s' handles %s", $att_name, join ', ', @delegated);
|
||||
$self->meta->add_attribute( $att_name => (
|
||||
is => 'ro',
|
||||
isa => $api_class,
|
||||
default => sub {$self->api_factory->get_api($api_name)},
|
||||
lazy => 1,
|
||||
handles => \@delegated,
|
||||
) );
|
||||
}
|
||||
# build the flattened API
|
||||
foreach my $api_name ($self->api_factory->apis_available) {
|
||||
my $att_name = sprintf "%s_api", lc($api_name);
|
||||
my $api_class = $self->api_factory->classname_for($api_name);
|
||||
my @delegated = grep { $delegates{$_}->[0]->{api_name} eq $api_name } keys %delegates;
|
||||
$log->debugf("Adding API: '%s' handles %s", $att_name, join ', ', @delegated);
|
||||
$self->meta->add_attribute( $att_name => (
|
||||
is => 'ro',
|
||||
isa => $api_class,
|
||||
default => sub {$self->api_factory->get_api($api_name)},
|
||||
lazy => 1,
|
||||
handles => \@delegated,
|
||||
) );
|
||||
}
|
||||
}
|
||||
|
||||
sub _build_af {
|
||||
@ -103,7 +103,7 @@ Automatically generated by the Perl Swagger Codegen project:
|
||||
|
||||
=over 4
|
||||
|
||||
=item Build date: 2015-11-13T18:23:57.025Z
|
||||
=item Build date: 2015-11-13T20:46:43.271Z
|
||||
|
||||
=item Build package: class io.swagger.codegen.languages.PerlClientCodegen
|
||||
|
||||
@ -235,10 +235,10 @@ created yet) the current value of C<base_url>.
|
||||
=head2 C<api_factory>
|
||||
|
||||
Returns an API factory object. You probably won't need to call this directly.
|
||||
|
||||
$self->api_factory('Pet'); # returns a WWW::SwaggerClient::PetApi instance
|
||||
|
||||
$self->pet_api; # the same
|
||||
$self->api_factory('Pet'); # returns a WWW::SwaggerClient::PetApi instance
|
||||
|
||||
$self->pet_api; # the same
|
||||
|
||||
=head1 MISSING METHODS
|
||||
|
||||
@ -308,9 +308,9 @@ namespace is used if you don't supply your own class.
|
||||
|
||||
Additional documentation for each class and method may be provided by the Swagger
|
||||
spec. If so, this is available via the C<class_documentation()> and
|
||||
C<method_documentation()> methods on each generated API and class:
|
||||
C<method_documentation()> methods on each generated object class, and the
|
||||
C<method_documentation()> method on the endpoint API classes:
|
||||
|
||||
my $cdoc = $api->pet_api->class_documentation;
|
||||
my $cmdoc = $api->pet_api->method_documentation->{$method_name};
|
||||
|
||||
my $odoc = $api->get_pet_by_id->(pet_id => $pet_id)->class_documentation;
|
||||
|
@ -57,12 +57,13 @@ sub new {
|
||||
# Returns pet inventories by status
|
||||
#
|
||||
{
|
||||
my $params = {
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ get_inventory } = { summary => 'Returns pet inventories by status',
|
||||
params => $params,
|
||||
returns => 'HASH[string,int]',
|
||||
};
|
||||
my $params = {
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ get_inventory } = {
|
||||
summary => 'Returns pet inventories by status',
|
||||
params => $params,
|
||||
returns => 'HASH[string,int]',
|
||||
};
|
||||
}
|
||||
# @return HASH[string,int]
|
||||
#
|
||||
@ -116,17 +117,18 @@ sub get_inventory {
|
||||
#
|
||||
# @param Order $body order placed for purchasing the pet (optional)
|
||||
{
|
||||
my $params = {
|
||||
'body' => {
|
||||
data_type => 'Order',
|
||||
description => 'order placed for purchasing the pet',
|
||||
required => '0',
|
||||
},
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ place_order } = { summary => 'Place an order for a pet',
|
||||
params => $params,
|
||||
returns => 'Order',
|
||||
};
|
||||
my $params = {
|
||||
'body' => {
|
||||
data_type => 'Order',
|
||||
description => 'order placed for purchasing the pet',
|
||||
required => '0',
|
||||
},
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ place_order } = {
|
||||
summary => 'Place an order for a pet',
|
||||
params => $params,
|
||||
returns => 'Order',
|
||||
};
|
||||
}
|
||||
# @return Order
|
||||
#
|
||||
@ -183,17 +185,18 @@ sub place_order {
|
||||
#
|
||||
# @param string $order_id ID of pet that needs to be fetched (required)
|
||||
{
|
||||
my $params = {
|
||||
'order_id' => {
|
||||
data_type => 'string',
|
||||
description => 'ID of pet that needs to be fetched',
|
||||
required => '1',
|
||||
},
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ get_order_by_id } = { summary => 'Find purchase order by ID',
|
||||
params => $params,
|
||||
returns => 'Order',
|
||||
};
|
||||
my $params = {
|
||||
'order_id' => {
|
||||
data_type => 'string',
|
||||
description => 'ID of pet that needs to be fetched',
|
||||
required => '1',
|
||||
},
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ get_order_by_id } = {
|
||||
summary => 'Find purchase order by ID',
|
||||
params => $params,
|
||||
returns => 'Order',
|
||||
};
|
||||
}
|
||||
# @return Order
|
||||
#
|
||||
@ -257,17 +260,18 @@ sub get_order_by_id {
|
||||
#
|
||||
# @param string $order_id ID of the order that needs to be deleted (required)
|
||||
{
|
||||
my $params = {
|
||||
'order_id' => {
|
||||
data_type => 'string',
|
||||
description => 'ID of the order that needs to be deleted',
|
||||
required => '1',
|
||||
},
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ delete_order } = { summary => 'Delete purchase order by ID',
|
||||
params => $params,
|
||||
returns => undef,
|
||||
};
|
||||
my $params = {
|
||||
'order_id' => {
|
||||
data_type => 'string',
|
||||
description => 'ID of the order that needs to be deleted',
|
||||
required => '1',
|
||||
},
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ delete_order } = {
|
||||
summary => 'Delete purchase order by ID',
|
||||
params => $params,
|
||||
returns => undef,
|
||||
};
|
||||
}
|
||||
# @return void
|
||||
#
|
||||
|
@ -58,17 +58,18 @@ sub new {
|
||||
#
|
||||
# @param User $body Created user object (optional)
|
||||
{
|
||||
my $params = {
|
||||
'body' => {
|
||||
data_type => 'User',
|
||||
description => 'Created user object',
|
||||
required => '0',
|
||||
},
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ create_user } = { summary => 'Create user',
|
||||
params => $params,
|
||||
returns => undef,
|
||||
};
|
||||
my $params = {
|
||||
'body' => {
|
||||
data_type => 'User',
|
||||
description => 'Created user object',
|
||||
required => '0',
|
||||
},
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ create_user } = {
|
||||
summary => 'Create user',
|
||||
params => $params,
|
||||
returns => undef,
|
||||
};
|
||||
}
|
||||
# @return void
|
||||
#
|
||||
@ -122,17 +123,18 @@ sub create_user {
|
||||
#
|
||||
# @param ARRAY[User] $body List of user object (optional)
|
||||
{
|
||||
my $params = {
|
||||
'body' => {
|
||||
data_type => 'ARRAY[User]',
|
||||
description => 'List of user object',
|
||||
required => '0',
|
||||
},
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ create_users_with_array_input } = { summary => 'Creates list of users with given input array',
|
||||
params => $params,
|
||||
returns => undef,
|
||||
};
|
||||
my $params = {
|
||||
'body' => {
|
||||
data_type => 'ARRAY[User]',
|
||||
description => 'List of user object',
|
||||
required => '0',
|
||||
},
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ create_users_with_array_input } = {
|
||||
summary => 'Creates list of users with given input array',
|
||||
params => $params,
|
||||
returns => undef,
|
||||
};
|
||||
}
|
||||
# @return void
|
||||
#
|
||||
@ -186,17 +188,18 @@ sub create_users_with_array_input {
|
||||
#
|
||||
# @param ARRAY[User] $body List of user object (optional)
|
||||
{
|
||||
my $params = {
|
||||
'body' => {
|
||||
data_type => 'ARRAY[User]',
|
||||
description => 'List of user object',
|
||||
required => '0',
|
||||
},
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ create_users_with_list_input } = { summary => 'Creates list of users with given input array',
|
||||
params => $params,
|
||||
returns => undef,
|
||||
};
|
||||
my $params = {
|
||||
'body' => {
|
||||
data_type => 'ARRAY[User]',
|
||||
description => 'List of user object',
|
||||
required => '0',
|
||||
},
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ create_users_with_list_input } = {
|
||||
summary => 'Creates list of users with given input array',
|
||||
params => $params,
|
||||
returns => undef,
|
||||
};
|
||||
}
|
||||
# @return void
|
||||
#
|
||||
@ -251,22 +254,23 @@ sub create_users_with_list_input {
|
||||
# @param string $username The user name for login (optional)
|
||||
# @param string $password The password for login in clear text (optional)
|
||||
{
|
||||
my $params = {
|
||||
'username' => {
|
||||
data_type => 'string',
|
||||
description => 'The user name for login',
|
||||
required => '0',
|
||||
},
|
||||
'password' => {
|
||||
data_type => 'string',
|
||||
description => 'The password for login in clear text',
|
||||
required => '0',
|
||||
},
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ login_user } = { summary => 'Logs user into the system',
|
||||
params => $params,
|
||||
returns => 'string',
|
||||
};
|
||||
my $params = {
|
||||
'username' => {
|
||||
data_type => 'string',
|
||||
description => 'The user name for login',
|
||||
required => '0',
|
||||
},
|
||||
'password' => {
|
||||
data_type => 'string',
|
||||
description => 'The password for login in clear text',
|
||||
required => '0',
|
||||
},
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ login_user } = {
|
||||
summary => 'Logs user into the system',
|
||||
params => $params,
|
||||
returns => 'string',
|
||||
};
|
||||
}
|
||||
# @return string
|
||||
#
|
||||
@ -325,12 +329,13 @@ sub login_user {
|
||||
# Logs out current logged in user session
|
||||
#
|
||||
{
|
||||
my $params = {
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ logout_user } = { summary => 'Logs out current logged in user session',
|
||||
params => $params,
|
||||
returns => undef,
|
||||
};
|
||||
my $params = {
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ logout_user } = {
|
||||
summary => 'Logs out current logged in user session',
|
||||
params => $params,
|
||||
returns => undef,
|
||||
};
|
||||
}
|
||||
# @return void
|
||||
#
|
||||
@ -381,17 +386,18 @@ sub logout_user {
|
||||
#
|
||||
# @param string $username The name that needs to be fetched. Use user1 for testing. (required)
|
||||
{
|
||||
my $params = {
|
||||
'username' => {
|
||||
data_type => 'string',
|
||||
description => 'The name that needs to be fetched. Use user1 for testing.',
|
||||
required => '1',
|
||||
},
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ get_user_by_name } = { summary => 'Get user by user name',
|
||||
params => $params,
|
||||
returns => 'User',
|
||||
};
|
||||
my $params = {
|
||||
'username' => {
|
||||
data_type => 'string',
|
||||
description => 'The name that needs to be fetched. Use user1 for testing.',
|
||||
required => '1',
|
||||
},
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ get_user_by_name } = {
|
||||
summary => 'Get user by user name',
|
||||
params => $params,
|
||||
returns => 'User',
|
||||
};
|
||||
}
|
||||
# @return User
|
||||
#
|
||||
@ -456,22 +462,23 @@ sub get_user_by_name {
|
||||
# @param string $username name that need to be deleted (required)
|
||||
# @param User $body Updated user object (optional)
|
||||
{
|
||||
my $params = {
|
||||
'username' => {
|
||||
data_type => 'string',
|
||||
description => 'name that need to be deleted',
|
||||
required => '1',
|
||||
},
|
||||
'body' => {
|
||||
data_type => 'User',
|
||||
description => 'Updated user object',
|
||||
required => '0',
|
||||
},
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ update_user } = { summary => 'Updated user',
|
||||
params => $params,
|
||||
returns => undef,
|
||||
};
|
||||
my $params = {
|
||||
'username' => {
|
||||
data_type => 'string',
|
||||
description => 'name that need to be deleted',
|
||||
required => '1',
|
||||
},
|
||||
'body' => {
|
||||
data_type => 'User',
|
||||
description => 'Updated user object',
|
||||
required => '0',
|
||||
},
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ update_user } = {
|
||||
summary => 'Updated user',
|
||||
params => $params,
|
||||
returns => undef,
|
||||
};
|
||||
}
|
||||
# @return void
|
||||
#
|
||||
@ -535,17 +542,18 @@ sub update_user {
|
||||
#
|
||||
# @param string $username The name that needs to be deleted (required)
|
||||
{
|
||||
my $params = {
|
||||
'username' => {
|
||||
data_type => 'string',
|
||||
description => 'The name that needs to be deleted',
|
||||
required => '1',
|
||||
},
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ delete_user } = { summary => 'Delete user',
|
||||
params => $params,
|
||||
returns => undef,
|
||||
};
|
||||
my $params = {
|
||||
'username' => {
|
||||
data_type => 'string',
|
||||
description => 'The name that needs to be deleted',
|
||||
required => '1',
|
||||
},
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ delete_user } = {
|
||||
summary => 'Delete user',
|
||||
params => $params,
|
||||
returns => undef,
|
||||
};
|
||||
}
|
||||
# @return void
|
||||
#
|
||||
|
Loading…
Reference in New Issue
Block a user