Rebuild perl petstore client after previous updates

At least 2 previous updates were committed without rebuilding the perl
petstore client. One was my fault (BaseObject.pm changes), the other
changes come from an upstream update or updates  I can't identify.
This commit is contained in:
Dave Baird 2015-11-03 16:46:47 +01:00
parent 1b538f6eaf
commit 8428e7963b
7 changed files with 169 additions and 49 deletions

View File

@ -153,6 +153,7 @@ sub to_query_value {
} }
} }
# Take value and turn it into a string suitable for inclusion in # Take value and turn it into a string suitable for inclusion in
# the header. If it's a string, pass through unchanged # the header. If it's a string, pass through unchanged
# If it's a datetime object, format it in ISO8601 # If it's a datetime object, format it in ISO8601

View File

@ -0,0 +1,59 @@
package WWW::SwaggerClient::Object::ApiResponse;
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 "WWW::SwaggerClient::Object::BaseObject";
#
#
#
#NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
#
my $swagger_types = {
'code' => 'int',
'type' => 'string',
'message' => 'string'
};
my $attribute_map = {
'code' => 'code',
'type' => 'type',
'message' => 'message'
};
# new object
sub new {
my ($class, %args) = @_;
my $self = {
#
'code' => $args{'code'},
#
'type' => $args{'type'},
#
'message' => $args{'message'}
};
return bless $self, $class;
}
# get swagger type of the attribute
sub get_swagger_types {
return $swagger_types;
}
# get attribute mappping
sub get_attribute_map {
return $attribute_map;
}
1;

View File

@ -19,7 +19,7 @@ use DateTime;
# #
# return json string # return perl hash
sub to_hash { sub to_hash {
return decode_json(JSON->new->convert_blessed->encode( shift )); return decode_json(JSON->new->convert_blessed->encode( shift ));
} }
@ -36,28 +36,30 @@ sub TO_JSON {
return $_data; return $_data;
} }
# from json string # from Perl hashref
sub from_hash { sub from_hash {
my ($self, $hash) = @_; my ($self, $hash) = @_;
# loop through attributes and use swagger_types to deserialize the data # loop through attributes and use swagger_types to deserialize the data
while ( my ($_key, $_type) = each %{$self->get_swagger_types} ) { while ( my ($_key, $_type) = each %{$self->get_swagger_types} ) {
my $_json_attribute = $self->get_attribute_map->{$_key};
if ($_type =~ /^array\[/i) { # array if ($_type =~ /^array\[/i) { # array
my $_subclass = substr($_type, 6, -1); my $_subclass = substr($_type, 6, -1);
my @_array = (); my @_array = ();
foreach my $_element (@{$hash->{$self->get_attribute_map->{$_key}}}) { foreach my $_element (@{$hash->{$_json_attribute}}) {
push @_array, $self->_deserialize($_subclass, $_element); push @_array, $self->_deserialize($_subclass, $_element);
} }
$self->{$_key} = \@_array; $self->{$_key} = \@_array;
} elsif (defined $hash->{$_key}) { #hash(model), primitive, datetime } elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
$self->{$_key} = $self->_deserialize($_type, $hash->{$_key}); $self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute});
} else { } else {
$log->debugf("warning: %s not defined\n", $_key); $log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
} }
} }
return $self; return $self;
} }
# deserialize non-array data # deserialize non-array data
sub _deserialize { sub _deserialize {
my ($self, $type, $data) = @_; my ($self, $type, $data) = @_;

View File

@ -52,13 +52,18 @@ sub new {
# #
# Update an existing pet # Update an existing pet
# #
# @param Pet $body Pet object that needs to be added to the store (optional) # @param Pet $body Pet object that needs to be added to the store (required)
# @return void # @return void
# #
sub update_pet { sub update_pet {
my ($self, %args) = @_; my ($self, %args) = @_;
# verify the required parameter 'body' is set
unless (exists $args{'body'}) {
croak("Missing the required parameter 'body' when calling update_pet");
}
# parse inputs # parse inputs
my $_resource_path = '/pet'; my $_resource_path = '/pet';
@ -70,7 +75,7 @@ sub update_pet {
my $form_params = {}; my $form_params = {};
# 'Accept' and 'Content-Type' header # 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml'); my $_header_accept = $self->{api_client}->select_header_accept('application/xml', 'application/json');
if ($_header_accept) { if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept; $header_params->{'Accept'} = $_header_accept;
} }
@ -102,13 +107,18 @@ sub update_pet {
# #
# Add a new pet to the store # Add a new pet to the store
# #
# @param Pet $body Pet object that needs to be added to the store (optional) # @param Pet $body Pet object that needs to be added to the store (required)
# @return void # @return void
# #
sub add_pet { sub add_pet {
my ($self, %args) = @_; my ($self, %args) = @_;
# verify the required parameter 'body' is set
unless (exists $args{'body'}) {
croak("Missing the required parameter 'body' when calling add_pet");
}
# parse inputs # parse inputs
my $_resource_path = '/pet'; my $_resource_path = '/pet';
@ -120,7 +130,7 @@ sub add_pet {
my $form_params = {}; my $form_params = {};
# 'Accept' and 'Content-Type' header # 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml'); my $_header_accept = $self->{api_client}->select_header_accept('application/xml', 'application/json');
if ($_header_accept) { if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept; $header_params->{'Accept'} = $_header_accept;
} }
@ -152,13 +162,18 @@ sub add_pet {
# #
# Finds Pets by status # Finds Pets by status
# #
# @param ARRAY[string] $status Status values that need to be considered for filter (optional) # @param ARRAY[string] $status Status values that need to be considered for filter (required)
# @return ARRAY[Pet] # @return ARRAY[Pet]
# #
sub find_pets_by_status { sub find_pets_by_status {
my ($self, %args) = @_; my ($self, %args) = @_;
# verify the required parameter 'status' is set
unless (exists $args{'status'}) {
croak("Missing the required parameter 'status' when calling find_pets_by_status");
}
# parse inputs # parse inputs
my $_resource_path = '/pet/findByStatus'; my $_resource_path = '/pet/findByStatus';
@ -170,7 +185,7 @@ sub find_pets_by_status {
my $form_params = {}; my $form_params = {};
# 'Accept' and 'Content-Type' header # 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml'); my $_header_accept = $self->{api_client}->select_header_accept('application/xml', 'application/json');
if ($_header_accept) { if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept; $header_params->{'Accept'} = $_header_accept;
} }
@ -205,13 +220,18 @@ sub find_pets_by_status {
# #
# Finds Pets by tags # Finds Pets by tags
# #
# @param ARRAY[string] $tags Tags to filter by (optional) # @param ARRAY[string] $tags Tags to filter by (required)
# @return ARRAY[Pet] # @return ARRAY[Pet]
# #
sub find_pets_by_tags { sub find_pets_by_tags {
my ($self, %args) = @_; my ($self, %args) = @_;
# verify the required parameter 'tags' is set
unless (exists $args{'tags'}) {
croak("Missing the required parameter 'tags' when calling find_pets_by_tags");
}
# parse inputs # parse inputs
my $_resource_path = '/pet/findByTags'; my $_resource_path = '/pet/findByTags';
@ -223,7 +243,7 @@ sub find_pets_by_tags {
my $form_params = {}; my $form_params = {};
# 'Accept' and 'Content-Type' header # 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml'); my $_header_accept = $self->{api_client}->select_header_accept('application/xml', 'application/json');
if ($_header_accept) { if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept; $header_params->{'Accept'} = $_header_accept;
} }
@ -258,7 +278,7 @@ sub find_pets_by_tags {
# #
# Find pet by ID # Find pet by ID
# #
# @param int $pet_id ID of pet that needs to be fetched (required) # @param int $pet_id ID of pet to return (required)
# @return Pet # @return Pet
# #
sub get_pet_by_id { sub get_pet_by_id {
@ -281,7 +301,7 @@ sub get_pet_by_id {
my $form_params = {}; my $form_params = {};
# 'Accept' and 'Content-Type' header # 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml'); my $_header_accept = $self->{api_client}->select_header_accept('application/xml', 'application/json');
if ($_header_accept) { if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept; $header_params->{'Accept'} = $_header_accept;
} }
@ -300,7 +320,7 @@ sub get_pet_by_id {
# authentication setting, if any # authentication setting, if any
my $auth_settings = ['api_key', 'petstore_auth']; my $auth_settings = ['api_key'];
# make the API Call # make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method, my $response = $self->{api_client}->call_api($_resource_path, $_method,
@ -318,7 +338,7 @@ sub get_pet_by_id {
# #
# Updates a pet in the store with form data # Updates a pet in the store with form data
# #
# @param string $pet_id ID of pet that needs to be updated (required) # @param int $pet_id ID of pet that needs to be updated (required)
# @param string $name Updated name of the pet (optional) # @param string $name Updated name of the pet (optional)
# @param string $status Updated status of the pet (optional) # @param string $status Updated status of the pet (optional)
# @return void # @return void
@ -343,7 +363,7 @@ sub update_pet_with_form {
my $form_params = {}; my $form_params = {};
# 'Accept' and 'Content-Type' header # 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml'); my $_header_accept = $self->{api_client}->select_header_accept('application/xml', 'application/json');
if ($_header_accept) { if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept; $header_params->{'Accept'} = $_header_accept;
} }
@ -411,7 +431,7 @@ sub delete_pet {
my $form_params = {}; my $form_params = {};
# 'Accept' and 'Content-Type' header # 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml'); my $_header_accept = $self->{api_client}->select_header_accept('application/xml', 'application/json');
if ($_header_accept) { if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept; $header_params->{'Accept'} = $_header_accept;
} }
@ -451,7 +471,7 @@ sub delete_pet {
# @param int $pet_id ID of pet to update (required) # @param int $pet_id ID of pet to update (required)
# @param string $additional_metadata Additional data to pass to server (optional) # @param string $additional_metadata Additional data to pass to server (optional)
# @param file $file file to upload (optional) # @param file $file file to upload (optional)
# @return void # @return ApiResponse
# #
sub upload_file { sub upload_file {
my ($self, %args) = @_; my ($self, %args) = @_;
@ -473,7 +493,7 @@ sub upload_file {
my $form_params = {}; my $form_params = {};
# 'Accept' and 'Content-Type' header # 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml'); my $_header_accept = $self->{api_client}->select_header_accept('application/json');
if ($_header_accept) { if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept; $header_params->{'Accept'} = $_header_accept;
} }
@ -506,11 +526,14 @@ sub upload_file {
my $auth_settings = ['petstore_auth']; my $auth_settings = ['petstore_auth'];
# make the API Call # make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params, $query_params, $form_params,
$header_params, $_body_data, $auth_settings); $header_params, $_body_data, $auth_settings);
return; if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('ApiResponse', $response);
return $_response_object;
} }

View File

@ -69,7 +69,7 @@ sub get_inventory {
my $form_params = {}; my $form_params = {};
# 'Accept' and 'Content-Type' header # 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml'); my $_header_accept = $self->{api_client}->select_header_accept('application/json');
if ($_header_accept) { if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept; $header_params->{'Accept'} = $_header_accept;
} }
@ -101,13 +101,18 @@ sub get_inventory {
# #
# Place an order for a pet # Place an order for a pet
# #
# @param Order $body order placed for purchasing the pet (optional) # @param Order $body order placed for purchasing the pet (required)
# @return Order # @return Order
# #
sub place_order { sub place_order {
my ($self, %args) = @_; my ($self, %args) = @_;
# verify the required parameter 'body' is set
unless (exists $args{'body'}) {
croak("Missing the required parameter 'body' when calling place_order");
}
# parse inputs # parse inputs
my $_resource_path = '/store/order'; my $_resource_path = '/store/order';
@ -119,7 +124,7 @@ sub place_order {
my $form_params = {}; my $form_params = {};
# 'Accept' and 'Content-Type' header # 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml'); my $_header_accept = $self->{api_client}->select_header_accept('application/xml', 'application/json');
if ($_header_accept) { if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept; $header_params->{'Accept'} = $_header_accept;
} }
@ -154,7 +159,7 @@ sub place_order {
# #
# Find purchase order by ID # Find purchase order by ID
# #
# @param string $order_id ID of pet that needs to be fetched (required) # @param int $order_id ID of pet that needs to be fetched (required)
# @return Order # @return Order
# #
sub get_order_by_id { sub get_order_by_id {
@ -177,7 +182,7 @@ sub get_order_by_id {
my $form_params = {}; my $form_params = {};
# 'Accept' and 'Content-Type' header # 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml'); my $_header_accept = $self->{api_client}->select_header_accept('application/xml', 'application/json');
if ($_header_accept) { if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept; $header_params->{'Accept'} = $_header_accept;
} }
@ -237,7 +242,7 @@ sub delete_order {
my $form_params = {}; my $form_params = {};
# 'Accept' and 'Content-Type' header # 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml'); my $_header_accept = $self->{api_client}->select_header_accept('application/xml', 'application/json');
if ($_header_accept) { if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept; $header_params->{'Accept'} = $_header_accept;
} }

View File

@ -52,13 +52,18 @@ sub new {
# #
# Create user # Create user
# #
# @param User $body Created user object (optional) # @param User $body Created user object (required)
# @return void # @return void
# #
sub create_user { sub create_user {
my ($self, %args) = @_; my ($self, %args) = @_;
# verify the required parameter 'body' is set
unless (exists $args{'body'}) {
croak("Missing the required parameter 'body' when calling create_user");
}
# parse inputs # parse inputs
my $_resource_path = '/user'; my $_resource_path = '/user';
@ -70,7 +75,7 @@ sub create_user {
my $form_params = {}; my $form_params = {};
# 'Accept' and 'Content-Type' header # 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml'); my $_header_accept = $self->{api_client}->select_header_accept('application/xml', 'application/json');
if ($_header_accept) { if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept; $header_params->{'Accept'} = $_header_accept;
} }
@ -102,13 +107,18 @@ sub create_user {
# #
# Creates list of users with given input array # Creates list of users with given input array
# #
# @param ARRAY[User] $body List of user object (optional) # @param ARRAY[User] $body List of user object (required)
# @return void # @return void
# #
sub create_users_with_array_input { sub create_users_with_array_input {
my ($self, %args) = @_; my ($self, %args) = @_;
# verify the required parameter 'body' is set
unless (exists $args{'body'}) {
croak("Missing the required parameter 'body' when calling create_users_with_array_input");
}
# parse inputs # parse inputs
my $_resource_path = '/user/createWithArray'; my $_resource_path = '/user/createWithArray';
@ -120,7 +130,7 @@ sub create_users_with_array_input {
my $form_params = {}; my $form_params = {};
# 'Accept' and 'Content-Type' header # 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml'); my $_header_accept = $self->{api_client}->select_header_accept('application/xml', 'application/json');
if ($_header_accept) { if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept; $header_params->{'Accept'} = $_header_accept;
} }
@ -152,13 +162,18 @@ sub create_users_with_array_input {
# #
# Creates list of users with given input array # Creates list of users with given input array
# #
# @param ARRAY[User] $body List of user object (optional) # @param ARRAY[User] $body List of user object (required)
# @return void # @return void
# #
sub create_users_with_list_input { sub create_users_with_list_input {
my ($self, %args) = @_; my ($self, %args) = @_;
# verify the required parameter 'body' is set
unless (exists $args{'body'}) {
croak("Missing the required parameter 'body' when calling create_users_with_list_input");
}
# parse inputs # parse inputs
my $_resource_path = '/user/createWithList'; my $_resource_path = '/user/createWithList';
@ -170,7 +185,7 @@ sub create_users_with_list_input {
my $form_params = {}; my $form_params = {};
# 'Accept' and 'Content-Type' header # 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml'); my $_header_accept = $self->{api_client}->select_header_accept('application/xml', 'application/json');
if ($_header_accept) { if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept; $header_params->{'Accept'} = $_header_accept;
} }
@ -202,14 +217,24 @@ sub create_users_with_list_input {
# #
# Logs user into the system # Logs user into the system
# #
# @param string $username The user name for login (optional) # @param string $username The user name for login (required)
# @param string $password The password for login in clear text (optional) # @param string $password The password for login in clear text (required)
# @return string # @return string
# #
sub login_user { sub login_user {
my ($self, %args) = @_; my ($self, %args) = @_;
# verify the required parameter 'username' is set
unless (exists $args{'username'}) {
croak("Missing the required parameter 'username' when calling login_user");
}
# verify the required parameter 'password' is set
unless (exists $args{'password'}) {
croak("Missing the required parameter 'password' when calling login_user");
}
# parse inputs # parse inputs
my $_resource_path = '/user/login'; my $_resource_path = '/user/login';
@ -221,7 +246,7 @@ sub login_user {
my $form_params = {}; my $form_params = {};
# 'Accept' and 'Content-Type' header # 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml'); my $_header_accept = $self->{api_client}->select_header_accept('application/xml', 'application/json');
if ($_header_accept) { if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept; $header_params->{'Accept'} = $_header_accept;
} }
@ -276,7 +301,7 @@ sub logout_user {
my $form_params = {}; my $form_params = {};
# 'Accept' and 'Content-Type' header # 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml'); my $_header_accept = $self->{api_client}->select_header_accept('application/xml', 'application/json');
if ($_header_accept) { if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept; $header_params->{'Accept'} = $_header_accept;
} }
@ -328,7 +353,7 @@ sub get_user_by_name {
my $form_params = {}; my $form_params = {};
# 'Accept' and 'Content-Type' header # 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml'); my $_header_accept = $self->{api_client}->select_header_accept('application/xml', 'application/json');
if ($_header_accept) { if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept; $header_params->{'Accept'} = $_header_accept;
} }
@ -366,7 +391,7 @@ sub get_user_by_name {
# Updated user # Updated user
# #
# @param string $username name that need to be deleted (required) # @param string $username name that need to be deleted (required)
# @param User $body Updated user object (optional) # @param User $body Updated user object (required)
# @return void # @return void
# #
sub update_user { sub update_user {
@ -378,6 +403,11 @@ sub update_user {
croak("Missing the required parameter 'username' when calling update_user"); croak("Missing the required parameter 'username' when calling update_user");
} }
# verify the required parameter 'body' is set
unless (exists $args{'body'}) {
croak("Missing the required parameter 'body' when calling update_user");
}
# parse inputs # parse inputs
my $_resource_path = '/user/{username}'; my $_resource_path = '/user/{username}';
@ -389,7 +419,7 @@ sub update_user {
my $form_params = {}; my $form_params = {};
# 'Accept' and 'Content-Type' header # 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml'); my $_header_accept = $self->{api_client}->select_header_accept('application/xml', 'application/json');
if ($_header_accept) { if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept; $header_params->{'Accept'} = $_header_accept;
} }
@ -449,7 +479,7 @@ sub delete_user {
my $form_params = {}; my $form_params = {};
# 'Accept' and 'Content-Type' header # 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml'); my $_header_accept = $self->{api_client}->select_header_accept('application/xml', 'application/json');
if ($_header_accept) { if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept; $header_params->{'Accept'} = $_header_accept;
} }

View File

@ -1,4 +1,4 @@
use Test::More tests => 35; use Test::More tests => 37;
use Test::Exception; use Test::Exception;
use lib 'lib'; use lib 'lib';
@ -69,8 +69,8 @@ is $update_pet_with_form, undef, 'get the null response from update_pet_wth_form
my $get_pet_after_update = $api->get_pet_by_id(pet_id => $pet_id); my $get_pet_after_update = $api->get_pet_by_id(pet_id => $pet_id);
is $get_pet_after_update->{status}, 'sold', 'get the updated status after update_pet_with_form'; is $get_pet_after_update->{status}, 'sold', 'get the updated status after update_pet_with_form';
my $upload_pet = $api->upload_file(pet_id => $pet_id, additional_metadata => 'testabc', file => 'test.pl'); my $upload_file = $api->upload_file(pet_id => $pet_id, additional_metadata => 'testabc', file => 'test.pl');
is $upload_pet, undef, 'get the null response from upload_pet'; isa_ok($upload_file, 'WWW::SwaggerClient::Object::ApiResponse'); # WWW::SwaggerClient::Object::Pet
my $delete_pet = $api->delete_pet(pet_id => $pet_id); my $delete_pet = $api->delete_pet(pet_id => $pet_id);
is $delete_pet, undef, 'get the null response from delete_pet'; is $delete_pet, undef, 'get the null response from delete_pet';