forked from loafle/openapi-generator-original
remove baseobject from perl, add README.mustache
This commit is contained in:
parent
3a2447634c
commit
fa9844af7e
@ -97,11 +97,12 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
|
|
||||||
supportingFiles.add(new SupportingFile("ApiClient.mustache", ("lib/WWW/" + moduleName).replace('/', File.separatorChar), "ApiClient.pm"));
|
supportingFiles.add(new SupportingFile("ApiClient.mustache", ("lib/WWW/" + moduleName).replace('/', File.separatorChar), "ApiClient.pm"));
|
||||||
supportingFiles.add(new SupportingFile("Configuration.mustache", ("lib/WWW/" + moduleName).replace('/', File.separatorChar), "Configuration.pm"));
|
supportingFiles.add(new SupportingFile("Configuration.mustache", ("lib/WWW/" + moduleName).replace('/', File.separatorChar), "Configuration.pm"));
|
||||||
supportingFiles.add(new SupportingFile("BaseObject.mustache", ("lib/WWW/" + moduleName).replace('/', File.separatorChar), "Object/BaseObject.pm"));
|
//supportingFiles.add(new SupportingFile("BaseObject.mustache", ("lib/WWW/" + moduleName).replace('/', File.separatorChar), "Object/BaseObject.pm"));
|
||||||
supportingFiles.add(new SupportingFile("ApiFactory.mustache", ("lib/WWW/" + moduleName).replace('/', File.separatorChar), "ApiFactory.pm"));
|
supportingFiles.add(new SupportingFile("ApiFactory.mustache", ("lib/WWW/" + moduleName).replace('/', File.separatorChar), "ApiFactory.pm"));
|
||||||
supportingFiles.add(new SupportingFile("Role.mustache", ("lib/WWW/" + moduleName).replace('/', File.separatorChar), "Role.pm"));
|
supportingFiles.add(new SupportingFile("Role.mustache", ("lib/WWW/" + moduleName).replace('/', File.separatorChar), "Role.pm"));
|
||||||
supportingFiles.add(new SupportingFile("AutoDoc.mustache", ("lib/WWW/" + moduleName + "/Role").replace('/', File.separatorChar), "AutoDoc.pm"));
|
supportingFiles.add(new SupportingFile("AutoDoc.mustache", ("lib/WWW/" + moduleName + "/Role").replace('/', File.separatorChar), "AutoDoc.pm"));
|
||||||
supportingFiles.add(new SupportingFile("autodoc.script.mustache", ("bin/").replace('/', File.separatorChar), "autodoc"));
|
supportingFiles.add(new SupportingFile("autodoc.script.mustache", "bin", "autodoc"));
|
||||||
|
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,25 +1,3 @@
|
|||||||
package WWW::{{moduleName}}::Object::BaseObject;
|
|
||||||
|
|
||||||
require 5.6.0;
|
|
||||||
use strict;
|
|
||||||
use warnings;
|
|
||||||
use utf8;
|
|
||||||
use JSON qw(decode_json);
|
|
||||||
use Data::Dumper;
|
|
||||||
use Module::Runtime qw(use_module);
|
|
||||||
use Log::Any qw($log);
|
|
||||||
use Date::Parse;
|
|
||||||
use DateTime;
|
|
||||||
|
|
||||||
use base ("Class::Accessor", "Class::Data::Inheritable");
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
|
||||||
#
|
|
||||||
|
|
||||||
__PACKAGE__->mk_classdata('attribute_map' => {});
|
__PACKAGE__->mk_classdata('attribute_map' => {});
|
||||||
__PACKAGE__->mk_classdata('swagger_types' => {});
|
__PACKAGE__->mk_classdata('swagger_types' => {});
|
||||||
__PACKAGE__->mk_classdata('method_documentation' => {});
|
__PACKAGE__->mk_classdata('method_documentation' => {});
|
||||||
@ -95,4 +73,3 @@ sub _deserialize {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
|
||||||
|
@ -13,7 +13,9 @@ use Log::Any qw($log);
|
|||||||
use Date::Parse;
|
use Date::Parse;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
|
||||||
use base "WWW::{{moduleName}}::Object::BaseObject";
|
#use base "WWW::{{moduleName}}::Object::BaseObject";
|
||||||
|
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
#{{description}}
|
#{{description}}
|
||||||
@ -21,6 +23,8 @@ use base "WWW::{{moduleName}}::Object::BaseObject";
|
|||||||
#NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
#NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
{{>BaseObject}}
|
||||||
|
|
||||||
__PACKAGE__->class_documentation({description => '{{description}}',
|
__PACKAGE__->class_documentation({description => '{{description}}',
|
||||||
class => '{{classname}}',
|
class => '{{classname}}',
|
||||||
required => [], # TODO
|
required => [], # TODO
|
||||||
@ -49,6 +53,7 @@ __PACKAGE__->attribute_map( {
|
|||||||
|
|
||||||
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
||||||
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
{{/model}}
|
{{/model}}
|
||||||
{{/models}}
|
{{/models}}
|
||||||
|
@ -1,281 +1,219 @@
|
|||||||
# NAME
|
# NAME
|
||||||
|
|
||||||
My::App
|
WWW::SwaggerClient::Role - a Moose role for the Swagger Petstore
|
||||||
|
|
||||||
# VERSION
|
|
||||||
|
|
||||||
## Swagger Petstore version: 1.0.0
|
## Swagger Petstore version: 1.0.0
|
||||||
|
|
||||||
|
# VERSION
|
||||||
|
|
||||||
Automatically generated by the Perl Swagger Codegen project:
|
Automatically generated by the Perl Swagger Codegen project:
|
||||||
|
|
||||||
- Build date: 2015-11-13T20:46:43.271Z
|
- Build date: 2015-12-28T16:00:32.828+08:00
|
||||||
- Build package: class io.swagger.codegen.languages.PerlClientCodegen
|
- Build package: class io.swagger.codegen.languages.PerlClientCodegen
|
||||||
- Codegen version:
|
- Codegen version:
|
||||||
|
|
||||||
# INHERITANCE
|
## A note on Moose
|
||||||
|
|
||||||
## Base class(es)
|
This role is the only component of the library that uses Moose. See
|
||||||
|
WWW::SwaggerClient::ApiFactory for non-Moosey usage.
|
||||||
|
|
||||||
Moose::Object
|
# SYNOPSIS
|
||||||
|
|
||||||
## Direct subclasses
|
The Perl Swagger Codegen project builds a library of Perl modules to interact with
|
||||||
|
a web service defined by a Swagger specification. See below for how to build the
|
||||||
|
library.
|
||||||
|
|
||||||
## All subclasses
|
This module provides an interface to the generated library. All the classes,
|
||||||
|
objects, and methods (well, not quite \*all\*, see below) are flattened into this
|
||||||
|
role.
|
||||||
|
|
||||||
# COMPOSITION
|
package MyApp;
|
||||||
|
use Moose;
|
||||||
|
with 'WWW::SwaggerClient::Role';
|
||||||
|
|
||||||
My::App composes the following roles:
|
package main;
|
||||||
|
|
||||||
## `WWW::SwaggerClient::Role`
|
my $api = MyApp->new({ tokens => $tokens });
|
||||||
|
|
||||||
Requires:
|
my $pet = $api->get_pet_by_id(pet_id => $pet_id);
|
||||||
|
|
||||||
|
|
||||||
|
## Structure of the library
|
||||||
|
|
||||||
|
The library consists of a set of API classes, one for each endpoint. These APIs
|
||||||
|
implement the method calls available on each endpoint.
|
||||||
|
|
||||||
|
Additionally, there is a set of "object" classes, which represent the objects
|
||||||
|
returned by and sent to the methods on the endpoints.
|
||||||
|
|
||||||
|
An API factory class is provided, which builds instances of each endpoint API.
|
||||||
|
|
||||||
|
This Moose role flattens all the methods from the endpoint APIs onto the consuming
|
||||||
|
class. It also provides methods to retrieve the endpoint API objects, and the API
|
||||||
|
factory object, should you need it.
|
||||||
|
|
||||||
|
For documentation of all these methods, see AUTOMATIC DOCUMENTATION below.
|
||||||
|
|
||||||
|
## Configuring authentication
|
||||||
|
|
||||||
|
In the normal case, the Swagger spec will describe what parameters are
|
||||||
|
required and where to put them. You just need to supply the tokens.
|
||||||
|
|
||||||
|
my $tokens = {
|
||||||
|
# basic
|
||||||
|
username => $username,
|
||||||
|
password => $password,
|
||||||
|
|
||||||
|
# oauth
|
||||||
|
access_token => $oauth_token,
|
||||||
|
|
||||||
|
# keys
|
||||||
|
$some_key => { token => $token,
|
||||||
|
prefix => $prefix,
|
||||||
|
in => $in, # 'head||query',
|
||||||
|
},
|
||||||
|
|
||||||
|
$another => { token => $token,
|
||||||
|
prefix => $prefix,
|
||||||
|
in => $in, # 'head||query',
|
||||||
|
},
|
||||||
|
...,
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
my $api = MyApp->new({ tokens => $tokens });
|
||||||
|
|
||||||
|
Note these are all optional, as are `prefix` and `in`, and depend on the API
|
||||||
|
you are accessing. Usually `prefix` and `in` will be determined by the code generator from
|
||||||
|
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
|
||||||
|
as follows, but you don't need to know about this.
|
||||||
|
|
||||||
|
- `$WWW::SwaggerClient::Configuration::username`
|
||||||
|
|
||||||
|
String. The username for basic auth.
|
||||||
|
|
||||||
|
- `$WWW::SwaggerClient::Configuration::password`
|
||||||
|
|
||||||
|
String. The password for basic auth.
|
||||||
|
|
||||||
|
- `$WWW::SwaggerClient::Configuration::api_key`
|
||||||
|
|
||||||
|
Hashref. Keyed on the name of each key (there can be multiple tokens).
|
||||||
|
|
||||||
|
$WWW::SwaggerClient::Configuration::api_key = {
|
||||||
|
secretKey => 'aaaabbbbccccdddd',
|
||||||
|
anotherKey => '1111222233334444',
|
||||||
|
};
|
||||||
|
|
||||||
|
- `$WWW::SwaggerClient::Configuration::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 = {
|
||||||
|
secretKey => 'string',
|
||||||
|
anotherKey => 'same or some other string',
|
||||||
|
};
|
||||||
|
|
||||||
|
- `$WWW::SwaggerClient::Configuration::access_token`
|
||||||
|
|
||||||
|
String. The OAuth access token.
|
||||||
|
|
||||||
# METHODS
|
# METHODS
|
||||||
|
|
||||||
## `add_pet()`
|
## `base_url`
|
||||||
|
|
||||||
Defined in: WWW::SwaggerClient::PetApi
|
The generated code has the `base_url` already set as a default value. This method
|
||||||
Delegates to: add_pet()
|
returns (and optionally sets, but only if the API client has not been
|
||||||
On: WWW::SwaggerClient::PetApi
|
created yet) the current value of `base_url`.
|
||||||
Via: pet_api()
|
|
||||||
Doc: Add a new pet to the store
|
|
||||||
Same as: $self->pet_api->add_pet()
|
|
||||||
|
|
||||||
## `create_user()`
|
|
||||||
|
|
||||||
Defined in: WWW::SwaggerClient::UserApi
|
|
||||||
Delegates to: create_user()
|
|
||||||
On: WWW::SwaggerClient::UserApi
|
|
||||||
Via: user_api()
|
|
||||||
Doc: Create user
|
|
||||||
Same as: $self->user_api->create_user()
|
|
||||||
|
|
||||||
## `create_users_with_array_input()`
|
|
||||||
|
|
||||||
Defined in: WWW::SwaggerClient::UserApi
|
|
||||||
Delegates to: create_users_with_array_input()
|
|
||||||
On: WWW::SwaggerClient::UserApi
|
|
||||||
Via: user_api()
|
|
||||||
Doc: Creates list of users with given input array
|
|
||||||
Same as: $self->user_api->create_users_with_array_input()
|
|
||||||
|
|
||||||
## `create_users_with_list_input()`
|
|
||||||
|
|
||||||
Defined in: WWW::SwaggerClient::UserApi
|
|
||||||
Delegates to: create_users_with_list_input()
|
|
||||||
On: WWW::SwaggerClient::UserApi
|
|
||||||
Via: user_api()
|
|
||||||
Doc: Creates list of users with given input array
|
|
||||||
Same as: $self->user_api->create_users_with_list_input()
|
|
||||||
|
|
||||||
## `delete_order()`
|
|
||||||
|
|
||||||
Defined in: WWW::SwaggerClient::StoreApi
|
|
||||||
Delegates to: delete_order()
|
|
||||||
On: WWW::SwaggerClient::StoreApi
|
|
||||||
Via: store_api()
|
|
||||||
Doc: Delete purchase order by ID
|
|
||||||
Same as: $self->store_api->delete_order()
|
|
||||||
|
|
||||||
## `delete_pet()`
|
|
||||||
|
|
||||||
Defined in: WWW::SwaggerClient::PetApi
|
|
||||||
Delegates to: delete_pet()
|
|
||||||
On: WWW::SwaggerClient::PetApi
|
|
||||||
Via: pet_api()
|
|
||||||
Doc: Deletes a pet
|
|
||||||
Same as: $self->pet_api->delete_pet()
|
|
||||||
|
|
||||||
## `delete_user()`
|
|
||||||
|
|
||||||
Defined in: WWW::SwaggerClient::UserApi
|
|
||||||
Delegates to: delete_user()
|
|
||||||
On: WWW::SwaggerClient::UserApi
|
|
||||||
Via: user_api()
|
|
||||||
Doc: Delete user
|
|
||||||
Same as: $self->user_api->delete_user()
|
|
||||||
|
|
||||||
## `find_pets_by_status()`
|
|
||||||
|
|
||||||
Defined in: WWW::SwaggerClient::PetApi
|
|
||||||
Delegates to: find_pets_by_status()
|
|
||||||
On: WWW::SwaggerClient::PetApi
|
|
||||||
Via: pet_api()
|
|
||||||
Doc: Finds Pets by status
|
|
||||||
Same as: $self->pet_api->find_pets_by_status()
|
|
||||||
|
|
||||||
## `find_pets_by_tags()`
|
|
||||||
|
|
||||||
Defined in: WWW::SwaggerClient::PetApi
|
|
||||||
Delegates to: find_pets_by_tags()
|
|
||||||
On: WWW::SwaggerClient::PetApi
|
|
||||||
Via: pet_api()
|
|
||||||
Doc: Finds Pets by tags
|
|
||||||
Same as: $self->pet_api->find_pets_by_tags()
|
|
||||||
|
|
||||||
## `get_inventory()`
|
|
||||||
|
|
||||||
Defined in: WWW::SwaggerClient::StoreApi
|
|
||||||
Delegates to: get_inventory()
|
|
||||||
On: WWW::SwaggerClient::StoreApi
|
|
||||||
Via: store_api()
|
|
||||||
Doc: Returns pet inventories by status
|
|
||||||
Same as: $self->store_api->get_inventory()
|
|
||||||
|
|
||||||
## `get_order_by_id()`
|
|
||||||
|
|
||||||
Defined in: WWW::SwaggerClient::StoreApi
|
|
||||||
Delegates to: get_order_by_id()
|
|
||||||
On: WWW::SwaggerClient::StoreApi
|
|
||||||
Via: store_api()
|
|
||||||
Doc: Find purchase order by ID
|
|
||||||
Same as: $self->store_api->get_order_by_id()
|
|
||||||
|
|
||||||
## `get_pet_by_id()`
|
|
||||||
|
|
||||||
Defined in: WWW::SwaggerClient::PetApi
|
|
||||||
Delegates to: get_pet_by_id()
|
|
||||||
On: WWW::SwaggerClient::PetApi
|
|
||||||
Via: pet_api()
|
|
||||||
Doc: Find pet by ID
|
|
||||||
Same as: $self->pet_api->get_pet_by_id()
|
|
||||||
|
|
||||||
## `get_user_by_name()`
|
|
||||||
|
|
||||||
Defined in: WWW::SwaggerClient::UserApi
|
|
||||||
Delegates to: get_user_by_name()
|
|
||||||
On: WWW::SwaggerClient::UserApi
|
|
||||||
Via: user_api()
|
|
||||||
Doc: Get user by user name
|
|
||||||
Same as: $self->user_api->get_user_by_name()
|
|
||||||
|
|
||||||
## `login_user()`
|
|
||||||
|
|
||||||
Defined in: WWW::SwaggerClient::UserApi
|
|
||||||
Delegates to: login_user()
|
|
||||||
On: WWW::SwaggerClient::UserApi
|
|
||||||
Via: user_api()
|
|
||||||
Doc: Logs user into the system
|
|
||||||
Same as: $self->user_api->login_user()
|
|
||||||
|
|
||||||
## `logout_user()`
|
|
||||||
|
|
||||||
Defined in: WWW::SwaggerClient::UserApi
|
|
||||||
Delegates to: logout_user()
|
|
||||||
On: WWW::SwaggerClient::UserApi
|
|
||||||
Via: user_api()
|
|
||||||
Doc: Logs out current logged in user session
|
|
||||||
Same as: $self->user_api->logout_user()
|
|
||||||
|
|
||||||
## `place_order()`
|
|
||||||
|
|
||||||
Defined in: WWW::SwaggerClient::StoreApi
|
|
||||||
Delegates to: place_order()
|
|
||||||
On: WWW::SwaggerClient::StoreApi
|
|
||||||
Via: store_api()
|
|
||||||
Doc: Place an order for a pet
|
|
||||||
Same as: $self->store_api->place_order()
|
|
||||||
|
|
||||||
## `update_pet()`
|
|
||||||
|
|
||||||
Defined in: WWW::SwaggerClient::PetApi
|
|
||||||
Delegates to: update_pet()
|
|
||||||
On: WWW::SwaggerClient::PetApi
|
|
||||||
Via: pet_api()
|
|
||||||
Doc: Update an existing pet
|
|
||||||
Same as: $self->pet_api->update_pet()
|
|
||||||
|
|
||||||
## `update_pet_with_form()`
|
|
||||||
|
|
||||||
Defined in: WWW::SwaggerClient::PetApi
|
|
||||||
Delegates to: update_pet_with_form()
|
|
||||||
On: WWW::SwaggerClient::PetApi
|
|
||||||
Via: pet_api()
|
|
||||||
Doc: Updates a pet in the store with form data
|
|
||||||
Same as: $self->pet_api->update_pet_with_form()
|
|
||||||
|
|
||||||
## `update_user()`
|
|
||||||
|
|
||||||
Defined in: WWW::SwaggerClient::UserApi
|
|
||||||
Delegates to: update_user()
|
|
||||||
On: WWW::SwaggerClient::UserApi
|
|
||||||
Via: user_api()
|
|
||||||
Doc: Updated user
|
|
||||||
Same as: $self->user_api->update_user()
|
|
||||||
|
|
||||||
## `upload_file()`
|
|
||||||
|
|
||||||
Defined in: WWW::SwaggerClient::PetApi
|
|
||||||
Delegates to: upload_file()
|
|
||||||
On: WWW::SwaggerClient::PetApi
|
|
||||||
Via: pet_api()
|
|
||||||
Doc: uploads an image
|
|
||||||
Same as: $self->pet_api->upload_file()
|
|
||||||
|
|
||||||
# ATTRIBUTES
|
|
||||||
|
|
||||||
## `api_factory`
|
## `api_factory`
|
||||||
|
|
||||||
is: ro
|
Returns an API factory object. You probably won't need to call this directly.
|
||||||
isa: WWW::SwaggerClient::ApiFactory
|
|
||||||
reqd: no
|
|
||||||
lazy: yes
|
|
||||||
doc: Builds an instance of the endpoint API class
|
|
||||||
handles:
|
|
||||||
|
|
||||||
## `base_url`
|
$self->api_factory('Pet'); # returns a WWW::SwaggerClient::PetApi instance
|
||||||
|
|
||||||
is: ro
|
$self->pet_api; # the same
|
||||||
isa: Str
|
|
||||||
reqd: no
|
|
||||||
lazy: no
|
|
||||||
doc: Root of the server that requests are sent to
|
|
||||||
handles:
|
|
||||||
|
|
||||||
## `pet_api`
|
# MISSING METHODS
|
||||||
|
|
||||||
is: ro
|
Most of the methods on the API are delegated to individual endpoint API objects
|
||||||
isa: WWW::SwaggerClient::PetApi
|
(e.g. Pet API, Store API, User API etc). Where different endpoint APIs use the
|
||||||
reqd: no
|
same method name (e.g. `new()`), these methods can't be delegated. So you need
|
||||||
lazy: yes
|
to call `$api->pet_api->new()`.
|
||||||
doc:
|
|
||||||
handles: add_pet, delete_pet, find_pets_by_status, find_pets_by_tags,
|
|
||||||
get_pet_by_id, update_pet, update_pet_with_form, upload_file
|
|
||||||
|
|
||||||
## `store_api`
|
In principle, every API is susceptible to the presence of a few, random, undelegatable
|
||||||
|
method names. In practice, because of the way method names are constructed, it's
|
||||||
|
unlikely in general that any methods will be undelegatable, except for:
|
||||||
|
|
||||||
is: ro
|
new()
|
||||||
isa: WWW::SwaggerClient::StoreApi
|
class_documentation()
|
||||||
reqd: no
|
method_documentation()
|
||||||
lazy: yes
|
|
||||||
doc:
|
|
||||||
handles: delete_order, get_inventory, get_order_by_id, place_order
|
|
||||||
|
|
||||||
## `tokens`
|
To call these methods, you need to get a handle on the relevant object, either
|
||||||
|
by calling `$api->foo_api` or by retrieving an object, e.g.
|
||||||
|
`$api->get_pet_by_id(pet_id => $pet_id)`. They are class methods, so
|
||||||
|
you could also call them on class names.
|
||||||
|
|
||||||
is: ro
|
# BUILDING YOUR LIBRARY
|
||||||
isa: HashRef
|
|
||||||
reqd: no
|
|
||||||
lazy: no
|
|
||||||
doc: The auth tokens required by the application - basic, OAuth and/or API key(s)
|
|
||||||
handles:
|
|
||||||
|
|
||||||
## `user_api`
|
See the homepage `https://github.com/swagger-api/swagger-codegen` for full details.
|
||||||
|
But briefly, clone the git repository, build the codegen codebase, set up your build
|
||||||
|
config file, then run the API build script. You will need git, Java 7 and Apache
|
||||||
|
maven 3.0.3 or better already installed.
|
||||||
|
|
||||||
is: ro
|
The config file should specify the project name for the generated library:
|
||||||
isa: WWW::SwaggerClient::UserApi
|
|
||||||
reqd: no
|
|
||||||
lazy: yes
|
|
||||||
doc:
|
|
||||||
handles: create_user, create_users_with_array_input,
|
|
||||||
create_users_with_list_input, delete_user, get_user_by_name,
|
|
||||||
login_user, logout_user, update_user
|
|
||||||
|
|
||||||
## `version_info`
|
{"moduleName":"MyProjectName"}
|
||||||
|
|
||||||
is: ro
|
Your library files will be built under `WWW::MyProjectName`.
|
||||||
isa: HashRef
|
|
||||||
reqd: no
|
$ git clone https://github.com/swagger-api/swagger-codegen.git
|
||||||
lazy: no
|
$ cd swagger-codegen
|
||||||
doc: Information about the application version and the codegen codebase version
|
$ mvn package
|
||||||
handles:
|
$ java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
|
||||||
|
-i [URL or file path to JSON swagger API spec] \
|
||||||
|
-l perl \
|
||||||
|
-c /path/to/config/file.json \
|
||||||
|
-o /path/to/output/folder
|
||||||
|
|
||||||
|
Bang, all done. Run the `autodoc` script in the `bin` directory to see the API
|
||||||
|
you just built.
|
||||||
|
|
||||||
|
# AUTOMATIC DOCUMENTATION
|
||||||
|
|
||||||
|
You can print out a summary of the generated API by running the included
|
||||||
|
`autodoc` script in the `bin` directory of your generated library. A few
|
||||||
|
output formats are supported:
|
||||||
|
|
||||||
|
Usage: autodoc [OPTION]
|
||||||
|
|
||||||
|
-w wide format (default)
|
||||||
|
-n narrow format
|
||||||
|
-p POD format
|
||||||
|
-H HTML format
|
||||||
|
-m Markdown format
|
||||||
|
-h print this help message
|
||||||
|
-c your application class
|
||||||
|
|
||||||
|
|
||||||
|
The `-c` option allows you to load and inspect your own application. A dummy
|
||||||
|
namespace is used if you don't supply your own class.
|
||||||
|
|
||||||
|
# DOCUMENTATION FROM THE SWAGGER SPEC
|
||||||
|
|
||||||
|
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 object class, and the
|
||||||
|
`method_documentation()` method on the endpoint API classes:
|
||||||
|
|
||||||
|
my $cmdoc = $api->pet_api->method_documentation->{$method_name};
|
||||||
|
|
||||||
|
my $odoc = $api->get_pet_by_id->(pet_id => $pet_id)->class_documentation;
|
||||||
|
my $omdoc = $api->get_pet_by_id->(pet_id => $pet_id)->method_documentation->{method_name};
|
||||||
|
|
||||||
|
|
||||||
|
Each of these calls returns a hashref with various useful pieces of information.
|
||||||
|
@ -11,7 +11,9 @@ use Log::Any qw($log);
|
|||||||
use Date::Parse;
|
use Date::Parse;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
|
||||||
use base "WWW::SwaggerClient::Object::BaseObject";
|
#use base "WWW::SwaggerClient::Object::BaseObject";
|
||||||
|
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
@ -19,6 +21,83 @@ use base "WWW::SwaggerClient::Object::BaseObject";
|
|||||||
#NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
#NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
#__PACKAGE__->mk_classdata('attribute_map' => {});
|
||||||
|
#__PACKAGE__->mk_classdata('swagger_types' => {});
|
||||||
|
#__PACKAGE__->mk_classdata('method_documentation' => {});
|
||||||
|
#__PACKAGE__->mk_classdata('class_documentation' => {});
|
||||||
|
|
||||||
|
# new object
|
||||||
|
sub new {
|
||||||
|
my ($class, %args) = @_;
|
||||||
|
|
||||||
|
my $self = bless {}, $class;
|
||||||
|
|
||||||
|
foreach my $attribute (keys %{$class->attribute_map}) {
|
||||||
|
my $args_key = $class->attribute_map->{$attribute};
|
||||||
|
$self->$attribute( $args{ $args_key } );
|
||||||
|
}
|
||||||
|
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
# return perl hash
|
||||||
|
sub to_hash {
|
||||||
|
return decode_json(JSON->new->convert_blessed->encode( shift ));
|
||||||
|
}
|
||||||
|
|
||||||
|
# used by JSON for serialization
|
||||||
|
sub TO_JSON {
|
||||||
|
my $self = shift;
|
||||||
|
my $_data = {};
|
||||||
|
foreach my $_key (keys %{$self->attribute_map}) {
|
||||||
|
if (defined $self->{$_key}) {
|
||||||
|
$_data->{$self->attribute_map->{$_key}} = $self->{$_key};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
# from Perl hashref
|
||||||
|
sub from_hash {
|
||||||
|
my ($self, $hash) = @_;
|
||||||
|
|
||||||
|
# loop through attributes and use swagger_types to deserialize the data
|
||||||
|
while ( my ($_key, $_type) = each %{$self->swagger_types} ) {
|
||||||
|
my $_json_attribute = $self->attribute_map->{$_key};
|
||||||
|
if ($_type =~ /^array\[/i) { # array
|
||||||
|
my $_subclass = substr($_type, 6, -1);
|
||||||
|
my @_array = ();
|
||||||
|
foreach my $_element (@{$hash->{$_json_attribute}}) {
|
||||||
|
push @_array, $self->_deserialize($_subclass, $_element);
|
||||||
|
}
|
||||||
|
$self->{$_key} = \@_array;
|
||||||
|
} elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
|
||||||
|
$self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute});
|
||||||
|
} else {
|
||||||
|
$log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
# deserialize non-array data
|
||||||
|
sub _deserialize {
|
||||||
|
my ($self, $type, $data) = @_;
|
||||||
|
$log->debugf("deserializing %s with %s",Dumper($data), $type);
|
||||||
|
|
||||||
|
if ($type eq 'DateTime') {
|
||||||
|
return DateTime->from_epoch(epoch => str2time($data));
|
||||||
|
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
|
||||||
|
return $data;
|
||||||
|
} else { # hash(model)
|
||||||
|
my $_instance = eval "WWW::SwaggerClient::Object::$type->new()";
|
||||||
|
return $_instance->from_hash($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
__PACKAGE__->class_documentation({description => '',
|
__PACKAGE__->class_documentation({description => '',
|
||||||
class => 'Category',
|
class => 'Category',
|
||||||
required => [], # TODO
|
required => [], # TODO
|
||||||
@ -54,4 +133,5 @@ __PACKAGE__->attribute_map( {
|
|||||||
|
|
||||||
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
||||||
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
@ -11,7 +11,9 @@ use Log::Any qw($log);
|
|||||||
use Date::Parse;
|
use Date::Parse;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
|
||||||
use base "WWW::SwaggerClient::Object::BaseObject";
|
#use base "WWW::SwaggerClient::Object::BaseObject";
|
||||||
|
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
@ -19,6 +21,83 @@ use base "WWW::SwaggerClient::Object::BaseObject";
|
|||||||
#NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
#NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
__PACKAGE__->mk_classdata('attribute_map' => {});
|
||||||
|
__PACKAGE__->mk_classdata('swagger_types' => {});
|
||||||
|
__PACKAGE__->mk_classdata('method_documentation' => {});
|
||||||
|
__PACKAGE__->mk_classdata('class_documentation' => {});
|
||||||
|
|
||||||
|
# new object
|
||||||
|
sub new {
|
||||||
|
my ($class, %args) = @_;
|
||||||
|
|
||||||
|
my $self = bless {}, $class;
|
||||||
|
|
||||||
|
foreach my $attribute (keys %{$class->attribute_map}) {
|
||||||
|
my $args_key = $class->attribute_map->{$attribute};
|
||||||
|
$self->$attribute( $args{ $args_key } );
|
||||||
|
}
|
||||||
|
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
# return perl hash
|
||||||
|
sub to_hash {
|
||||||
|
return decode_json(JSON->new->convert_blessed->encode( shift ));
|
||||||
|
}
|
||||||
|
|
||||||
|
# used by JSON for serialization
|
||||||
|
sub TO_JSON {
|
||||||
|
my $self = shift;
|
||||||
|
my $_data = {};
|
||||||
|
foreach my $_key (keys %{$self->attribute_map}) {
|
||||||
|
if (defined $self->{$_key}) {
|
||||||
|
$_data->{$self->attribute_map->{$_key}} = $self->{$_key};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
# from Perl hashref
|
||||||
|
sub from_hash {
|
||||||
|
my ($self, $hash) = @_;
|
||||||
|
|
||||||
|
# loop through attributes and use swagger_types to deserialize the data
|
||||||
|
while ( my ($_key, $_type) = each %{$self->swagger_types} ) {
|
||||||
|
my $_json_attribute = $self->attribute_map->{$_key};
|
||||||
|
if ($_type =~ /^array\[/i) { # array
|
||||||
|
my $_subclass = substr($_type, 6, -1);
|
||||||
|
my @_array = ();
|
||||||
|
foreach my $_element (@{$hash->{$_json_attribute}}) {
|
||||||
|
push @_array, $self->_deserialize($_subclass, $_element);
|
||||||
|
}
|
||||||
|
$self->{$_key} = \@_array;
|
||||||
|
} elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
|
||||||
|
$self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute});
|
||||||
|
} else {
|
||||||
|
$log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
# deserialize non-array data
|
||||||
|
sub _deserialize {
|
||||||
|
my ($self, $type, $data) = @_;
|
||||||
|
$log->debugf("deserializing %s with %s",Dumper($data), $type);
|
||||||
|
|
||||||
|
if ($type eq 'DateTime') {
|
||||||
|
return DateTime->from_epoch(epoch => str2time($data));
|
||||||
|
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
|
||||||
|
return $data;
|
||||||
|
} else { # hash(model)
|
||||||
|
my $_instance = eval "WWW::SwaggerClient::Object::$type->new()";
|
||||||
|
return $_instance->from_hash($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
__PACKAGE__->class_documentation({description => '',
|
__PACKAGE__->class_documentation({description => '',
|
||||||
class => 'Order',
|
class => 'Order',
|
||||||
required => [], # TODO
|
required => [], # TODO
|
||||||
@ -90,4 +169,5 @@ __PACKAGE__->attribute_map( {
|
|||||||
|
|
||||||
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
||||||
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
@ -11,7 +11,9 @@ use Log::Any qw($log);
|
|||||||
use Date::Parse;
|
use Date::Parse;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
|
||||||
use base "WWW::SwaggerClient::Object::BaseObject";
|
#use base "WWW::SwaggerClient::Object::BaseObject";
|
||||||
|
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
@ -19,6 +21,83 @@ use base "WWW::SwaggerClient::Object::BaseObject";
|
|||||||
#NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
#NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
__PACKAGE__->mk_classdata('attribute_map' => {});
|
||||||
|
__PACKAGE__->mk_classdata('swagger_types' => {});
|
||||||
|
__PACKAGE__->mk_classdata('method_documentation' => {});
|
||||||
|
__PACKAGE__->mk_classdata('class_documentation' => {});
|
||||||
|
|
||||||
|
# new object
|
||||||
|
sub new {
|
||||||
|
my ($class, %args) = @_;
|
||||||
|
|
||||||
|
my $self = bless {}, $class;
|
||||||
|
|
||||||
|
foreach my $attribute (keys %{$class->attribute_map}) {
|
||||||
|
my $args_key = $class->attribute_map->{$attribute};
|
||||||
|
$self->$attribute( $args{ $args_key } );
|
||||||
|
}
|
||||||
|
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
# return perl hash
|
||||||
|
sub to_hash {
|
||||||
|
return decode_json(JSON->new->convert_blessed->encode( shift ));
|
||||||
|
}
|
||||||
|
|
||||||
|
# used by JSON for serialization
|
||||||
|
sub TO_JSON {
|
||||||
|
my $self = shift;
|
||||||
|
my $_data = {};
|
||||||
|
foreach my $_key (keys %{$self->attribute_map}) {
|
||||||
|
if (defined $self->{$_key}) {
|
||||||
|
$_data->{$self->attribute_map->{$_key}} = $self->{$_key};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
# from Perl hashref
|
||||||
|
sub from_hash {
|
||||||
|
my ($self, $hash) = @_;
|
||||||
|
|
||||||
|
# loop through attributes and use swagger_types to deserialize the data
|
||||||
|
while ( my ($_key, $_type) = each %{$self->swagger_types} ) {
|
||||||
|
my $_json_attribute = $self->attribute_map->{$_key};
|
||||||
|
if ($_type =~ /^array\[/i) { # array
|
||||||
|
my $_subclass = substr($_type, 6, -1);
|
||||||
|
my @_array = ();
|
||||||
|
foreach my $_element (@{$hash->{$_json_attribute}}) {
|
||||||
|
push @_array, $self->_deserialize($_subclass, $_element);
|
||||||
|
}
|
||||||
|
$self->{$_key} = \@_array;
|
||||||
|
} elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
|
||||||
|
$self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute});
|
||||||
|
} else {
|
||||||
|
$log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
# deserialize non-array data
|
||||||
|
sub _deserialize {
|
||||||
|
my ($self, $type, $data) = @_;
|
||||||
|
$log->debugf("deserializing %s with %s",Dumper($data), $type);
|
||||||
|
|
||||||
|
if ($type eq 'DateTime') {
|
||||||
|
return DateTime->from_epoch(epoch => str2time($data));
|
||||||
|
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
|
||||||
|
return $data;
|
||||||
|
} else { # hash(model)
|
||||||
|
my $_instance = eval "WWW::SwaggerClient::Object::$type->new()";
|
||||||
|
return $_instance->from_hash($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
__PACKAGE__->class_documentation({description => '',
|
__PACKAGE__->class_documentation({description => '',
|
||||||
class => 'Pet',
|
class => 'Pet',
|
||||||
required => [], # TODO
|
required => [], # TODO
|
||||||
@ -90,4 +169,5 @@ __PACKAGE__->attribute_map( {
|
|||||||
|
|
||||||
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
||||||
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
@ -11,7 +11,9 @@ use Log::Any qw($log);
|
|||||||
use Date::Parse;
|
use Date::Parse;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
|
||||||
use base "WWW::SwaggerClient::Object::BaseObject";
|
#use base "WWW::SwaggerClient::Object::BaseObject";
|
||||||
|
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
@ -19,6 +21,83 @@ use base "WWW::SwaggerClient::Object::BaseObject";
|
|||||||
#NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
#NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
__PACKAGE__->mk_classdata('attribute_map' => {});
|
||||||
|
__PACKAGE__->mk_classdata('swagger_types' => {});
|
||||||
|
__PACKAGE__->mk_classdata('method_documentation' => {});
|
||||||
|
__PACKAGE__->mk_classdata('class_documentation' => {});
|
||||||
|
|
||||||
|
# new object
|
||||||
|
sub new {
|
||||||
|
my ($class, %args) = @_;
|
||||||
|
|
||||||
|
my $self = bless {}, $class;
|
||||||
|
|
||||||
|
foreach my $attribute (keys %{$class->attribute_map}) {
|
||||||
|
my $args_key = $class->attribute_map->{$attribute};
|
||||||
|
$self->$attribute( $args{ $args_key } );
|
||||||
|
}
|
||||||
|
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
# return perl hash
|
||||||
|
sub to_hash {
|
||||||
|
return decode_json(JSON->new->convert_blessed->encode( shift ));
|
||||||
|
}
|
||||||
|
|
||||||
|
# used by JSON for serialization
|
||||||
|
sub TO_JSON {
|
||||||
|
my $self = shift;
|
||||||
|
my $_data = {};
|
||||||
|
foreach my $_key (keys %{$self->attribute_map}) {
|
||||||
|
if (defined $self->{$_key}) {
|
||||||
|
$_data->{$self->attribute_map->{$_key}} = $self->{$_key};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
# from Perl hashref
|
||||||
|
sub from_hash {
|
||||||
|
my ($self, $hash) = @_;
|
||||||
|
|
||||||
|
# loop through attributes and use swagger_types to deserialize the data
|
||||||
|
while ( my ($_key, $_type) = each %{$self->swagger_types} ) {
|
||||||
|
my $_json_attribute = $self->attribute_map->{$_key};
|
||||||
|
if ($_type =~ /^array\[/i) { # array
|
||||||
|
my $_subclass = substr($_type, 6, -1);
|
||||||
|
my @_array = ();
|
||||||
|
foreach my $_element (@{$hash->{$_json_attribute}}) {
|
||||||
|
push @_array, $self->_deserialize($_subclass, $_element);
|
||||||
|
}
|
||||||
|
$self->{$_key} = \@_array;
|
||||||
|
} elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
|
||||||
|
$self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute});
|
||||||
|
} else {
|
||||||
|
$log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
# deserialize non-array data
|
||||||
|
sub _deserialize {
|
||||||
|
my ($self, $type, $data) = @_;
|
||||||
|
$log->debugf("deserializing %s with %s",Dumper($data), $type);
|
||||||
|
|
||||||
|
if ($type eq 'DateTime') {
|
||||||
|
return DateTime->from_epoch(epoch => str2time($data));
|
||||||
|
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
|
||||||
|
return $data;
|
||||||
|
} else { # hash(model)
|
||||||
|
my $_instance = eval "WWW::SwaggerClient::Object::$type->new()";
|
||||||
|
return $_instance->from_hash($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
__PACKAGE__->class_documentation({description => '',
|
__PACKAGE__->class_documentation({description => '',
|
||||||
class => 'Tag',
|
class => 'Tag',
|
||||||
required => [], # TODO
|
required => [], # TODO
|
||||||
@ -54,4 +133,5 @@ __PACKAGE__->attribute_map( {
|
|||||||
|
|
||||||
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
||||||
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
@ -11,7 +11,9 @@ use Log::Any qw($log);
|
|||||||
use Date::Parse;
|
use Date::Parse;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
|
||||||
use base "WWW::SwaggerClient::Object::BaseObject";
|
#use base "WWW::SwaggerClient::Object::BaseObject";
|
||||||
|
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
@ -19,6 +21,83 @@ use base "WWW::SwaggerClient::Object::BaseObject";
|
|||||||
#NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
#NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
__PACKAGE__->mk_classdata('attribute_map' => {});
|
||||||
|
__PACKAGE__->mk_classdata('swagger_types' => {});
|
||||||
|
__PACKAGE__->mk_classdata('method_documentation' => {});
|
||||||
|
__PACKAGE__->mk_classdata('class_documentation' => {});
|
||||||
|
|
||||||
|
# new object
|
||||||
|
sub new {
|
||||||
|
my ($class, %args) = @_;
|
||||||
|
|
||||||
|
my $self = bless {}, $class;
|
||||||
|
|
||||||
|
foreach my $attribute (keys %{$class->attribute_map}) {
|
||||||
|
my $args_key = $class->attribute_map->{$attribute};
|
||||||
|
$self->$attribute( $args{ $args_key } );
|
||||||
|
}
|
||||||
|
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
# return perl hash
|
||||||
|
sub to_hash {
|
||||||
|
return decode_json(JSON->new->convert_blessed->encode( shift ));
|
||||||
|
}
|
||||||
|
|
||||||
|
# used by JSON for serialization
|
||||||
|
sub TO_JSON {
|
||||||
|
my $self = shift;
|
||||||
|
my $_data = {};
|
||||||
|
foreach my $_key (keys %{$self->attribute_map}) {
|
||||||
|
if (defined $self->{$_key}) {
|
||||||
|
$_data->{$self->attribute_map->{$_key}} = $self->{$_key};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
# from Perl hashref
|
||||||
|
sub from_hash {
|
||||||
|
my ($self, $hash) = @_;
|
||||||
|
|
||||||
|
# loop through attributes and use swagger_types to deserialize the data
|
||||||
|
while ( my ($_key, $_type) = each %{$self->swagger_types} ) {
|
||||||
|
my $_json_attribute = $self->attribute_map->{$_key};
|
||||||
|
if ($_type =~ /^array\[/i) { # array
|
||||||
|
my $_subclass = substr($_type, 6, -1);
|
||||||
|
my @_array = ();
|
||||||
|
foreach my $_element (@{$hash->{$_json_attribute}}) {
|
||||||
|
push @_array, $self->_deserialize($_subclass, $_element);
|
||||||
|
}
|
||||||
|
$self->{$_key} = \@_array;
|
||||||
|
} elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
|
||||||
|
$self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute});
|
||||||
|
} else {
|
||||||
|
$log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
# deserialize non-array data
|
||||||
|
sub _deserialize {
|
||||||
|
my ($self, $type, $data) = @_;
|
||||||
|
$log->debugf("deserializing %s with %s",Dumper($data), $type);
|
||||||
|
|
||||||
|
if ($type eq 'DateTime') {
|
||||||
|
return DateTime->from_epoch(epoch => str2time($data));
|
||||||
|
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
|
||||||
|
return $data;
|
||||||
|
} else { # hash(model)
|
||||||
|
my $_instance = eval "WWW::SwaggerClient::Object::$type->new()";
|
||||||
|
return $_instance->from_hash($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
__PACKAGE__->class_documentation({description => '',
|
__PACKAGE__->class_documentation({description => '',
|
||||||
class => 'User',
|
class => 'User',
|
||||||
required => [], # TODO
|
required => [], # TODO
|
||||||
@ -108,4 +187,5 @@ __PACKAGE__->attribute_map( {
|
|||||||
|
|
||||||
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
||||||
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
@ -567,6 +567,65 @@ sub delete_pet {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# download_file
|
||||||
|
#
|
||||||
|
# downloads an image
|
||||||
|
#
|
||||||
|
{
|
||||||
|
my $params = {
|
||||||
|
};
|
||||||
|
__PACKAGE__->method_documentation->{ download_file } = {
|
||||||
|
summary => 'downloads an image',
|
||||||
|
params => $params,
|
||||||
|
returns => 'File',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
# @return File
|
||||||
|
#
|
||||||
|
sub download_file {
|
||||||
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# parse inputs
|
||||||
|
my $_resource_path = '/pet/{petId}/downloadImage';
|
||||||
|
$_resource_path =~ s/{format}/json/; # default format to json
|
||||||
|
|
||||||
|
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('application/octet-stream');
|
||||||
|
if ($_header_accept) {
|
||||||
|
$header_params->{'Accept'} = $_header_accept;
|
||||||
|
}
|
||||||
|
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
my $_body_data;
|
||||||
|
|
||||||
|
|
||||||
|
# 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('File', $response);
|
||||||
|
return $_response_object;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
# upload_file
|
# upload_file
|
||||||
#
|
#
|
||||||
|
@ -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-20T17:35:18.902+08:00',
|
generated_date => '2015-12-28T16:00:32.828+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-20T17:35:18.902+08:00
|
=item Build date: 2015-12-28T16:00:32.828+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