Add perltidy to format Perl code (#970)

* add perl tidy without updating petstore samples

* incldue pl file, update samples

* use no backup option, perltidy on test.pl
This commit is contained in:
William Cheng
2018-09-06 14:46:02 +08:00
committed by GitHub
parent 39c734fc25
commit e29f263941
62 changed files with 5968 additions and 4212 deletions

View File

@@ -32,7 +32,7 @@ import java.util.HashSet;
import java.util.regex.Matcher;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.io.FilenameUtils;
public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig {
private static final Logger LOGGER = LoggerFactory.getLogger(PerlClientCodegen.class);
@@ -133,6 +133,10 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig {
public void processOpts() {
super.processOpts();
if (StringUtils.isEmpty(System.getenv("PERLTIDY_PATH"))) {
LOGGER.info("Environment variable PERLTIDY_PATH not defined so the Perl code may not be properly formatted. To define it, try 'export PERLTIDY_PATH=/usr/local/bin/perltidy' (Linux/Mac)");
}
if (additionalProperties.containsKey(MODULE_VERSION)) {
setModuleVersion((String) additionalProperties.get(MODULE_VERSION));
} else {
@@ -560,4 +564,33 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig {
// remove =end, =cut to avoid code injection
return input.replace("=begin", "=_begin").replace("=end", "=_end").replace("=cut", "=_cut").replace("=pod", "=_pod");
}
@Override
public void postProcessFile(File file, String fileType) {
if (file == null) {
return;
}
String perlTidyPath = System.getenv("PERLTIDY_PATH");
if (StringUtils.isEmpty(perlTidyPath)) {
return; // skip if PERLTIDY_PATH env variable is not defined
}
// only process files with .t, .pm extension
if ("t".equals(FilenameUtils.getExtension(file.toString())) ||
"pm".equals(FilenameUtils.getExtension(file.toString())) ||
"pl".equals(FilenameUtils.getExtension(file.toString()))) {
String command = perlTidyPath + " -b -bext='/' " + file.toString();
try {
Process p = Runtime.getRuntime().exec(command);
p.waitFor();
if (p.exitValue() != 0) {
LOGGER.error("Error running the command ({}): {}", command, p.exitValue());
}
} catch (Exception e) {
LOGGER.error("Error running the command ({}): {}", command, e.getMessage());
}
LOGGER.info("Successfully executed: " + command);
}
}
}

View File

@@ -1 +1 @@
3.0.0-SNAPSHOT
3.3.0-SNAPSHOT

View File

@@ -248,6 +248,8 @@ use WWW::OpenAPIClient::Object::Dog;
use WWW::OpenAPIClient::Object::EnumArrays;
use WWW::OpenAPIClient::Object::EnumClass;
use WWW::OpenAPIClient::Object::EnumTest;
use WWW::OpenAPIClient::Object::File;
use WWW::OpenAPIClient::Object::FileSchemaTestClass;
use WWW::OpenAPIClient::Object::FormatTest;
use WWW::OpenAPIClient::Object::HasOnlyReadOnly;
use WWW::OpenAPIClient::Object::List;
@@ -263,6 +265,7 @@ use WWW::OpenAPIClient::Object::OuterEnum;
use WWW::OpenAPIClient::Object::Pet;
use WWW::OpenAPIClient::Object::ReadOnlyFirst;
use WWW::OpenAPIClient::Object::SpecialModelName;
use WWW::OpenAPIClient::Object::StringBooleanMap;
use WWW::OpenAPIClient::Object::Tag;
use WWW::OpenAPIClient::Object::User;
@@ -300,6 +303,8 @@ use WWW::OpenAPIClient::Object::Dog;
use WWW::OpenAPIClient::Object::EnumArrays;
use WWW::OpenAPIClient::Object::EnumClass;
use WWW::OpenAPIClient::Object::EnumTest;
use WWW::OpenAPIClient::Object::File;
use WWW::OpenAPIClient::Object::FileSchemaTestClass;
use WWW::OpenAPIClient::Object::FormatTest;
use WWW::OpenAPIClient::Object::HasOnlyReadOnly;
use WWW::OpenAPIClient::Object::List;
@@ -315,6 +320,7 @@ use WWW::OpenAPIClient::Object::OuterEnum;
use WWW::OpenAPIClient::Object::Pet;
use WWW::OpenAPIClient::Object::ReadOnlyFirst;
use WWW::OpenAPIClient::Object::SpecialModelName;
use WWW::OpenAPIClient::Object::StringBooleanMap;
use WWW::OpenAPIClient::Object::Tag;
use WWW::OpenAPIClient::Object::User;
@@ -328,11 +334,11 @@ my $api_instance = WWW::OpenAPIClient::->new(
my $client = WWW::OpenAPIClient::Object::Client->new(); # Client | client model
eval {
my $result = $api_instance->test_special_tags(client => $client);
my $result = $api_instance->call_123_test_special_tags(client => $client);
print Dumper($result);
};
if ($@) {
warn "Exception when calling AnotherFakeApi->test_special_tags: $@\n";
warn "Exception when calling AnotherFakeApi->call_123_test_special_tags: $@\n";
}
```
@@ -343,11 +349,12 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*
Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*AnotherFakeApi* | [**test_special_tags**](docs/AnotherFakeApi.md#test_special_tags) | **PATCH** /another-fake/dummy | To test special tags
*AnotherFakeApi* | [**call_123_test_special_tags**](docs/AnotherFakeApi.md#call_123_test_special_tags) | **PATCH** /another-fake/dummy | To test special tags
*FakeApi* | [**fake_outer_boolean_serialize**](docs/FakeApi.md#fake_outer_boolean_serialize) | **POST** /fake/outer/boolean |
*FakeApi* | [**fake_outer_composite_serialize**](docs/FakeApi.md#fake_outer_composite_serialize) | **POST** /fake/outer/composite |
*FakeApi* | [**fake_outer_number_serialize**](docs/FakeApi.md#fake_outer_number_serialize) | **POST** /fake/outer/number |
*FakeApi* | [**fake_outer_string_serialize**](docs/FakeApi.md#fake_outer_string_serialize) | **POST** /fake/outer/string |
*FakeApi* | [**test_body_with_file_schema**](docs/FakeApi.md#test_body_with_file_schema) | **PUT** /fake/body-with-file-schema |
*FakeApi* | [**test_body_with_query_params**](docs/FakeApi.md#test_body_with_query_params) | **PUT** /fake/body-with-query-params |
*FakeApi* | [**test_client_model**](docs/FakeApi.md#test_client_model) | **PATCH** /fake | To test \"client\" model
*FakeApi* | [**test_endpoint_parameters**](docs/FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
@@ -363,6 +370,7 @@ Class | Method | HTTP request | Description
*PetApi* | [**update_pet**](docs/PetApi.md#update_pet) | **PUT** /pet | Update an existing pet
*PetApi* | [**update_pet_with_form**](docs/PetApi.md#update_pet_with_form) | **POST** /pet/{petId} | Updates a pet in the store with form data
*PetApi* | [**upload_file**](docs/PetApi.md#upload_file) | **POST** /pet/{petId}/uploadImage | uploads an image
*PetApi* | [**upload_file_with_required_file**](docs/PetApi.md#upload_file_with_required_file) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required)
*StoreApi* | [**delete_order**](docs/StoreApi.md#delete_order) | **DELETE** /store/order/{order_id} | Delete purchase order by ID
*StoreApi* | [**get_inventory**](docs/StoreApi.md#get_inventory) | **GET** /store/inventory | Returns pet inventories by status
*StoreApi* | [**get_order_by_id**](docs/StoreApi.md#get_order_by_id) | **GET** /store/order/{order_id} | Find purchase order by ID
@@ -394,6 +402,8 @@ Class | Method | HTTP request | Description
- [WWW::OpenAPIClient::Object::EnumArrays](docs/EnumArrays.md)
- [WWW::OpenAPIClient::Object::EnumClass](docs/EnumClass.md)
- [WWW::OpenAPIClient::Object::EnumTest](docs/EnumTest.md)
- [WWW::OpenAPIClient::Object::File](docs/File.md)
- [WWW::OpenAPIClient::Object::FileSchemaTestClass](docs/FileSchemaTestClass.md)
- [WWW::OpenAPIClient::Object::FormatTest](docs/FormatTest.md)
- [WWW::OpenAPIClient::Object::HasOnlyReadOnly](docs/HasOnlyReadOnly.md)
- [WWW::OpenAPIClient::Object::List](docs/List.md)
@@ -409,6 +419,7 @@ Class | Method | HTTP request | Description
- [WWW::OpenAPIClient::Object::Pet](docs/Pet.md)
- [WWW::OpenAPIClient::Object::ReadOnlyFirst](docs/ReadOnlyFirst.md)
- [WWW::OpenAPIClient::Object::SpecialModelName](docs/SpecialModelName.md)
- [WWW::OpenAPIClient::Object::StringBooleanMap](docs/StringBooleanMap.md)
- [WWW::OpenAPIClient::Object::Tag](docs/Tag.md)
- [WWW::OpenAPIClient::Object::User](docs/User.md)

View File

@@ -9,15 +9,15 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*
Method | HTTP request | Description
------------- | ------------- | -------------
[**test_special_tags**](AnotherFakeApi.md#test_special_tags) | **PATCH** /another-fake/dummy | To test special tags
[**call_123_test_special_tags**](AnotherFakeApi.md#call_123_test_special_tags) | **PATCH** /another-fake/dummy | To test special tags
# **test_special_tags**
> Client test_special_tags(client => $client)
# **call_123_test_special_tags**
> Client call_123_test_special_tags(client => $client)
To test special tags
To test special tags
To test special tags and operation ID starting with number
### Example
```perl
@@ -29,11 +29,11 @@ my $api_instance = WWW::OpenAPIClient::AnotherFakeApi->new(
my $client = WWW::OpenAPIClient::Object::Client->new(); # Client | client model
eval {
my $result = $api_instance->test_special_tags(client => $client);
my $result = $api_instance->call_123_test_special_tags(client => $client);
print Dumper($result);
};
if ($@) {
warn "Exception when calling AnotherFakeApi->test_special_tags: $@\n";
warn "Exception when calling AnotherFakeApi->call_123_test_special_tags: $@\n";
}
```

View File

@@ -13,6 +13,7 @@ Method | HTTP request | Description
[**fake_outer_composite_serialize**](FakeApi.md#fake_outer_composite_serialize) | **POST** /fake/outer/composite |
[**fake_outer_number_serialize**](FakeApi.md#fake_outer_number_serialize) | **POST** /fake/outer/number |
[**fake_outer_string_serialize**](FakeApi.md#fake_outer_string_serialize) | **POST** /fake/outer/string |
[**test_body_with_file_schema**](FakeApi.md#test_body_with_file_schema) | **PUT** /fake/body-with-file-schema |
[**test_body_with_query_params**](FakeApi.md#test_body_with_query_params) | **PUT** /fake/body-with-query-params |
[**test_client_model**](FakeApi.md#test_client_model) | **PATCH** /fake | To test \"client\" model
[**test_endpoint_parameters**](FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
@@ -205,6 +206,51 @@ No authorization required
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **test_body_with_file_schema**
> test_body_with_file_schema(file_schema_test_class => $file_schema_test_class)
For this test, the body for this request much reference a schema named `File`.
### Example
```perl
use Data::Dumper;
use WWW::OpenAPIClient::FakeApi;
my $api_instance = WWW::OpenAPIClient::FakeApi->new(
);
my $file_schema_test_class = WWW::OpenAPIClient::Object::FileSchemaTestClass->new(); # FileSchemaTestClass |
eval {
$api_instance->test_body_with_file_schema(file_schema_test_class => $file_schema_test_class);
};
if ($@) {
warn "Exception when calling FakeApi->test_body_with_file_schema: $@\n";
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**file_schema_test_class** | [**FileSchemaTestClass**](FileSchemaTestClass.md)| |
### Return type
void (empty response body)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: application/json
- **Accept**: Not defined
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **test_body_with_query_params**
> test_body_with_query_params(query => $query, user => $user)
@@ -412,7 +458,7 @@ Name | Type | Description | Notes
**enum_query_string** | **string**| Query parameter enum test (string) | [optional] [default to '-efg']
**enum_query_integer** | **int**| Query parameter enum test (double) | [optional]
**enum_query_double** | **double**| Query parameter enum test (double) | [optional]
**enum_form_string_array** | **ARRAY[string]**| Form parameter enum test (string array) | [optional] [default to '$']
**enum_form_string_array** | [**ARRAY[string]**](string.md)| Form parameter enum test (string array) | [optional] [default to '$']
**enum_form_string** | **string**| Form parameter enum test (string) | [optional] [default to '-efg']
### Return type

View File

@@ -0,0 +1,15 @@
# WWW::OpenAPIClient::Object::File
## Load the model package
```perl
use WWW::OpenAPIClient::Object::File;
```
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**source_uri** | **string** | Test capitalization | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -0,0 +1,16 @@
# WWW::OpenAPIClient::Object::FileSchemaTestClass
## Load the model package
```perl
use WWW::OpenAPIClient::Object::FileSchemaTestClass;
```
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**file** | [**File**](File.md) | | [optional]
**files** | [**ARRAY[File]**](File.md) | | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -10,6 +10,8 @@ Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**map_map_of_string** | **HASH[string,HASH[string,string]]** | | [optional]
**map_of_enum_string** | **HASH[string,string]** | | [optional]
**direct_map** | **HASH[string,boolean]** | | [optional]
**indirect_map** | [**StringBooleanMap**](StringBooleanMap.md) | | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -17,6 +17,7 @@ Method | HTTP request | Description
[**update_pet**](PetApi.md#update_pet) | **PUT** /pet | Update an existing pet
[**update_pet_with_form**](PetApi.md#update_pet_with_form) | **POST** /pet/{petId} | Updates a pet in the store with form data
[**upload_file**](PetApi.md#upload_file) | **POST** /pet/{petId}/uploadImage | uploads an image
[**upload_file_with_required_file**](PetApi.md#upload_file_with_required_file) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required)
# **add_pet**
@@ -409,3 +410,54 @@ Name | Type | Description | Notes
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **upload_file_with_required_file**
> ApiResponse upload_file_with_required_file(pet_id => $pet_id, required_file => $required_file, additional_metadata => $additional_metadata)
uploads an image (required)
### Example
```perl
use Data::Dumper;
use WWW::OpenAPIClient::PetApi;
my $api_instance = WWW::OpenAPIClient::PetApi->new(
# Configure OAuth2 access token for authorization: petstore_auth
access_token => 'YOUR_ACCESS_TOKEN',
);
my $pet_id = 789; # int | ID of pet to update
my $required_file = "/path/to/file"; # string | file to upload
my $additional_metadata = "additional_metadata_example"; # string | Additional data to pass to server
eval {
my $result = $api_instance->upload_file_with_required_file(pet_id => $pet_id, required_file => $required_file, additional_metadata => $additional_metadata);
print Dumper($result);
};
if ($@) {
warn "Exception when calling PetApi->upload_file_with_required_file: $@\n";
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**pet_id** | **int**| ID of pet to update |
**required_file** | **string****string**| file to upload |
**additional_metadata** | **string**| Additional data to pass to server | [optional]
### Return type
[**ApiResponse**](ApiResponse.md)
### Authorization
[petstore_auth](../README.md#petstore_auth)
### HTTP request headers
- **Content-Type**: multipart/form-data
- **Accept**: application/json
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

View File

@@ -0,0 +1,14 @@
# WWW::OpenAPIClient::Object::StringBooleanMap
## Load the model package
```perl
use WWW::OpenAPIClient::Object::StringBooleanMap;
```
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -1,3 +1,4 @@
=begin comment
OpenAPI Petstore
@@ -39,7 +40,8 @@ sub new {
if ( $_[0] && ref $_[0] && ref $_[0] eq 'WWW::OpenAPIClient::ApiClient' ) {
$api_client = $_[0];
} else {
}
else {
$api_client = WWW::OpenAPIClient::ApiClient->new(@_);
}
@@ -47,9 +49,8 @@ sub new {
}
#
# test_special_tags
# call_123_test_special_tags
#
# To test special tags
#
@@ -62,20 +63,23 @@ sub new {
required => '1',
},
};
__PACKAGE__->method_documentation->{ 'test_special_tags' } = {
__PACKAGE__->method_documentation->{'call_123_test_special_tags'} = {
summary => 'To test special tags',
params => $params,
returns => 'Client',
};
}
# @return Client
#
sub test_special_tags {
sub call_123_test_special_tags {
my ( $self, %args ) = @_;
# verify the required parameter 'client' is set
unless ( exists $args{'client'} ) {
croak("Missing the required parameter 'client' when calling test_special_tags");
croak(
"Missing the required parameter 'client' when calling call_123_test_special_tags"
);
}
# parse inputs
@@ -87,13 +91,16 @@ sub test_special_tags {
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
my $_header_accept =
$self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/json');
$header_params->{'Content-Type'} =
$self->{api_client}->select_header_content_type('application/json');
my $_body_data;
# body params
if ( exists $args{'client'} ) {
$_body_data = $args{'client'};
@@ -103,13 +110,15 @@ sub test_special_tags {
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);
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('Client', $response);
my $_response_object =
$self->{api_client}->deserialize( 'Client', $response );
return $_response_object;
}

View File

@@ -1,3 +1,4 @@
=begin comment
OpenAPI Petstore
@@ -39,14 +40,17 @@ use Module::Runtime qw(use_module);
use WWW::OpenAPIClient::Configuration;
sub new {
my $class = shift;
my $config;
if ( $_[0] && ref $_[0] && ref $_[0] eq 'WWW::OpenAPIClient::Configuration' ) {
if ( $_[0]
&& ref $_[0]
&& ref $_[0] eq 'WWW::OpenAPIClient::Configuration' )
{
$config = $_[0];
} else {
}
else {
$config = WWW::OpenAPIClient::Configuration->new(@_);
}
@@ -88,38 +92,49 @@ sub set_timeout {
# @return mixed
sub call_api {
my $self = shift;
my ($resource_path, $method, $query_params, $post_params, $header_params, $body_data, $auth_settings) = @_;
my (
$resource_path, $method, $query_params, $post_params,
$header_params, $body_data, $auth_settings
) = @_;
# update parameters based on authentication settings
$self->update_params_for_auth($header_params, $query_params, $auth_settings);
$self->update_params_for_auth( $header_params, $query_params,
$auth_settings );
my $_url = $self->{config}{base_url} . $resource_path;
# build query
if (%$query_params) {
$_url = ($_url . '?' . eval { URI::Query->new($query_params)->stringify });
$_url =
( $_url . '?' . eval { URI::Query->new($query_params)->stringify } );
}
# body data
$body_data = to_json($body_data->to_hash) if defined $body_data && $body_data->can('to_hash'); # model to json string
$body_data = to_json( $body_data->to_hash )
if defined $body_data
&& $body_data->can('to_hash'); # model to json string
my $_body_data = %$post_params ? $post_params : $body_data;
# Make the HTTP request
my $_request;
if ( $method eq 'POST' ) {
# multipart
$header_params->{'Content-Type'} = lc $header_params->{'Content-Type'} eq 'multipart/form' ?
'form-data' : $header_params->{'Content-Type'};
$header_params->{'Content-Type'} =
lc $header_params->{'Content-Type'} eq 'multipart/form'
? 'form-data'
: $header_params->{'Content-Type'};
$_request = POST( $_url, %$header_params, Content => $_body_data );
}
elsif ( $method eq 'PUT' ) {
# multipart
$header_params->{'Content-Type'} = lc $header_params->{'Content-Type'} eq 'multipart/form' ?
'form-data' : $header_params->{'Content-Type'};
$header_params->{'Content-Type'} =
lc $header_params->{'Content-Type'} eq 'multipart/form'
? 'form-data'
: $header_params->{'Content-Type'};
$_request = PUT( $_url, %$header_params, Content => $_body_data );
@@ -141,15 +156,18 @@ sub call_api {
else {
}
$self->{ua}->timeout($self->{http_timeout} || $self->{config}{http_timeout});
$self->{ua}->agent($self->{http_user_agent} || $self->{config}{http_user_agent});
$self->{ua}
->timeout( $self->{http_timeout} || $self->{config}{http_timeout} );
$self->{ua}
->agent( $self->{http_user_agent} || $self->{config}{http_user_agent} );
$log->debugf( "REQUEST: %s", $_request->as_string );
my $_response = $self->{ua}->request($_request);
$log->debugf( "RESPONSE: %s", $_response->as_string );
unless ( $_response->is_success ) {
croak(sprintf "API Exception(%s): %s\n%s", $_response->code, $_response->message, $_response->content);
croak( sprintf "API Exception(%s): %s\n%s",
$_response->code, $_response->message, $_response->content );
}
return $_response->content;
@@ -165,7 +183,6 @@ sub to_path_value {
return uri_escape( $self->to_string($value) );
}
# Take value and turn it into a string suitable for inclusion in
# the query, by imploding comma-separated if it's an object.
# If it's a string, pass through unchanged. It will be url-encoded
@@ -176,12 +193,12 @@ sub to_query_value {
my ( $self, $object ) = @_;
if ( ref($object) eq 'ARRAY' ) {
return join( ',', @$object );
} else {
}
else {
return $self->to_string($object);
}
}
# Take value and turn it into a string suitable for inclusion in
# the header. If it's a string, pass through unchanged
# If it's a datetime object, format it in ISO8601
@@ -222,31 +239,36 @@ sub to_string {
# @param string $class class name is passed as a string
# @param string $data data of the body
# @return object an instance of $class
sub deserialize
{
sub deserialize {
my ( $self, $class, $data ) = @_;
$log->debugf( "deserializing %s for %s", $data, $class );
if ( not defined $data ) {
return undef;
} elsif ( (substr($class, 0, 5)) eq 'HASH[') { #hash
}
elsif ( ( substr( $class, 0, 5 ) ) eq 'HASH[' ) { #hash
if ( $class =~ /^HASH\[(.*),(.*)\]$/ ) {
my ( $key_type, $type ) = ( $1, $2 );
my %hash;
my $decoded_data = decode_json $data;
foreach my $key ( keys %$decoded_data ) {
if ( ref $decoded_data->{$key} eq 'HASH' ) {
$hash{$key} = $self->deserialize($type, encode_json $decoded_data->{$key});
} else {
$hash{$key} = $self->deserialize($type, $decoded_data->{$key});
$hash{$key} = $self->deserialize( $type,
encode_json $decoded_data->{$key} );
}
else {
$hash{$key} =
$self->deserialize( $type, $decoded_data->{$key} );
}
}
return \%hash;
} else {
}
else {
#TODO log error
}
} elsif ( (substr($class, 0, 6)) eq 'ARRAY[' ) { # array of data
}
elsif ( ( substr( $class, 0, 6 ) ) eq 'ARRAY[' ) { # array of data
return $data if $data eq '[]'; # return if empty array
my $_sub_class = substr( $class, 6, -1 );
@@ -254,21 +276,27 @@ sub deserialize
my @_values = ();
foreach my $_value (@$_json_data) {
if ( ref $_value eq 'ARRAY' ) {
push @_values, $self->deserialize($_sub_class, encode_json $_value);
} else {
push @_values,
$self->deserialize( $_sub_class, encode_json $_value);
}
else {
push @_values, $self->deserialize( $_sub_class, $_value );
}
}
return \@_values;
} elsif ($class eq 'DateTime') {
}
elsif ( $class eq 'DateTime' ) {
return DateTime->from_epoch( epoch => str2time($data) );
} elsif (grep /^$class$/, ('string', 'int', 'float', 'bool', 'object')) {
}
elsif ( grep /^$class$/, ( 'string', 'int', 'float', 'bool', 'object' ) ) {
return $data;
} else { # model
}
else { # model
my $_instance = use_module("WWW::OpenAPIClient::Object::$class")->new;
if ( ref $data eq "HASH" ) {
return $_instance->from_hash($data);
} else { # string, need to json decode first
}
else { # string, need to json decode first
return $_instance->from_hash( decode_json $data);
}
}
@@ -278,15 +306,16 @@ sub deserialize
# return 'Accept' based on an array of accept provided
# @param [Array] header_accept_array Array fo 'Accept'
# @return String Accept (e.g. application/json)
sub select_header_accept
{
sub select_header_accept {
my ( $self, @header ) = @_;
if ( @header == 0 || ( @header == 1 && $header[0] eq '' ) ) {
return undef;
} elsif (grep(/^application\/json$/i, @header)) {
}
elsif ( grep( /^application\/json$/i, @header ) ) {
return 'application/json';
} else {
}
else {
return join( ',', @header );
}
@@ -295,15 +324,16 @@ sub select_header_accept
# return the content type based on an array of content-type provided
# @param [Array] content_type_array Array fo content-type
# @return String Content-Type (e.g. application/json)
sub select_header_content_type
{
sub select_header_content_type {
my ( $self, @header ) = @_;
if ( @header == 0 || ( @header == 1 && $header[0] eq '' ) ) {
return 'application/json'; # default to application/json
} elsif (grep(/^application\/json$/i, @header)) {
}
elsif ( grep( /^application\/json$/i, @header ) ) {
return 'application/json';
} else {
}
else {
return join( ',', @header );
}
@@ -312,8 +342,7 @@ sub select_header_content_type
# Get API key (with prefix if set)
# @param string key name
# @return string API key with the prefix
sub get_api_key_with_prefix
{
sub get_api_key_with_prefix {
my ( $self, $key_name ) = @_;
my $api_key = $self->{config}{api_key}{$key_name};
@@ -337,8 +366,10 @@ sub update_params_for_auth {
# one endpoint can have more than 1 auth settings
foreach my $auth (@$auth_settings) {
# determine which one to use
if ( !defined($auth) ) {
# TODO show warning about auth setting not defined
}
elsif ( $auth eq 'api_key' ) {
@@ -358,13 +389,17 @@ elsif ($auth eq 'api_key_query') {
elsif ( $auth eq 'http_basic_test' ) {
if ( $self->{config}{username} || $self->{config}{password} ) {
$header_params->{'Authorization'} = 'Basic ' . encode_base64($self->{config}{username} . ":" . $self->{config}{password});
$header_params->{'Authorization'} =
'Basic '
. encode_base64( $self->{config}{username} . ":"
. $self->{config}{password} );
}
}
elsif ( $auth eq 'petstore_auth' ) {
if ( $self->{config}{access_token} ) {
$header_params->{'Authorization'} = 'Bearer ' . $self->{config}{access_token};
$header_params->{'Authorization'} =
'Bearer ' . $self->{config}{access_token};
}
}
else {
@@ -386,7 +421,8 @@ sub _global_auth_setup {
# basic
if ( my $uname = delete $tokens->{username} ) {
my $pword = delete $tokens->{password};
$header_params->{'Authorization'} = 'Basic '.encode_base64($uname.":".$pword);
$header_params->{'Authorization'} =
'Basic ' . encode_base64( $uname . ":" . $pword );
}
# oauth
@@ -405,10 +441,10 @@ sub _global_auth_setup {
$query_params->{$token_name} = $token;
}
else {
die "Don't know where to put token '$token_name' ('$in' is not 'head' or 'query')";
die
"Don't know where to put token '$token_name' ('$in' is not 'head' or 'query')";
}
}
}
1;

View File

@@ -1,3 +1,4 @@
=begin comment
OpenAPI Petstore
@@ -59,8 +60,7 @@ use WWW::OpenAPIClient::ApiClient;
# Load all the API classes and construct a lookup table at startup time
my %_apis = map { $_ =~ /^WWW::OpenAPIClient::(.*)$/; $1 => $_ }
grep {$_ =~ /Api$/}
usesub 'WWW::OpenAPIClient';
grep { $_ =~ /Api$/ } usesub 'WWW::OpenAPIClient';
=head1 new($api_client)
@@ -80,7 +80,8 @@ sub new {
my $api_client;
if ( $_[0] && ref $_[0] && ref $_[0] eq 'WWW::OpenAPIClient::ApiClient' ) {
$api_client = $_[0];
} else {
}
else {
$api_client = WWW::OpenAPIClient::ApiClient->new(@_);
}
bless { api_client => $api_client }, $class;
@@ -114,7 +115,9 @@ sub api_client { $_[0]->{api_client} }
=head1 apis_available()
=cut
sub apis_available { return map { $_ =~ s/Api$//; $_ } sort keys %_apis }
sub apis_available {
return map { $_ =~ s/Api$//; $_ } sort keys %_apis;
}
=head1 classname_for()
=cut
@@ -124,5 +127,4 @@ sub classname_for {
return $_apis{"${api_name}Api"};
}
1;

View File

@@ -1,3 +1,4 @@
=begin comment
OpenAPI Petstore
@@ -115,7 +116,6 @@ sub new {
return bless \%p => $self;
}
sub get_tokens {
my $self = shift;
@@ -159,10 +159,12 @@ sub accept_tokens {
foreach my $token_name ( keys %$tokens ) {
$self->{api_key}{$token_name} = $tokens->{$token_name}{token};
if ( $tokens->{$token_name}{prefix} ) {
$self->{api_key_prefix}{$token_name} = $tokens->{$token_name}{prefix};
$self->{api_key_prefix}{$token_name} =
$tokens->{$token_name}{prefix};
}
my $in = $tokens->{$token_name}->{in} || 'head';
croak "Tokens can only go in 'head' or 'query' (not in '$in')" unless $in =~ /^(?:head|query)$/;
croak "Tokens can only go in 'head' or 'query' (not in '$in')"
unless $in =~ /^(?:head|query)$/;
$self->{api_key_in}{$token_name} = $in;
}
}

View File

@@ -1,3 +1,4 @@
=begin comment
OpenAPI Petstore
@@ -39,7 +40,8 @@ sub new {
if ( $_[0] && ref $_[0] && ref $_[0] eq 'WWW::OpenAPIClient::ApiClient' ) {
$api_client = $_[0];
} else {
}
else {
$api_client = WWW::OpenAPIClient::ApiClient->new(@_);
}
@@ -47,7 +49,6 @@ sub new {
}
#
# fake_outer_boolean_serialize
#
@@ -68,6 +69,7 @@ sub new {
returns => 'boolean',
};
}
# @return boolean
#
sub fake_outer_boolean_serialize {
@@ -86,9 +88,11 @@ sub fake_outer_boolean_serialize {
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
$header_params->{'Content-Type'} =
$self->{api_client}->select_header_content_type();
my $_body_data;
# body params
if ( exists $args{'body'} ) {
$_body_data = $args{'body'};
@@ -98,13 +102,15 @@ sub fake_outer_boolean_serialize {
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);
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('boolean', $response);
my $_response_object =
$self->{api_client}->deserialize( 'boolean', $response );
return $_response_object;
}
@@ -128,6 +134,7 @@ sub fake_outer_boolean_serialize {
returns => 'OuterComposite',
};
}
# @return OuterComposite
#
sub fake_outer_composite_serialize {
@@ -146,9 +153,11 @@ sub fake_outer_composite_serialize {
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
$header_params->{'Content-Type'} =
$self->{api_client}->select_header_content_type();
my $_body_data;
# body params
if ( exists $args{'outer_composite'} ) {
$_body_data = $args{'outer_composite'};
@@ -158,13 +167,15 @@ sub fake_outer_composite_serialize {
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);
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('OuterComposite', $response);
my $_response_object =
$self->{api_client}->deserialize( 'OuterComposite', $response );
return $_response_object;
}
@@ -188,6 +199,7 @@ sub fake_outer_composite_serialize {
returns => 'double',
};
}
# @return double
#
sub fake_outer_number_serialize {
@@ -206,9 +218,11 @@ sub fake_outer_number_serialize {
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
$header_params->{'Content-Type'} =
$self->{api_client}->select_header_content_type();
my $_body_data;
# body params
if ( exists $args{'body'} ) {
$_body_data = $args{'body'};
@@ -218,13 +232,15 @@ sub fake_outer_number_serialize {
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);
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('double', $response);
my $_response_object =
$self->{api_client}->deserialize( 'double', $response );
return $_response_object;
}
@@ -248,6 +264,7 @@ sub fake_outer_number_serialize {
returns => 'string',
};
}
# @return string
#
sub fake_outer_string_serialize {
@@ -266,9 +283,11 @@ sub fake_outer_string_serialize {
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
$header_params->{'Content-Type'} =
$self->{api_client}->select_header_content_type();
my $_body_data;
# body params
if ( exists $args{'body'} ) {
$_body_data = $args{'body'};
@@ -278,16 +297,85 @@ sub fake_outer_string_serialize {
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);
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('string', $response);
my $_response_object =
$self->{api_client}->deserialize( 'string', $response );
return $_response_object;
}
#
# test_body_with_file_schema
#
#
#
# @param FileSchemaTestClass $file_schema_test_class (required)
{
my $params = {
'file_schema_test_class' => {
data_type => 'FileSchemaTestClass',
description => '',
required => '1',
},
};
__PACKAGE__->method_documentation->{'test_body_with_file_schema'} = {
summary => '',
params => $params,
returns => undef,
};
}
# @return void
#
sub test_body_with_file_schema {
my ( $self, %args ) = @_;
# verify the required parameter 'file_schema_test_class' is set
unless ( exists $args{'file_schema_test_class'} ) {
croak(
"Missing the required parameter 'file_schema_test_class' when calling test_body_with_file_schema"
);
}
# parse inputs
my $_resource_path = '/fake/body-with-file-schema';
my $_method = 'PUT';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept();
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} =
$self->{api_client}->select_header_content_type('application/json');
my $_body_data;
# body params
if ( exists $args{'file_schema_test_class'} ) {
$_body_data = $args{'file_schema_test_class'};
}
# authentication setting, if any
my $auth_settings = [qw()];
# make the API Call
$self->{api_client}->call_api(
$_resource_path, $_method, $query_params, $form_params,
$header_params, $_body_data, $auth_settings
);
return;
}
#
# test_body_with_query_params
#
@@ -314,6 +402,7 @@ sub fake_outer_string_serialize {
returns => undef,
};
}
# @return void
#
sub test_body_with_query_params {
@@ -321,12 +410,16 @@ sub test_body_with_query_params {
# verify the required parameter 'query' is set
unless ( exists $args{'query'} ) {
croak("Missing the required parameter 'query' when calling test_body_with_query_params");
croak(
"Missing the required parameter 'query' when calling test_body_with_query_params"
);
}
# verify the required parameter 'user' is set
unless ( exists $args{'user'} ) {
croak("Missing the required parameter 'user' when calling test_body_with_query_params");
croak(
"Missing the required parameter 'user' when calling test_body_with_query_params"
);
}
# parse inputs
@@ -342,14 +435,17 @@ sub test_body_with_query_params {
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/json');
$header_params->{'Content-Type'} =
$self->{api_client}->select_header_content_type('application/json');
# query params
if ( exists $args{'query'} ) {
$query_params->{'query'} = $self->{api_client}->to_query_value($args{'query'});
$query_params->{'query'} =
$self->{api_client}->to_query_value( $args{'query'} );
}
my $_body_data;
# body params
if ( exists $args{'user'} ) {
$_body_data = $args{'user'};
@@ -359,9 +455,10 @@ sub test_body_with_query_params {
my $auth_settings = [qw()];
# make the API Call
$self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
$self->{api_client}->call_api(
$_resource_path, $_method, $query_params, $form_params,
$header_params, $_body_data, $auth_settings
);
return;
}
@@ -385,6 +482,7 @@ sub test_body_with_query_params {
returns => 'Client',
};
}
# @return Client
#
sub test_client_model {
@@ -392,7 +490,9 @@ sub test_client_model {
# verify the required parameter 'client' is set
unless ( exists $args{'client'} ) {
croak("Missing the required parameter 'client' when calling test_client_model");
croak(
"Missing the required parameter 'client' when calling test_client_model"
);
}
# parse inputs
@@ -404,13 +504,16 @@ sub test_client_model {
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
my $_header_accept =
$self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/json');
$header_params->{'Content-Type'} =
$self->{api_client}->select_header_content_type('application/json');
my $_body_data;
# body params
if ( exists $args{'client'} ) {
$_body_data = $args{'client'};
@@ -420,13 +523,15 @@ sub test_client_model {
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);
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('Client', $response);
my $_response_object =
$self->{api_client}->deserialize( 'Client', $response );
return $_response_object;
}
@@ -523,11 +628,13 @@ sub test_client_model {
},
};
__PACKAGE__->method_documentation->{'test_endpoint_parameters'} = {
summary => 'Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ',
summary =>
'Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ',
params => $params,
returns => undef,
};
}
# @return void
#
sub test_endpoint_parameters {
@@ -535,22 +642,30 @@ sub test_endpoint_parameters {
# verify the required parameter 'number' is set
unless ( exists $args{'number'} ) {
croak("Missing the required parameter 'number' when calling test_endpoint_parameters");
croak(
"Missing the required parameter 'number' when calling test_endpoint_parameters"
);
}
# verify the required parameter 'double' is set
unless ( exists $args{'double'} ) {
croak("Missing the required parameter 'double' when calling test_endpoint_parameters");
croak(
"Missing the required parameter 'double' when calling test_endpoint_parameters"
);
}
# verify the required parameter 'pattern_without_delimiter' is set
unless ( exists $args{'pattern_without_delimiter'} ) {
croak("Missing the required parameter 'pattern_without_delimiter' when calling test_endpoint_parameters");
croak(
"Missing the required parameter 'pattern_without_delimiter' when calling test_endpoint_parameters"
);
}
# verify the required parameter 'byte' is set
unless ( exists $args{'byte'} ) {
croak("Missing the required parameter 'byte' when calling test_endpoint_parameters");
croak(
"Missing the required parameter 'byte' when calling test_endpoint_parameters"
);
}
# parse inputs
@@ -566,51 +681,61 @@ sub test_endpoint_parameters {
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/x-www-form-urlencoded');
$header_params->{'Content-Type'} = $self->{api_client}
->select_header_content_type('application/x-www-form-urlencoded');
# form params
if ( exists $args{'integer'} ) {
$form_params->{'integer'} = $self->{api_client}->to_form_value($args{'integer'});
$form_params->{'integer'} =
$self->{api_client}->to_form_value( $args{'integer'} );
}
# form params
if ( exists $args{'int32'} ) {
$form_params->{'int32'} = $self->{api_client}->to_form_value($args{'int32'});
$form_params->{'int32'} =
$self->{api_client}->to_form_value( $args{'int32'} );
}
# form params
if ( exists $args{'int64'} ) {
$form_params->{'int64'} = $self->{api_client}->to_form_value($args{'int64'});
$form_params->{'int64'} =
$self->{api_client}->to_form_value( $args{'int64'} );
}
# form params
if ( exists $args{'number'} ) {
$form_params->{'number'} = $self->{api_client}->to_form_value($args{'number'});
$form_params->{'number'} =
$self->{api_client}->to_form_value( $args{'number'} );
}
# form params
if ( exists $args{'float'} ) {
$form_params->{'float'} = $self->{api_client}->to_form_value($args{'float'});
$form_params->{'float'} =
$self->{api_client}->to_form_value( $args{'float'} );
}
# form params
if ( exists $args{'double'} ) {
$form_params->{'double'} = $self->{api_client}->to_form_value($args{'double'});
$form_params->{'double'} =
$self->{api_client}->to_form_value( $args{'double'} );
}
# form params
if ( exists $args{'string'} ) {
$form_params->{'string'} = $self->{api_client}->to_form_value($args{'string'});
$form_params->{'string'} =
$self->{api_client}->to_form_value( $args{'string'} );
}
# form params
if ( exists $args{'pattern_without_delimiter'} ) {
$form_params->{'pattern_without_delimiter'} = $self->{api_client}->to_form_value($args{'pattern_without_delimiter'});
$form_params->{'pattern_without_delimiter'} = $self->{api_client}
->to_form_value( $args{'pattern_without_delimiter'} );
}
# form params
if ( exists $args{'byte'} ) {
$form_params->{'byte'} = $self->{api_client}->to_form_value($args{'byte'});
$form_params->{'byte'} =
$self->{api_client}->to_form_value( $args{'byte'} );
}
# form params
@@ -621,32 +746,38 @@ sub test_endpoint_parameters {
# form params
if ( exists $args{'date'} ) {
$form_params->{'date'} = $self->{api_client}->to_form_value($args{'date'});
$form_params->{'date'} =
$self->{api_client}->to_form_value( $args{'date'} );
}
# form params
if ( exists $args{'date_time'} ) {
$form_params->{'dateTime'} = $self->{api_client}->to_form_value($args{'date_time'});
$form_params->{'dateTime'} =
$self->{api_client}->to_form_value( $args{'date_time'} );
}
# form params
if ( exists $args{'password'} ) {
$form_params->{'password'} = $self->{api_client}->to_form_value($args{'password'});
$form_params->{'password'} =
$self->{api_client}->to_form_value( $args{'password'} );
}
# form params
if ( exists $args{'callback'} ) {
$form_params->{'callback'} = $self->{api_client}->to_form_value($args{'callback'});
$form_params->{'callback'} =
$self->{api_client}->to_form_value( $args{'callback'} );
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw(http_basic_test )];
# make the API Call
$self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
$self->{api_client}->call_api(
$_resource_path, $_method, $query_params, $form_params,
$header_params, $_body_data, $auth_settings
);
return;
}
@@ -712,6 +843,7 @@ sub test_endpoint_parameters {
returns => undef,
};
}
# @return void
#
sub test_enum_parameters {
@@ -730,56 +862,67 @@ sub test_enum_parameters {
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/x-www-form-urlencoded');
$header_params->{'Content-Type'} = $self->{api_client}
->select_header_content_type('application/x-www-form-urlencoded');
# query params
if ( exists $args{'enum_query_string_array'} ) {
$query_params->{'enum_query_string_array'} = $self->{api_client}->to_query_value($args{'enum_query_string_array'});
$query_params->{'enum_query_string_array'} = $self->{api_client}
->to_query_value( $args{'enum_query_string_array'} );
}
# query params
if ( exists $args{'enum_query_string'} ) {
$query_params->{'enum_query_string'} = $self->{api_client}->to_query_value($args{'enum_query_string'});
$query_params->{'enum_query_string'} =
$self->{api_client}->to_query_value( $args{'enum_query_string'} );
}
# query params
if ( exists $args{'enum_query_integer'} ) {
$query_params->{'enum_query_integer'} = $self->{api_client}->to_query_value($args{'enum_query_integer'});
$query_params->{'enum_query_integer'} =
$self->{api_client}->to_query_value( $args{'enum_query_integer'} );
}
# query params
if ( exists $args{'enum_query_double'} ) {
$query_params->{'enum_query_double'} = $self->{api_client}->to_query_value($args{'enum_query_double'});
$query_params->{'enum_query_double'} =
$self->{api_client}->to_query_value( $args{'enum_query_double'} );
}
# header params
if ( exists $args{'enum_header_string_array'} ) {
$header_params->{'enum_header_string_array'} = $self->{api_client}->to_header_value($args{'enum_header_string_array'});
$header_params->{'enum_header_string_array'} = $self->{api_client}
->to_header_value( $args{'enum_header_string_array'} );
}
# header params
if ( exists $args{'enum_header_string'} ) {
$header_params->{'enum_header_string'} = $self->{api_client}->to_header_value($args{'enum_header_string'});
$header_params->{'enum_header_string'} =
$self->{api_client}->to_header_value( $args{'enum_header_string'} );
}
# form params
if ( exists $args{'enum_form_string_array'} ) {
$form_params->{'enum_form_string_array'} = $self->{api_client}->to_form_value($args{'enum_form_string_array'});
$form_params->{'enum_form_string_array'} =
$self->{api_client}->to_form_value( $args{'enum_form_string_array'} );
}
# form params
if ( exists $args{'enum_form_string'} ) {
$form_params->{'enum_form_string'} = $self->{api_client}->to_form_value($args{'enum_form_string'});
$form_params->{'enum_form_string'} =
$self->{api_client}->to_form_value( $args{'enum_form_string'} );
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw()];
# make the API Call
$self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
$self->{api_client}->call_api(
$_resource_path, $_method, $query_params, $form_params,
$header_params, $_body_data, $auth_settings
);
return;
}
@@ -803,6 +946,7 @@ sub test_enum_parameters {
returns => undef,
};
}
# @return void
#
sub test_inline_additional_properties {
@@ -810,7 +954,9 @@ sub test_inline_additional_properties {
# verify the required parameter 'request_body' is set
unless ( exists $args{'request_body'} ) {
croak("Missing the required parameter 'request_body' when calling test_inline_additional_properties");
croak(
"Missing the required parameter 'request_body' when calling test_inline_additional_properties"
);
}
# parse inputs
@@ -826,9 +972,11 @@ sub test_inline_additional_properties {
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/json');
$header_params->{'Content-Type'} =
$self->{api_client}->select_header_content_type('application/json');
my $_body_data;
# body params
if ( exists $args{'request_body'} ) {
$_body_data = $args{'request_body'};
@@ -838,9 +986,10 @@ sub test_inline_additional_properties {
my $auth_settings = [qw()];
# make the API Call
$self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
$self->{api_client}->call_api(
$_resource_path, $_method, $query_params, $form_params,
$header_params, $_body_data, $auth_settings
);
return;
}
@@ -870,6 +1019,7 @@ sub test_inline_additional_properties {
returns => undef,
};
}
# @return void
#
sub test_json_form_data {
@@ -877,12 +1027,16 @@ sub test_json_form_data {
# verify the required parameter 'param' is set
unless ( exists $args{'param'} ) {
croak("Missing the required parameter 'param' when calling test_json_form_data");
croak(
"Missing the required parameter 'param' when calling test_json_form_data"
);
}
# verify the required parameter 'param2' is set
unless ( exists $args{'param2'} ) {
croak("Missing the required parameter 'param2' when calling test_json_form_data");
croak(
"Missing the required parameter 'param2' when calling test_json_form_data"
);
}
# parse inputs
@@ -898,26 +1052,31 @@ sub test_json_form_data {
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/x-www-form-urlencoded');
$header_params->{'Content-Type'} = $self->{api_client}
->select_header_content_type('application/x-www-form-urlencoded');
# form params
if ( exists $args{'param'} ) {
$form_params->{'param'} = $self->{api_client}->to_form_value($args{'param'});
$form_params->{'param'} =
$self->{api_client}->to_form_value( $args{'param'} );
}
# form params
if ( exists $args{'param2'} ) {
$form_params->{'param2'} = $self->{api_client}->to_form_value($args{'param2'});
$form_params->{'param2'} =
$self->{api_client}->to_form_value( $args{'param2'} );
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw()];
# make the API Call
$self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
$self->{api_client}->call_api(
$_resource_path, $_method, $query_params, $form_params,
$header_params, $_body_data, $auth_settings
);
return;
}

View File

@@ -1,3 +1,4 @@
=begin comment
OpenAPI Petstore
@@ -39,7 +40,8 @@ sub new {
if ( $_[0] && ref $_[0] && ref $_[0] eq 'WWW::OpenAPIClient::ApiClient' ) {
$api_client = $_[0];
} else {
}
else {
$api_client = WWW::OpenAPIClient::ApiClient->new(@_);
}
@@ -47,7 +49,6 @@ sub new {
}
#
# test_classname
#
@@ -68,6 +69,7 @@ sub new {
returns => 'Client',
};
}
# @return Client
#
sub test_classname {
@@ -75,7 +77,9 @@ sub test_classname {
# verify the required parameter 'client' is set
unless ( exists $args{'client'} ) {
croak("Missing the required parameter 'client' when calling test_classname");
croak(
"Missing the required parameter 'client' when calling test_classname"
);
}
# parse inputs
@@ -87,13 +91,16 @@ sub test_classname {
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
my $_header_accept =
$self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/json');
$header_params->{'Content-Type'} =
$self->{api_client}->select_header_content_type('application/json');
my $_body_data;
# body params
if ( exists $args{'client'} ) {
$_body_data = $args{'client'};
@@ -103,13 +110,15 @@ sub test_classname {
my $auth_settings = [qw(api_key_query )];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
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('Client', $response);
my $_response_object =
$self->{api_client}->deserialize( 'Client', $response );
return $_response_object;
}

View File

@@ -1,3 +1,4 @@
=begin comment
OpenAPI Petstore
@@ -30,10 +31,8 @@ use Log::Any qw($log);
use Date::Parse;
use DateTime;
use base ( "Class::Accessor", "Class::Data::Inheritable" );
#
#
#
@@ -110,10 +109,15 @@ sub from_hash {
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);
}
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 );
}
}
@@ -127,22 +131,26 @@ sub _deserialize {
if ( $type eq 'DateTime' ) {
return DateTime->from_epoch( epoch => str2time($data) );
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
}
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
return $data;
} else { # hash(model)
}
else { # hash(model)
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
return $_instance->from_hash($data);
}
}
__PACKAGE__->class_documentation({description => '',
__PACKAGE__->class_documentation(
{
description => '',
class => 'AdditionalPropertiesClass',
required => [], # TODO
} );
}
);
__PACKAGE__->method_documentation({
__PACKAGE__->method_documentation(
{
'map_property' => {
datatype => 'HASH[string,string]',
base_name => 'map_property',
@@ -157,19 +165,23 @@ __PACKAGE__->method_documentation({
format => '',
read_only => '',
},
});
}
);
__PACKAGE__->openapi_types( {
__PACKAGE__->openapi_types(
{
'map_property' => 'HASH[string,string]',
'map_of_map_property' => 'HASH[string,HASH[string,string]]'
} );
}
);
__PACKAGE__->attribute_map( {
__PACKAGE__->attribute_map(
{
'map_property' => 'map_property',
'map_of_map_property' => 'map_of_map_property'
} );
}
);
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
1;

View File

@@ -1,3 +1,4 @@
=begin comment
OpenAPI Petstore
@@ -30,10 +31,8 @@ use Log::Any qw($log);
use Date::Parse;
use DateTime;
use base ( "Class::Accessor", "Class::Data::Inheritable" );
#
#
#
@@ -110,10 +109,15 @@ sub from_hash {
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);
}
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 );
}
}
@@ -127,22 +131,26 @@ sub _deserialize {
if ( $type eq 'DateTime' ) {
return DateTime->from_epoch( epoch => str2time($data) );
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
}
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
return $data;
} else { # hash(model)
}
else { # hash(model)
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
return $_instance->from_hash($data);
}
}
__PACKAGE__->class_documentation({description => '',
__PACKAGE__->class_documentation(
{
description => '',
class => 'Animal',
required => [], # TODO
} );
}
);
__PACKAGE__->method_documentation({
__PACKAGE__->method_documentation(
{
'class_name' => {
datatype => 'string',
base_name => 'className',
@@ -157,19 +165,23 @@ __PACKAGE__->method_documentation({
format => '',
read_only => '',
},
});
}
);
__PACKAGE__->openapi_types( {
__PACKAGE__->openapi_types(
{
'class_name' => 'string',
'color' => 'string'
} );
}
);
__PACKAGE__->attribute_map( {
__PACKAGE__->attribute_map(
{
'class_name' => 'className',
'color' => 'color'
} );
}
);
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
1;

View File

@@ -1,3 +1,4 @@
=begin comment
OpenAPI Petstore
@@ -34,7 +35,6 @@ use WWW::OpenAPIClient::Object::Animal;
use base ( "Class::Accessor", "Class::Data::Inheritable" );
#
#
#
@@ -111,10 +111,15 @@ sub from_hash {
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);
}
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 );
}
}
@@ -128,33 +133,38 @@ sub _deserialize {
if ( $type eq 'DateTime' ) {
return DateTime->from_epoch( epoch => str2time($data) );
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
}
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
return $data;
} else { # hash(model)
}
else { # hash(model)
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
return $_instance->from_hash($data);
}
}
__PACKAGE__->class_documentation({description => '',
__PACKAGE__->class_documentation(
{
description => '',
class => 'AnimalFarm',
required => [], # TODO
} );
}
);
__PACKAGE__->method_documentation({
});
__PACKAGE__->method_documentation( {} );
__PACKAGE__->openapi_types( {
__PACKAGE__->openapi_types(
{
} );
}
);
__PACKAGE__->attribute_map( {
__PACKAGE__->attribute_map(
{
} );
}
);
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
1;

View File

@@ -1,3 +1,4 @@
=begin comment
OpenAPI Petstore
@@ -30,10 +31,8 @@ use Log::Any qw($log);
use Date::Parse;
use DateTime;
use base ( "Class::Accessor", "Class::Data::Inheritable" );
#
#
#
@@ -110,10 +109,15 @@ sub from_hash {
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);
}
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 );
}
}
@@ -127,22 +131,26 @@ sub _deserialize {
if ( $type eq 'DateTime' ) {
return DateTime->from_epoch( epoch => str2time($data) );
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
}
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
return $data;
} else { # hash(model)
}
else { # hash(model)
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
return $_instance->from_hash($data);
}
}
__PACKAGE__->class_documentation({description => '',
__PACKAGE__->class_documentation(
{
description => '',
class => 'ApiResponse',
required => [], # TODO
} );
}
);
__PACKAGE__->method_documentation({
__PACKAGE__->method_documentation(
{
'code' => {
datatype => 'int',
base_name => 'code',
@@ -164,21 +172,25 @@ __PACKAGE__->method_documentation({
format => '',
read_only => '',
},
});
}
);
__PACKAGE__->openapi_types( {
__PACKAGE__->openapi_types(
{
'code' => 'int',
'type' => 'string',
'message' => 'string'
} );
}
);
__PACKAGE__->attribute_map( {
__PACKAGE__->attribute_map(
{
'code' => 'code',
'type' => 'type',
'message' => 'message'
} );
}
);
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
1;

View File

@@ -1,3 +1,4 @@
=begin comment
OpenAPI Petstore
@@ -30,10 +31,8 @@ use Log::Any qw($log);
use Date::Parse;
use DateTime;
use base ( "Class::Accessor", "Class::Data::Inheritable" );
#
#
#
@@ -110,10 +109,15 @@ sub from_hash {
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);
}
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 );
}
}
@@ -127,22 +131,26 @@ sub _deserialize {
if ( $type eq 'DateTime' ) {
return DateTime->from_epoch( epoch => str2time($data) );
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
}
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
return $data;
} else { # hash(model)
}
else { # hash(model)
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
return $_instance->from_hash($data);
}
}
__PACKAGE__->class_documentation({description => '',
__PACKAGE__->class_documentation(
{
description => '',
class => 'ArrayOfArrayOfNumberOnly',
required => [], # TODO
} );
}
);
__PACKAGE__->method_documentation({
__PACKAGE__->method_documentation(
{
'array_array_number' => {
datatype => 'ARRAY[ARRAY[double]]',
base_name => 'ArrayArrayNumber',
@@ -150,17 +158,21 @@ __PACKAGE__->method_documentation({
format => '',
read_only => '',
},
});
}
);
__PACKAGE__->openapi_types( {
__PACKAGE__->openapi_types(
{
'array_array_number' => 'ARRAY[ARRAY[double]]'
} );
}
);
__PACKAGE__->attribute_map( {
__PACKAGE__->attribute_map(
{
'array_array_number' => 'ArrayArrayNumber'
} );
}
);
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
1;

View File

@@ -1,3 +1,4 @@
=begin comment
OpenAPI Petstore
@@ -30,10 +31,8 @@ use Log::Any qw($log);
use Date::Parse;
use DateTime;
use base ( "Class::Accessor", "Class::Data::Inheritable" );
#
#
#
@@ -110,10 +109,15 @@ sub from_hash {
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);
}
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 );
}
}
@@ -127,22 +131,26 @@ sub _deserialize {
if ( $type eq 'DateTime' ) {
return DateTime->from_epoch( epoch => str2time($data) );
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
}
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
return $data;
} else { # hash(model)
}
else { # hash(model)
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
return $_instance->from_hash($data);
}
}
__PACKAGE__->class_documentation({description => '',
__PACKAGE__->class_documentation(
{
description => '',
class => 'ArrayOfNumberOnly',
required => [], # TODO
} );
}
);
__PACKAGE__->method_documentation({
__PACKAGE__->method_documentation(
{
'array_number' => {
datatype => 'ARRAY[double]',
base_name => 'ArrayNumber',
@@ -150,17 +158,21 @@ __PACKAGE__->method_documentation({
format => '',
read_only => '',
},
});
}
);
__PACKAGE__->openapi_types( {
__PACKAGE__->openapi_types(
{
'array_number' => 'ARRAY[double]'
} );
}
);
__PACKAGE__->attribute_map( {
__PACKAGE__->attribute_map(
{
'array_number' => 'ArrayNumber'
} );
}
);
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
1;

View File

@@ -1,3 +1,4 @@
=begin comment
OpenAPI Petstore
@@ -34,7 +35,6 @@ use WWW::OpenAPIClient::Object::ReadOnlyFirst;
use base ( "Class::Accessor", "Class::Data::Inheritable" );
#
#
#
@@ -111,10 +111,15 @@ sub from_hash {
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);
}
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 );
}
}
@@ -128,22 +133,26 @@ sub _deserialize {
if ( $type eq 'DateTime' ) {
return DateTime->from_epoch( epoch => str2time($data) );
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
}
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
return $data;
} else { # hash(model)
}
else { # hash(model)
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
return $_instance->from_hash($data);
}
}
__PACKAGE__->class_documentation({description => '',
__PACKAGE__->class_documentation(
{
description => '',
class => 'ArrayTest',
required => [], # TODO
} );
}
);
__PACKAGE__->method_documentation({
__PACKAGE__->method_documentation(
{
'array_of_string' => {
datatype => 'ARRAY[string]',
base_name => 'array_of_string',
@@ -165,21 +174,25 @@ __PACKAGE__->method_documentation({
format => '',
read_only => '',
},
});
}
);
__PACKAGE__->openapi_types( {
__PACKAGE__->openapi_types(
{
'array_of_string' => 'ARRAY[string]',
'array_array_of_integer' => 'ARRAY[ARRAY[int]]',
'array_array_of_model' => 'ARRAY[ARRAY[ReadOnlyFirst]]'
} );
}
);
__PACKAGE__->attribute_map( {
__PACKAGE__->attribute_map(
{
'array_of_string' => 'array_of_string',
'array_array_of_integer' => 'array_array_of_integer',
'array_array_of_model' => 'array_array_of_model'
} );
}
);
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
1;

View File

@@ -1,3 +1,4 @@
=begin comment
OpenAPI Petstore
@@ -30,10 +31,8 @@ use Log::Any qw($log);
use Date::Parse;
use DateTime;
use base ( "Class::Accessor", "Class::Data::Inheritable" );
#
#
#
@@ -110,10 +109,15 @@ sub from_hash {
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);
}
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 );
}
}
@@ -127,22 +131,26 @@ sub _deserialize {
if ( $type eq 'DateTime' ) {
return DateTime->from_epoch( epoch => str2time($data) );
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
}
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
return $data;
} else { # hash(model)
}
else { # hash(model)
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
return $_instance->from_hash($data);
}
}
__PACKAGE__->class_documentation({description => '',
__PACKAGE__->class_documentation(
{
description => '',
class => 'Capitalization',
required => [], # TODO
} );
}
);
__PACKAGE__->method_documentation({
__PACKAGE__->method_documentation(
{
'small_camel' => {
datatype => 'string',
base_name => 'smallCamel',
@@ -185,27 +193,31 @@ __PACKAGE__->method_documentation({
format => '',
read_only => '',
},
});
}
);
__PACKAGE__->openapi_types( {
__PACKAGE__->openapi_types(
{
'small_camel' => 'string',
'capital_camel' => 'string',
'small_snake' => 'string',
'capital_snake' => 'string',
'sca_eth_flow_points' => 'string',
'att_name' => 'string'
} );
}
);
__PACKAGE__->attribute_map( {
__PACKAGE__->attribute_map(
{
'small_camel' => 'smallCamel',
'capital_camel' => 'CapitalCamel',
'small_snake' => 'small_Snake',
'capital_snake' => 'Capital_Snake',
'sca_eth_flow_points' => 'SCA_ETH_Flow_Points',
'att_name' => 'ATT_NAME'
} );
}
);
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
1;

View File

@@ -1,3 +1,4 @@
=begin comment
OpenAPI Petstore
@@ -34,7 +35,6 @@ use WWW::OpenAPIClient::Object::Animal;
use base ( "Class::Accessor", "Class::Data::Inheritable" );
#
#
#
@@ -111,10 +111,15 @@ sub from_hash {
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);
}
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 );
}
}
@@ -128,22 +133,26 @@ sub _deserialize {
if ( $type eq 'DateTime' ) {
return DateTime->from_epoch( epoch => str2time($data) );
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
}
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
return $data;
} else { # hash(model)
}
else { # hash(model)
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
return $_instance->from_hash($data);
}
}
__PACKAGE__->class_documentation({description => '',
__PACKAGE__->class_documentation(
{
description => '',
class => 'Cat',
required => [], # TODO
} );
}
);
__PACKAGE__->method_documentation({
__PACKAGE__->method_documentation(
{
'class_name' => {
datatype => 'string',
base_name => 'className',
@@ -165,21 +174,25 @@ __PACKAGE__->method_documentation({
format => '',
read_only => '',
},
});
}
);
__PACKAGE__->openapi_types( {
__PACKAGE__->openapi_types(
{
'class_name' => 'string',
'color' => 'string',
'declawed' => 'boolean'
} );
}
);
__PACKAGE__->attribute_map( {
__PACKAGE__->attribute_map(
{
'class_name' => 'className',
'color' => 'color',
'declawed' => 'declawed'
} );
}
);
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
1;

View File

@@ -1,3 +1,4 @@
=begin comment
OpenAPI Petstore
@@ -30,10 +31,8 @@ use Log::Any qw($log);
use Date::Parse;
use DateTime;
use base ( "Class::Accessor", "Class::Data::Inheritable" );
#
#
#
@@ -110,10 +109,15 @@ sub from_hash {
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);
}
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 );
}
}
@@ -127,22 +131,26 @@ sub _deserialize {
if ( $type eq 'DateTime' ) {
return DateTime->from_epoch( epoch => str2time($data) );
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
}
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
return $data;
} else { # hash(model)
}
else { # hash(model)
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
return $_instance->from_hash($data);
}
}
__PACKAGE__->class_documentation({description => '',
__PACKAGE__->class_documentation(
{
description => '',
class => 'Category',
required => [], # TODO
} );
}
);
__PACKAGE__->method_documentation({
__PACKAGE__->method_documentation(
{
'id' => {
datatype => 'int',
base_name => 'id',
@@ -157,19 +165,23 @@ __PACKAGE__->method_documentation({
format => '',
read_only => '',
},
});
}
);
__PACKAGE__->openapi_types( {
__PACKAGE__->openapi_types(
{
'id' => 'int',
'name' => 'string'
} );
}
);
__PACKAGE__->attribute_map( {
__PACKAGE__->attribute_map(
{
'id' => 'id',
'name' => 'name'
} );
}
);
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
1;

View File

@@ -1,3 +1,4 @@
=begin comment
OpenAPI Petstore
@@ -30,10 +31,8 @@ use Log::Any qw($log);
use Date::Parse;
use DateTime;
use base ( "Class::Accessor", "Class::Data::Inheritable" );
#
#Model for testing model with \"_class\" property
#
@@ -110,10 +109,15 @@ sub from_hash {
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);
}
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 );
}
}
@@ -127,22 +131,27 @@ sub _deserialize {
if ( $type eq 'DateTime' ) {
return DateTime->from_epoch( epoch => str2time($data) );
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
}
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
return $data;
} else { # hash(model)
}
else { # hash(model)
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
return $_instance->from_hash($data);
}
}
__PACKAGE__->class_documentation({description => 'Model for testing model with \"_class\" property',
__PACKAGE__->class_documentation(
{
description =>
'Model for testing model with \"_class\" property',
class => 'ClassModel',
required => [], # TODO
} );
}
);
__PACKAGE__->method_documentation({
__PACKAGE__->method_documentation(
{
'_class' => {
datatype => 'string',
base_name => '_class',
@@ -150,17 +159,21 @@ __PACKAGE__->method_documentation({
format => '',
read_only => '',
},
});
}
);
__PACKAGE__->openapi_types( {
__PACKAGE__->openapi_types(
{
'_class' => 'string'
} );
}
);
__PACKAGE__->attribute_map( {
__PACKAGE__->attribute_map(
{
'_class' => '_class'
} );
}
);
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
1;

View File

@@ -1,3 +1,4 @@
=begin comment
OpenAPI Petstore
@@ -30,10 +31,8 @@ use Log::Any qw($log);
use Date::Parse;
use DateTime;
use base ( "Class::Accessor", "Class::Data::Inheritable" );
#
#
#
@@ -110,10 +109,15 @@ sub from_hash {
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);
}
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 );
}
}
@@ -127,22 +131,26 @@ sub _deserialize {
if ( $type eq 'DateTime' ) {
return DateTime->from_epoch( epoch => str2time($data) );
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
}
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
return $data;
} else { # hash(model)
}
else { # hash(model)
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
return $_instance->from_hash($data);
}
}
__PACKAGE__->class_documentation({description => '',
__PACKAGE__->class_documentation(
{
description => '',
class => 'Client',
required => [], # TODO
} );
}
);
__PACKAGE__->method_documentation({
__PACKAGE__->method_documentation(
{
'client' => {
datatype => 'string',
base_name => 'client',
@@ -150,17 +158,21 @@ __PACKAGE__->method_documentation({
format => '',
read_only => '',
},
});
}
);
__PACKAGE__->openapi_types( {
__PACKAGE__->openapi_types(
{
'client' => 'string'
} );
}
);
__PACKAGE__->attribute_map( {
__PACKAGE__->attribute_map(
{
'client' => 'client'
} );
}
);
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
1;

View File

@@ -1,3 +1,4 @@
=begin comment
OpenAPI Petstore
@@ -34,7 +35,6 @@ use WWW::OpenAPIClient::Object::Animal;
use base ( "Class::Accessor", "Class::Data::Inheritable" );
#
#
#
@@ -111,10 +111,15 @@ sub from_hash {
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);
}
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 );
}
}
@@ -128,22 +133,26 @@ sub _deserialize {
if ( $type eq 'DateTime' ) {
return DateTime->from_epoch( epoch => str2time($data) );
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
}
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
return $data;
} else { # hash(model)
}
else { # hash(model)
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
return $_instance->from_hash($data);
}
}
__PACKAGE__->class_documentation({description => '',
__PACKAGE__->class_documentation(
{
description => '',
class => 'Dog',
required => [], # TODO
} );
}
);
__PACKAGE__->method_documentation({
__PACKAGE__->method_documentation(
{
'class_name' => {
datatype => 'string',
base_name => 'className',
@@ -165,21 +174,25 @@ __PACKAGE__->method_documentation({
format => '',
read_only => '',
},
});
}
);
__PACKAGE__->openapi_types( {
__PACKAGE__->openapi_types(
{
'class_name' => 'string',
'color' => 'string',
'breed' => 'string'
} );
}
);
__PACKAGE__->attribute_map( {
__PACKAGE__->attribute_map(
{
'class_name' => 'className',
'color' => 'color',
'breed' => 'breed'
} );
}
);
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
1;

View File

@@ -1,3 +1,4 @@
=begin comment
OpenAPI Petstore
@@ -30,10 +31,8 @@ use Log::Any qw($log);
use Date::Parse;
use DateTime;
use base ( "Class::Accessor", "Class::Data::Inheritable" );
#
#
#
@@ -110,10 +109,15 @@ sub from_hash {
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);
}
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 );
}
}
@@ -127,22 +131,26 @@ sub _deserialize {
if ( $type eq 'DateTime' ) {
return DateTime->from_epoch( epoch => str2time($data) );
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
}
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
return $data;
} else { # hash(model)
}
else { # hash(model)
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
return $_instance->from_hash($data);
}
}
__PACKAGE__->class_documentation({description => '',
__PACKAGE__->class_documentation(
{
description => '',
class => 'EnumArrays',
required => [], # TODO
} );
}
);
__PACKAGE__->method_documentation({
__PACKAGE__->method_documentation(
{
'just_symbol' => {
datatype => 'string',
base_name => 'just_symbol',
@@ -157,19 +165,23 @@ __PACKAGE__->method_documentation({
format => '',
read_only => '',
},
});
}
);
__PACKAGE__->openapi_types( {
__PACKAGE__->openapi_types(
{
'just_symbol' => 'string',
'array_enum' => 'ARRAY[string]'
} );
}
);
__PACKAGE__->attribute_map( {
__PACKAGE__->attribute_map(
{
'just_symbol' => 'just_symbol',
'array_enum' => 'array_enum'
} );
}
);
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
1;

View File

@@ -1,3 +1,4 @@
=begin comment
OpenAPI Petstore
@@ -30,10 +31,8 @@ use Log::Any qw($log);
use Date::Parse;
use DateTime;
use base ( "Class::Accessor", "Class::Data::Inheritable" );
#
#
#
@@ -110,10 +109,15 @@ sub from_hash {
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);
}
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 );
}
}
@@ -127,33 +131,38 @@ sub _deserialize {
if ( $type eq 'DateTime' ) {
return DateTime->from_epoch( epoch => str2time($data) );
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
}
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
return $data;
} else { # hash(model)
}
else { # hash(model)
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
return $_instance->from_hash($data);
}
}
__PACKAGE__->class_documentation({description => '',
__PACKAGE__->class_documentation(
{
description => '',
class => 'EnumClass',
required => [], # TODO
} );
}
);
__PACKAGE__->method_documentation({
});
__PACKAGE__->method_documentation( {} );
__PACKAGE__->openapi_types( {
__PACKAGE__->openapi_types(
{
} );
}
);
__PACKAGE__->attribute_map( {
__PACKAGE__->attribute_map(
{
} );
}
);
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
1;

View File

@@ -1,3 +1,4 @@
=begin comment
OpenAPI Petstore
@@ -34,7 +35,6 @@ use WWW::OpenAPIClient::Object::OuterEnum;
use base ( "Class::Accessor", "Class::Data::Inheritable" );
#
#
#
@@ -111,10 +111,15 @@ sub from_hash {
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);
}
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 );
}
}
@@ -128,22 +133,26 @@ sub _deserialize {
if ( $type eq 'DateTime' ) {
return DateTime->from_epoch( epoch => str2time($data) );
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
}
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
return $data;
} else { # hash(model)
}
else { # hash(model)
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
return $_instance->from_hash($data);
}
}
__PACKAGE__->class_documentation({description => '',
__PACKAGE__->class_documentation(
{
description => '',
class => 'EnumTest',
required => [], # TODO
} );
}
);
__PACKAGE__->method_documentation({
__PACKAGE__->method_documentation(
{
'enum_string' => {
datatype => 'string',
base_name => 'enum_string',
@@ -179,25 +188,29 @@ __PACKAGE__->method_documentation({
format => '',
read_only => '',
},
});
}
);
__PACKAGE__->openapi_types( {
__PACKAGE__->openapi_types(
{
'enum_string' => 'string',
'enum_string_required' => 'string',
'enum_integer' => 'int',
'enum_number' => 'double',
'outer_enum' => 'OuterEnum'
} );
}
);
__PACKAGE__->attribute_map( {
__PACKAGE__->attribute_map(
{
'enum_string' => 'enum_string',
'enum_string_required' => 'enum_string_required',
'enum_integer' => 'enum_integer',
'enum_number' => 'enum_number',
'outer_enum' => 'outerEnum'
} );
}
);
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
1;

View File

@@ -0,0 +1,178 @@
=begin comment
OpenAPI Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0
Generated by: https://openapi-generator.tech
=end comment
=cut
#
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
# Do not edit the class manually.
# Ref: https://openapi-generator.tech
#
package WWW::OpenAPIClient::Object::File;
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" );
#
#Must be named `File` for test.
#
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). Do not edit the class manually.
# REF: https://openapi-generator.tech
#
=begin comment
OpenAPI Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0
Generated by: https://openapi-generator.tech
=end comment
=cut
#
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
# Do not edit the class manually.
# Ref: https://openapi-generator.tech
#
__PACKAGE__->mk_classdata( 'attribute_map' => {} );
__PACKAGE__->mk_classdata( 'openapi_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 openapi_types to deserialize the data
while ( my ( $_key, $_type ) = each %{ $self->openapi_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::OpenAPIClient::Object::$type->new()";
return $_instance->from_hash($data);
}
}
__PACKAGE__->class_documentation(
{
description => 'Must be named `File` for test.',
class => 'File',
required => [], # TODO
}
);
__PACKAGE__->method_documentation(
{
'source_uri' => {
datatype => 'string',
base_name => 'sourceURI',
description => 'Test capitalization',
format => '',
read_only => '',
},
}
);
__PACKAGE__->openapi_types(
{
'source_uri' => 'string'
}
);
__PACKAGE__->attribute_map(
{
'source_uri' => 'sourceURI'
}
);
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
1;

View File

@@ -0,0 +1,189 @@
=begin comment
OpenAPI Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0
Generated by: https://openapi-generator.tech
=end comment
=cut
#
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
# Do not edit the class manually.
# Ref: https://openapi-generator.tech
#
package WWW::OpenAPIClient::Object::FileSchemaTestClass;
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 WWW::OpenAPIClient::Object::File;
use base ( "Class::Accessor", "Class::Data::Inheritable" );
#
#
#
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). Do not edit the class manually.
# REF: https://openapi-generator.tech
#
=begin comment
OpenAPI Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0
Generated by: https://openapi-generator.tech
=end comment
=cut
#
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
# Do not edit the class manually.
# Ref: https://openapi-generator.tech
#
__PACKAGE__->mk_classdata( 'attribute_map' => {} );
__PACKAGE__->mk_classdata( 'openapi_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 openapi_types to deserialize the data
while ( my ( $_key, $_type ) = each %{ $self->openapi_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::OpenAPIClient::Object::$type->new()";
return $_instance->from_hash($data);
}
}
__PACKAGE__->class_documentation(
{
description => '',
class => 'FileSchemaTestClass',
required => [], # TODO
}
);
__PACKAGE__->method_documentation(
{
'file' => {
datatype => 'File',
base_name => 'file',
description => '',
format => '',
read_only => '',
},
'files' => {
datatype => 'ARRAY[File]',
base_name => 'files',
description => '',
format => '',
read_only => '',
},
}
);
__PACKAGE__->openapi_types(
{
'file' => 'File',
'files' => 'ARRAY[File]'
}
);
__PACKAGE__->attribute_map(
{
'file' => 'file',
'files' => 'files'
}
);
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
1;

View File

@@ -1,3 +1,4 @@
=begin comment
OpenAPI Petstore
@@ -30,10 +31,8 @@ use Log::Any qw($log);
use Date::Parse;
use DateTime;
use base ( "Class::Accessor", "Class::Data::Inheritable" );
#
#
#
@@ -110,10 +109,15 @@ sub from_hash {
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);
}
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 );
}
}
@@ -127,22 +131,26 @@ sub _deserialize {
if ( $type eq 'DateTime' ) {
return DateTime->from_epoch( epoch => str2time($data) );
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
}
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
return $data;
} else { # hash(model)
}
else { # hash(model)
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
return $_instance->from_hash($data);
}
}
__PACKAGE__->class_documentation({description => '',
__PACKAGE__->class_documentation(
{
description => '',
class => 'FormatTest',
required => [], # TODO
} );
}
);
__PACKAGE__->method_documentation({
__PACKAGE__->method_documentation(
{
'integer' => {
datatype => 'int',
base_name => 'integer',
@@ -234,9 +242,11 @@ __PACKAGE__->method_documentation({
format => '',
read_only => '',
},
});
}
);
__PACKAGE__->openapi_types( {
__PACKAGE__->openapi_types(
{
'integer' => 'int',
'int32' => 'int',
'int64' => 'int',
@@ -250,9 +260,11 @@ __PACKAGE__->openapi_types( {
'date_time' => 'DateTime',
'uuid' => 'string',
'password' => 'string'
} );
}
);
__PACKAGE__->attribute_map( {
__PACKAGE__->attribute_map(
{
'integer' => 'integer',
'int32' => 'int32',
'int64' => 'int64',
@@ -266,9 +278,9 @@ __PACKAGE__->attribute_map( {
'date_time' => 'dateTime',
'uuid' => 'uuid',
'password' => 'password'
} );
}
);
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
1;

View File

@@ -1,3 +1,4 @@
=begin comment
OpenAPI Petstore
@@ -30,10 +31,8 @@ use Log::Any qw($log);
use Date::Parse;
use DateTime;
use base ( "Class::Accessor", "Class::Data::Inheritable" );
#
#
#
@@ -110,10 +109,15 @@ sub from_hash {
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);
}
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 );
}
}
@@ -127,22 +131,26 @@ sub _deserialize {
if ( $type eq 'DateTime' ) {
return DateTime->from_epoch( epoch => str2time($data) );
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
}
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
return $data;
} else { # hash(model)
}
else { # hash(model)
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
return $_instance->from_hash($data);
}
}
__PACKAGE__->class_documentation({description => '',
__PACKAGE__->class_documentation(
{
description => '',
class => 'HasOnlyReadOnly',
required => [], # TODO
} );
}
);
__PACKAGE__->method_documentation({
__PACKAGE__->method_documentation(
{
'bar' => {
datatype => 'string',
base_name => 'bar',
@@ -157,19 +165,23 @@ __PACKAGE__->method_documentation({
format => '',
read_only => '',
},
});
}
);
__PACKAGE__->openapi_types( {
__PACKAGE__->openapi_types(
{
'bar' => 'string',
'foo' => 'string'
} );
}
);
__PACKAGE__->attribute_map( {
__PACKAGE__->attribute_map(
{
'bar' => 'bar',
'foo' => 'foo'
} );
}
);
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
1;

View File

@@ -1,3 +1,4 @@
=begin comment
OpenAPI Petstore
@@ -30,10 +31,8 @@ use Log::Any qw($log);
use Date::Parse;
use DateTime;
use base ( "Class::Accessor", "Class::Data::Inheritable" );
#
#
#
@@ -110,10 +109,15 @@ sub from_hash {
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);
}
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 );
}
}
@@ -127,22 +131,26 @@ sub _deserialize {
if ( $type eq 'DateTime' ) {
return DateTime->from_epoch( epoch => str2time($data) );
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
}
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
return $data;
} else { # hash(model)
}
else { # hash(model)
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
return $_instance->from_hash($data);
}
}
__PACKAGE__->class_documentation({description => '',
__PACKAGE__->class_documentation(
{
description => '',
class => 'List',
required => [], # TODO
} );
}
);
__PACKAGE__->method_documentation({
__PACKAGE__->method_documentation(
{
'_123_list' => {
datatype => 'string',
base_name => '123-list',
@@ -150,17 +158,21 @@ __PACKAGE__->method_documentation({
format => '',
read_only => '',
},
});
}
);
__PACKAGE__->openapi_types( {
__PACKAGE__->openapi_types(
{
'_123_list' => 'string'
} );
}
);
__PACKAGE__->attribute_map( {
__PACKAGE__->attribute_map(
{
'_123_list' => '123-list'
} );
}
);
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
1;

View File

@@ -1,3 +1,4 @@
=begin comment
OpenAPI Petstore
@@ -30,10 +31,10 @@ use Log::Any qw($log);
use Date::Parse;
use DateTime;
use WWW::OpenAPIClient::Object::StringBooleanMap;
use base ( "Class::Accessor", "Class::Data::Inheritable" );
#
#
#
@@ -110,10 +111,15 @@ sub from_hash {
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);
}
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 );
}
}
@@ -127,22 +133,26 @@ sub _deserialize {
if ( $type eq 'DateTime' ) {
return DateTime->from_epoch( epoch => str2time($data) );
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
}
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
return $data;
} else { # hash(model)
}
else { # hash(model)
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
return $_instance->from_hash($data);
}
}
__PACKAGE__->class_documentation({description => '',
__PACKAGE__->class_documentation(
{
description => '',
class => 'MapTest',
required => [], # TODO
} );
}
);
__PACKAGE__->method_documentation({
__PACKAGE__->method_documentation(
{
'map_map_of_string' => {
datatype => 'HASH[string,HASH[string,string]]',
base_name => 'map_map_of_string',
@@ -157,19 +167,41 @@ __PACKAGE__->method_documentation({
format => '',
read_only => '',
},
});
'direct_map' => {
datatype => 'HASH[string,boolean]',
base_name => 'direct_map',
description => '',
format => '',
read_only => '',
},
'indirect_map' => {
datatype => 'StringBooleanMap',
base_name => 'indirect_map',
description => '',
format => '',
read_only => '',
},
}
);
__PACKAGE__->openapi_types( {
__PACKAGE__->openapi_types(
{
'map_map_of_string' => 'HASH[string,HASH[string,string]]',
'map_of_enum_string' => 'HASH[string,string]'
} );
'map_of_enum_string' => 'HASH[string,string]',
'direct_map' => 'HASH[string,boolean]',
'indirect_map' => 'StringBooleanMap'
}
);
__PACKAGE__->attribute_map( {
__PACKAGE__->attribute_map(
{
'map_map_of_string' => 'map_map_of_string',
'map_of_enum_string' => 'map_of_enum_string'
} );
'map_of_enum_string' => 'map_of_enum_string',
'direct_map' => 'direct_map',
'indirect_map' => 'indirect_map'
}
);
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
1;

View File

@@ -1,3 +1,4 @@
=begin comment
OpenAPI Petstore
@@ -34,7 +35,6 @@ use WWW::OpenAPIClient::Object::Animal;
use base ( "Class::Accessor", "Class::Data::Inheritable" );
#
#
#
@@ -111,10 +111,15 @@ sub from_hash {
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);
}
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 );
}
}
@@ -128,22 +133,26 @@ sub _deserialize {
if ( $type eq 'DateTime' ) {
return DateTime->from_epoch( epoch => str2time($data) );
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
}
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
return $data;
} else { # hash(model)
}
else { # hash(model)
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
return $_instance->from_hash($data);
}
}
__PACKAGE__->class_documentation({description => '',
__PACKAGE__->class_documentation(
{
description => '',
class => 'MixedPropertiesAndAdditionalPropertiesClass',
required => [], # TODO
} );
}
);
__PACKAGE__->method_documentation({
__PACKAGE__->method_documentation(
{
'uuid' => {
datatype => 'string',
base_name => 'uuid',
@@ -165,21 +174,25 @@ __PACKAGE__->method_documentation({
format => '',
read_only => '',
},
});
}
);
__PACKAGE__->openapi_types( {
__PACKAGE__->openapi_types(
{
'uuid' => 'string',
'date_time' => 'DateTime',
'map' => 'HASH[string,Animal]'
} );
}
);
__PACKAGE__->attribute_map( {
__PACKAGE__->attribute_map(
{
'uuid' => 'uuid',
'date_time' => 'dateTime',
'map' => 'map'
} );
}
);
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
1;

View File

@@ -1,3 +1,4 @@
=begin comment
OpenAPI Petstore
@@ -30,10 +31,8 @@ use Log::Any qw($log);
use Date::Parse;
use DateTime;
use base ( "Class::Accessor", "Class::Data::Inheritable" );
#
#Model for testing model name starting with number
#
@@ -110,10 +109,15 @@ sub from_hash {
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);
}
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 );
}
}
@@ -127,22 +131,26 @@ sub _deserialize {
if ( $type eq 'DateTime' ) {
return DateTime->from_epoch( epoch => str2time($data) );
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
}
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
return $data;
} else { # hash(model)
}
else { # hash(model)
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
return $_instance->from_hash($data);
}
}
__PACKAGE__->class_documentation({description => 'Model for testing model name starting with number',
__PACKAGE__->class_documentation(
{
description => 'Model for testing model name starting with number',
class => 'Model200Response',
required => [], # TODO
} );
}
);
__PACKAGE__->method_documentation({
__PACKAGE__->method_documentation(
{
'name' => {
datatype => 'int',
base_name => 'name',
@@ -157,19 +165,23 @@ __PACKAGE__->method_documentation({
format => '',
read_only => '',
},
});
}
);
__PACKAGE__->openapi_types( {
__PACKAGE__->openapi_types(
{
'name' => 'int',
'class' => 'string'
} );
}
);
__PACKAGE__->attribute_map( {
__PACKAGE__->attribute_map(
{
'name' => 'name',
'class' => 'class'
} );
}
);
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
1;

View File

@@ -1,3 +1,4 @@
=begin comment
OpenAPI Petstore
@@ -30,10 +31,8 @@ use Log::Any qw($log);
use Date::Parse;
use DateTime;
use base ( "Class::Accessor", "Class::Data::Inheritable" );
#
#Model for testing reserved words
#
@@ -110,10 +109,15 @@ sub from_hash {
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);
}
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 );
}
}
@@ -127,22 +131,26 @@ sub _deserialize {
if ( $type eq 'DateTime' ) {
return DateTime->from_epoch( epoch => str2time($data) );
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
}
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
return $data;
} else { # hash(model)
}
else { # hash(model)
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
return $_instance->from_hash($data);
}
}
__PACKAGE__->class_documentation({description => 'Model for testing reserved words',
__PACKAGE__->class_documentation(
{
description => 'Model for testing reserved words',
class => 'ModelReturn',
required => [], # TODO
} );
}
);
__PACKAGE__->method_documentation({
__PACKAGE__->method_documentation(
{
'return' => {
datatype => 'int',
base_name => 'return',
@@ -150,17 +158,21 @@ __PACKAGE__->method_documentation({
format => '',
read_only => '',
},
});
}
);
__PACKAGE__->openapi_types( {
__PACKAGE__->openapi_types(
{
'return' => 'int'
} );
}
);
__PACKAGE__->attribute_map( {
__PACKAGE__->attribute_map(
{
'return' => 'return'
} );
}
);
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
1;

View File

@@ -1,3 +1,4 @@
=begin comment
OpenAPI Petstore
@@ -30,10 +31,8 @@ use Log::Any qw($log);
use Date::Parse;
use DateTime;
use base ( "Class::Accessor", "Class::Data::Inheritable" );
#
#Model for testing model name same as property name
#
@@ -110,10 +109,15 @@ sub from_hash {
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);
}
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 );
}
}
@@ -127,22 +131,26 @@ sub _deserialize {
if ( $type eq 'DateTime' ) {
return DateTime->from_epoch( epoch => str2time($data) );
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
}
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
return $data;
} else { # hash(model)
}
else { # hash(model)
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
return $_instance->from_hash($data);
}
}
__PACKAGE__->class_documentation({description => 'Model for testing model name same as property name',
__PACKAGE__->class_documentation(
{
description => 'Model for testing model name same as property name',
class => 'Name',
required => [], # TODO
} );
}
);
__PACKAGE__->method_documentation({
__PACKAGE__->method_documentation(
{
'name' => {
datatype => 'int',
base_name => 'name',
@@ -171,23 +179,27 @@ __PACKAGE__->method_documentation({
format => '',
read_only => '',
},
});
}
);
__PACKAGE__->openapi_types( {
__PACKAGE__->openapi_types(
{
'name' => 'int',
'snake_case' => 'int',
'property' => 'string',
'_123_number' => 'int'
} );
}
);
__PACKAGE__->attribute_map( {
__PACKAGE__->attribute_map(
{
'name' => 'name',
'snake_case' => 'snake_case',
'property' => 'property',
'_123_number' => '123Number'
} );
}
);
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
1;

View File

@@ -1,3 +1,4 @@
=begin comment
OpenAPI Petstore
@@ -30,10 +31,8 @@ use Log::Any qw($log);
use Date::Parse;
use DateTime;
use base ( "Class::Accessor", "Class::Data::Inheritable" );
#
#
#
@@ -110,10 +109,15 @@ sub from_hash {
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);
}
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 );
}
}
@@ -127,22 +131,26 @@ sub _deserialize {
if ( $type eq 'DateTime' ) {
return DateTime->from_epoch( epoch => str2time($data) );
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
}
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
return $data;
} else { # hash(model)
}
else { # hash(model)
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
return $_instance->from_hash($data);
}
}
__PACKAGE__->class_documentation({description => '',
__PACKAGE__->class_documentation(
{
description => '',
class => 'NumberOnly',
required => [], # TODO
} );
}
);
__PACKAGE__->method_documentation({
__PACKAGE__->method_documentation(
{
'just_number' => {
datatype => 'double',
base_name => 'JustNumber',
@@ -150,17 +158,21 @@ __PACKAGE__->method_documentation({
format => '',
read_only => '',
},
});
}
);
__PACKAGE__->openapi_types( {
__PACKAGE__->openapi_types(
{
'just_number' => 'double'
} );
}
);
__PACKAGE__->attribute_map( {
__PACKAGE__->attribute_map(
{
'just_number' => 'JustNumber'
} );
}
);
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
1;

View File

@@ -1,3 +1,4 @@
=begin comment
OpenAPI Petstore
@@ -30,10 +31,8 @@ use Log::Any qw($log);
use Date::Parse;
use DateTime;
use base ( "Class::Accessor", "Class::Data::Inheritable" );
#
#
#
@@ -110,10 +109,15 @@ sub from_hash {
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);
}
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 );
}
}
@@ -127,22 +131,26 @@ sub _deserialize {
if ( $type eq 'DateTime' ) {
return DateTime->from_epoch( epoch => str2time($data) );
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
}
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
return $data;
} else { # hash(model)
}
else { # hash(model)
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
return $_instance->from_hash($data);
}
}
__PACKAGE__->class_documentation({description => '',
__PACKAGE__->class_documentation(
{
description => '',
class => 'Order',
required => [], # TODO
} );
}
);
__PACKAGE__->method_documentation({
__PACKAGE__->method_documentation(
{
'id' => {
datatype => 'int',
base_name => 'id',
@@ -185,27 +193,31 @@ __PACKAGE__->method_documentation({
format => '',
read_only => '',
},
});
}
);
__PACKAGE__->openapi_types( {
__PACKAGE__->openapi_types(
{
'id' => 'int',
'pet_id' => 'int',
'quantity' => 'int',
'ship_date' => 'DateTime',
'status' => 'string',
'complete' => 'boolean'
} );
}
);
__PACKAGE__->attribute_map( {
__PACKAGE__->attribute_map(
{
'id' => 'id',
'pet_id' => 'petId',
'quantity' => 'quantity',
'ship_date' => 'shipDate',
'status' => 'status',
'complete' => 'complete'
} );
}
);
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
1;

View File

@@ -1,3 +1,4 @@
=begin comment
OpenAPI Petstore
@@ -30,10 +31,8 @@ use Log::Any qw($log);
use Date::Parse;
use DateTime;
use base ( "Class::Accessor", "Class::Data::Inheritable" );
#
#
#
@@ -110,10 +109,15 @@ sub from_hash {
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);
}
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 );
}
}
@@ -127,22 +131,26 @@ sub _deserialize {
if ( $type eq 'DateTime' ) {
return DateTime->from_epoch( epoch => str2time($data) );
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
}
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
return $data;
} else { # hash(model)
}
else { # hash(model)
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
return $_instance->from_hash($data);
}
}
__PACKAGE__->class_documentation({description => '',
__PACKAGE__->class_documentation(
{
description => '',
class => 'OuterComposite',
required => [], # TODO
} );
}
);
__PACKAGE__->method_documentation({
__PACKAGE__->method_documentation(
{
'my_number' => {
datatype => 'double',
base_name => 'my_number',
@@ -164,21 +172,25 @@ __PACKAGE__->method_documentation({
format => '',
read_only => '',
},
});
}
);
__PACKAGE__->openapi_types( {
__PACKAGE__->openapi_types(
{
'my_number' => 'double',
'my_string' => 'string',
'my_boolean' => 'boolean'
} );
}
);
__PACKAGE__->attribute_map( {
__PACKAGE__->attribute_map(
{
'my_number' => 'my_number',
'my_string' => 'my_string',
'my_boolean' => 'my_boolean'
} );
}
);
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
1;

View File

@@ -1,3 +1,4 @@
=begin comment
OpenAPI Petstore
@@ -30,10 +31,8 @@ use Log::Any qw($log);
use Date::Parse;
use DateTime;
use base ( "Class::Accessor", "Class::Data::Inheritable" );
#
#
#
@@ -110,10 +109,15 @@ sub from_hash {
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);
}
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 );
}
}
@@ -127,33 +131,38 @@ sub _deserialize {
if ( $type eq 'DateTime' ) {
return DateTime->from_epoch( epoch => str2time($data) );
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
}
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
return $data;
} else { # hash(model)
}
else { # hash(model)
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
return $_instance->from_hash($data);
}
}
__PACKAGE__->class_documentation({description => '',
__PACKAGE__->class_documentation(
{
description => '',
class => 'OuterEnum',
required => [], # TODO
} );
}
);
__PACKAGE__->method_documentation({
});
__PACKAGE__->method_documentation( {} );
__PACKAGE__->openapi_types( {
__PACKAGE__->openapi_types(
{
} );
}
);
__PACKAGE__->attribute_map( {
__PACKAGE__->attribute_map(
{
} );
}
);
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
1;

View File

@@ -1,3 +1,4 @@
=begin comment
OpenAPI Petstore
@@ -35,7 +36,6 @@ use WWW::OpenAPIClient::Object::Tag;
use base ( "Class::Accessor", "Class::Data::Inheritable" );
#
#
#
@@ -112,10 +112,15 @@ sub from_hash {
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);
}
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 );
}
}
@@ -129,22 +134,26 @@ sub _deserialize {
if ( $type eq 'DateTime' ) {
return DateTime->from_epoch( epoch => str2time($data) );
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
}
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
return $data;
} else { # hash(model)
}
else { # hash(model)
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
return $_instance->from_hash($data);
}
}
__PACKAGE__->class_documentation({description => '',
__PACKAGE__->class_documentation(
{
description => '',
class => 'Pet',
required => [], # TODO
} );
}
);
__PACKAGE__->method_documentation({
__PACKAGE__->method_documentation(
{
'id' => {
datatype => 'int',
base_name => 'id',
@@ -187,27 +196,31 @@ __PACKAGE__->method_documentation({
format => '',
read_only => '',
},
});
}
);
__PACKAGE__->openapi_types( {
__PACKAGE__->openapi_types(
{
'id' => 'int',
'category' => 'Category',
'name' => 'string',
'photo_urls' => 'ARRAY[string]',
'tags' => 'ARRAY[Tag]',
'status' => 'string'
} );
}
);
__PACKAGE__->attribute_map( {
__PACKAGE__->attribute_map(
{
'id' => 'id',
'category' => 'category',
'name' => 'name',
'photo_urls' => 'photoUrls',
'tags' => 'tags',
'status' => 'status'
} );
}
);
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
1;

View File

@@ -1,3 +1,4 @@
=begin comment
OpenAPI Petstore
@@ -30,10 +31,8 @@ use Log::Any qw($log);
use Date::Parse;
use DateTime;
use base ( "Class::Accessor", "Class::Data::Inheritable" );
#
#
#
@@ -110,10 +109,15 @@ sub from_hash {
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);
}
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 );
}
}
@@ -127,22 +131,26 @@ sub _deserialize {
if ( $type eq 'DateTime' ) {
return DateTime->from_epoch( epoch => str2time($data) );
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
}
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
return $data;
} else { # hash(model)
}
else { # hash(model)
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
return $_instance->from_hash($data);
}
}
__PACKAGE__->class_documentation({description => '',
__PACKAGE__->class_documentation(
{
description => '',
class => 'ReadOnlyFirst',
required => [], # TODO
} );
}
);
__PACKAGE__->method_documentation({
__PACKAGE__->method_documentation(
{
'bar' => {
datatype => 'string',
base_name => 'bar',
@@ -157,19 +165,23 @@ __PACKAGE__->method_documentation({
format => '',
read_only => '',
},
});
}
);
__PACKAGE__->openapi_types( {
__PACKAGE__->openapi_types(
{
'bar' => 'string',
'baz' => 'string'
} );
}
);
__PACKAGE__->attribute_map( {
__PACKAGE__->attribute_map(
{
'bar' => 'bar',
'baz' => 'baz'
} );
}
);
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
1;

View File

@@ -1,3 +1,4 @@
=begin comment
OpenAPI Petstore
@@ -30,10 +31,8 @@ use Log::Any qw($log);
use Date::Parse;
use DateTime;
use base ( "Class::Accessor", "Class::Data::Inheritable" );
#
#
#
@@ -110,10 +109,15 @@ sub from_hash {
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);
}
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 );
}
}
@@ -127,22 +131,26 @@ sub _deserialize {
if ( $type eq 'DateTime' ) {
return DateTime->from_epoch( epoch => str2time($data) );
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
}
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
return $data;
} else { # hash(model)
}
else { # hash(model)
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
return $_instance->from_hash($data);
}
}
__PACKAGE__->class_documentation({description => '',
__PACKAGE__->class_documentation(
{
description => '',
class => 'SpecialModelName',
required => [], # TODO
} );
}
);
__PACKAGE__->method_documentation({
__PACKAGE__->method_documentation(
{
'__special[property/name]' => {
datatype => 'int',
base_name => '$special[property.name]',
@@ -150,17 +158,21 @@ __PACKAGE__->method_documentation({
format => '',
read_only => '',
},
});
}
);
__PACKAGE__->openapi_types( {
__PACKAGE__->openapi_types(
{
'__special[property/name]' => 'int'
} );
}
);
__PACKAGE__->attribute_map( {
__PACKAGE__->attribute_map(
{
'__special[property/name]' => '$special[property.name]'
} );
}
);
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
1;

View File

@@ -0,0 +1,168 @@
=begin comment
OpenAPI Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0
Generated by: https://openapi-generator.tech
=end comment
=cut
#
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
# Do not edit the class manually.
# Ref: https://openapi-generator.tech
#
package WWW::OpenAPIClient::Object::StringBooleanMap;
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 OpenAPI Generator (https://openapi-generator.tech). Do not edit the class manually.
# REF: https://openapi-generator.tech
#
=begin comment
OpenAPI Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0
Generated by: https://openapi-generator.tech
=end comment
=cut
#
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
# Do not edit the class manually.
# Ref: https://openapi-generator.tech
#
__PACKAGE__->mk_classdata( 'attribute_map' => {} );
__PACKAGE__->mk_classdata( 'openapi_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 openapi_types to deserialize the data
while ( my ( $_key, $_type ) = each %{ $self->openapi_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::OpenAPIClient::Object::$type->new()";
return $_instance->from_hash($data);
}
}
__PACKAGE__->class_documentation(
{
description => '',
class => 'StringBooleanMap',
required => [], # TODO
}
);
__PACKAGE__->method_documentation( {} );
__PACKAGE__->openapi_types(
{
}
);
__PACKAGE__->attribute_map(
{
}
);
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
1;

View File

@@ -1,3 +1,4 @@
=begin comment
OpenAPI Petstore
@@ -30,10 +31,8 @@ use Log::Any qw($log);
use Date::Parse;
use DateTime;
use base ( "Class::Accessor", "Class::Data::Inheritable" );
#
#
#
@@ -110,10 +109,15 @@ sub from_hash {
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);
}
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 );
}
}
@@ -127,22 +131,26 @@ sub _deserialize {
if ( $type eq 'DateTime' ) {
return DateTime->from_epoch( epoch => str2time($data) );
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
}
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
return $data;
} else { # hash(model)
}
else { # hash(model)
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
return $_instance->from_hash($data);
}
}
__PACKAGE__->class_documentation({description => '',
__PACKAGE__->class_documentation(
{
description => '',
class => 'Tag',
required => [], # TODO
} );
}
);
__PACKAGE__->method_documentation({
__PACKAGE__->method_documentation(
{
'id' => {
datatype => 'int',
base_name => 'id',
@@ -157,19 +165,23 @@ __PACKAGE__->method_documentation({
format => '',
read_only => '',
},
});
}
);
__PACKAGE__->openapi_types( {
__PACKAGE__->openapi_types(
{
'id' => 'int',
'name' => 'string'
} );
}
);
__PACKAGE__->attribute_map( {
__PACKAGE__->attribute_map(
{
'id' => 'id',
'name' => 'name'
} );
}
);
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
1;

View File

@@ -1,3 +1,4 @@
=begin comment
OpenAPI Petstore
@@ -30,10 +31,8 @@ use Log::Any qw($log);
use Date::Parse;
use DateTime;
use base ( "Class::Accessor", "Class::Data::Inheritable" );
#
#
#
@@ -110,10 +109,15 @@ sub from_hash {
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);
}
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 );
}
}
@@ -127,22 +131,26 @@ sub _deserialize {
if ( $type eq 'DateTime' ) {
return DateTime->from_epoch( epoch => str2time($data) );
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
}
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
return $data;
} else { # hash(model)
}
else { # hash(model)
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
return $_instance->from_hash($data);
}
}
__PACKAGE__->class_documentation({description => '',
__PACKAGE__->class_documentation(
{
description => '',
class => 'User',
required => [], # TODO
} );
}
);
__PACKAGE__->method_documentation({
__PACKAGE__->method_documentation(
{
'id' => {
datatype => 'int',
base_name => 'id',
@@ -199,9 +207,11 @@ __PACKAGE__->method_documentation({
format => '',
read_only => '',
},
});
}
);
__PACKAGE__->openapi_types( {
__PACKAGE__->openapi_types(
{
'id' => 'int',
'username' => 'string',
'first_name' => 'string',
@@ -210,9 +220,11 @@ __PACKAGE__->openapi_types( {
'password' => 'string',
'phone' => 'string',
'user_status' => 'int'
} );
}
);
__PACKAGE__->attribute_map( {
__PACKAGE__->attribute_map(
{
'id' => 'id',
'username' => 'username',
'first_name' => 'firstName',
@@ -221,9 +233,9 @@ __PACKAGE__->attribute_map( {
'password' => 'password',
'phone' => 'phone',
'user_status' => 'userStatus'
} );
}
);
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
1;

View File

@@ -1,3 +1,4 @@
=begin comment
OpenAPI Petstore
@@ -39,7 +40,8 @@ sub new {
if ( $_[0] && ref $_[0] && ref $_[0] eq 'WWW::OpenAPIClient::ApiClient' ) {
$api_client = $_[0];
} else {
}
else {
$api_client = WWW::OpenAPIClient::ApiClient->new(@_);
}
@@ -47,7 +49,6 @@ sub new {
}
#
# add_pet
#
@@ -68,6 +69,7 @@ sub new {
returns => undef,
};
}
# @return void
#
sub add_pet {
@@ -91,9 +93,11 @@ sub add_pet {
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/json', 'application/xml');
$header_params->{'Content-Type'} = $self->{api_client}
->select_header_content_type( 'application/json', 'application/xml' );
my $_body_data;
# body params
if ( exists $args{'pet'} ) {
$_body_data = $args{'pet'};
@@ -103,9 +107,10 @@ sub add_pet {
my $auth_settings = [qw(petstore_auth )];
# make the API Call
$self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
$self->{api_client}->call_api(
$_resource_path, $_method, $query_params, $form_params,
$header_params, $_body_data, $auth_settings
);
return;
}
@@ -135,6 +140,7 @@ sub add_pet {
returns => undef,
};
}
# @return void
#
sub delete_pet {
@@ -142,7 +148,8 @@ sub delete_pet {
# verify the required parameter 'pet_id' is set
unless ( exists $args{'pet_id'} ) {
croak("Missing the required parameter 'pet_id' when calling delete_pet");
croak(
"Missing the required parameter 'pet_id' when calling delete_pet");
}
# parse inputs
@@ -158,11 +165,13 @@ sub delete_pet {
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
$header_params->{'Content-Type'} =
$self->{api_client}->select_header_content_type();
# header params
if ( exists $args{'api_key'} ) {
$header_params->{'api_key'} = $self->{api_client}->to_header_value($args{'api_key'});
$header_params->{'api_key'} =
$self->{api_client}->to_header_value( $args{'api_key'} );
}
# path params
@@ -173,13 +182,15 @@ sub delete_pet {
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw(petstore_auth )];
# make the API Call
$self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
$self->{api_client}->call_api(
$_resource_path, $_method, $query_params, $form_params,
$header_params, $_body_data, $auth_settings
);
return;
}
@@ -193,7 +204,8 @@ sub delete_pet {
my $params = {
'status' => {
data_type => 'ARRAY[string]',
description => 'Status values that need to be considered for filter',
description =>
'Status values that need to be considered for filter',
required => '1',
},
};
@@ -203,6 +215,7 @@ sub delete_pet {
returns => 'ARRAY[Pet]',
};
}
# @return ARRAY[Pet]
#
sub find_pets_by_status {
@@ -210,7 +223,9 @@ sub find_pets_by_status {
# verify the required parameter 'status' is set
unless ( exists $args{'status'} ) {
croak("Missing the required parameter 'status' when calling find_pets_by_status");
croak(
"Missing the required parameter 'status' when calling find_pets_by_status"
);
}
# parse inputs
@@ -222,29 +237,35 @@ sub find_pets_by_status {
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/xml', 'application/json');
my $_header_accept = $self->{api_client}
->select_header_accept( 'application/xml', 'application/json' );
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
$header_params->{'Content-Type'} =
$self->{api_client}->select_header_content_type();
# query params
if ( exists $args{'status'} ) {
$query_params->{'status'} = $self->{api_client}->to_query_value($args{'status'});
$query_params->{'status'} =
$self->{api_client}->to_query_value( $args{'status'} );
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw(petstore_auth )];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
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('ARRAY[Pet]', $response);
my $_response_object =
$self->{api_client}->deserialize( 'ARRAY[Pet]', $response );
return $_response_object;
}
@@ -268,6 +289,7 @@ sub find_pets_by_status {
returns => 'ARRAY[Pet]',
};
}
# @return ARRAY[Pet]
#
sub find_pets_by_tags {
@@ -275,7 +297,9 @@ sub find_pets_by_tags {
# verify the required parameter 'tags' is set
unless ( exists $args{'tags'} ) {
croak("Missing the required parameter 'tags' when calling find_pets_by_tags");
croak(
"Missing the required parameter 'tags' when calling find_pets_by_tags"
);
}
# parse inputs
@@ -287,29 +311,35 @@ sub find_pets_by_tags {
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/xml', 'application/json');
my $_header_accept = $self->{api_client}
->select_header_accept( 'application/xml', 'application/json' );
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
$header_params->{'Content-Type'} =
$self->{api_client}->select_header_content_type();
# query params
if ( exists $args{'tags'} ) {
$query_params->{'tags'} = $self->{api_client}->to_query_value($args{'tags'});
$query_params->{'tags'} =
$self->{api_client}->to_query_value( $args{'tags'} );
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw(petstore_auth )];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
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('ARRAY[Pet]', $response);
my $_response_object =
$self->{api_client}->deserialize( 'ARRAY[Pet]', $response );
return $_response_object;
}
@@ -333,6 +363,7 @@ sub find_pets_by_tags {
returns => 'Pet',
};
}
# @return Pet
#
sub get_pet_by_id {
@@ -340,7 +371,9 @@ sub get_pet_by_id {
# verify the required parameter 'pet_id' is set
unless ( exists $args{'pet_id'} ) {
croak("Missing the required parameter 'pet_id' when calling get_pet_by_id");
croak(
"Missing the required parameter 'pet_id' when calling get_pet_by_id"
);
}
# parse inputs
@@ -352,11 +385,13 @@ sub get_pet_by_id {
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/xml', 'application/json');
my $_header_accept = $self->{api_client}
->select_header_accept( 'application/xml', 'application/json' );
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
$header_params->{'Content-Type'} =
$self->{api_client}->select_header_content_type();
# path params
if ( exists $args{'pet_id'} ) {
@@ -366,13 +401,15 @@ sub get_pet_by_id {
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw(api_key )];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
my $response = $self->{api_client}->call_api(
$_resource_path, $_method, $query_params, $form_params,
$header_params, $_body_data, $auth_settings
);
if ( !$response ) {
return;
}
@@ -400,6 +437,7 @@ sub get_pet_by_id {
returns => undef,
};
}
# @return void
#
sub update_pet {
@@ -423,9 +461,11 @@ sub update_pet {
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/json', 'application/xml');
$header_params->{'Content-Type'} = $self->{api_client}
->select_header_content_type( 'application/json', 'application/xml' );
my $_body_data;
# body params
if ( exists $args{'pet'} ) {
$_body_data = $args{'pet'};
@@ -435,9 +475,10 @@ sub update_pet {
my $auth_settings = [qw(petstore_auth )];
# make the API Call
$self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
$self->{api_client}->call_api(
$_resource_path, $_method, $query_params, $form_params,
$header_params, $_body_data, $auth_settings
);
return;
}
@@ -473,6 +514,7 @@ sub update_pet {
returns => undef,
};
}
# @return void
#
sub update_pet_with_form {
@@ -480,7 +522,9 @@ sub update_pet_with_form {
# verify the required parameter 'pet_id' is set
unless ( exists $args{'pet_id'} ) {
croak("Missing the required parameter 'pet_id' when calling update_pet_with_form");
croak(
"Missing the required parameter 'pet_id' when calling update_pet_with_form"
);
}
# parse inputs
@@ -496,7 +540,8 @@ sub update_pet_with_form {
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/x-www-form-urlencoded');
$header_params->{'Content-Type'} = $self->{api_client}
->select_header_content_type('application/x-www-form-urlencoded');
# path params
if ( exists $args{'pet_id'} ) {
@@ -507,22 +552,26 @@ sub update_pet_with_form {
# form params
if ( exists $args{'name'} ) {
$form_params->{'name'} = $self->{api_client}->to_form_value($args{'name'});
$form_params->{'name'} =
$self->{api_client}->to_form_value( $args{'name'} );
}
# form params
if ( exists $args{'status'} ) {
$form_params->{'status'} = $self->{api_client}->to_form_value($args{'status'});
$form_params->{'status'} =
$self->{api_client}->to_form_value( $args{'status'} );
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw(petstore_auth )];
# make the API Call
$self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
$self->{api_client}->call_api(
$_resource_path, $_method, $query_params, $form_params,
$header_params, $_body_data, $auth_settings
);
return;
}
@@ -558,6 +607,7 @@ sub update_pet_with_form {
returns => 'ApiResponse',
};
}
# @return ApiResponse
#
sub upload_file {
@@ -565,7 +615,8 @@ sub upload_file {
# verify the required parameter 'pet_id' is set
unless ( exists $args{'pet_id'} ) {
croak("Missing the required parameter 'pet_id' when calling upload_file");
croak(
"Missing the required parameter 'pet_id' when calling upload_file");
}
# parse inputs
@@ -577,11 +628,13 @@ sub upload_file {
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
my $_header_accept =
$self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('multipart/form-data');
$header_params->{'Content-Type'} =
$self->{api_client}->select_header_content_type('multipart/form-data');
# path params
if ( exists $args{'pet_id'} ) {
@@ -592,7 +645,8 @@ sub upload_file {
# form params
if ( exists $args{'additional_metadata'} ) {
$form_params->{'additionalMetadata'} = $self->{api_client}->to_form_value($args{'additional_metadata'});
$form_params->{'additionalMetadata'} =
$self->{api_client}->to_form_value( $args{'additional_metadata'} );
}
# form params
@@ -602,17 +656,127 @@ sub upload_file {
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw(petstore_auth )];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
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('ApiResponse', $response);
my $_response_object =
$self->{api_client}->deserialize( 'ApiResponse', $response );
return $_response_object;
}
#
# upload_file_with_required_file
#
# uploads an image (required)
#
# @param int $pet_id ID of pet to update (required)
# @param string $required_file file to upload (required)
# @param string $additional_metadata Additional data to pass to server (optional)
{
my $params = {
'pet_id' => {
data_type => 'int',
description => 'ID of pet to update',
required => '1',
},
'required_file' => {
data_type => 'string',
description => 'file to upload',
required => '1',
},
'additional_metadata' => {
data_type => 'string',
description => 'Additional data to pass to server',
required => '0',
},
};
__PACKAGE__->method_documentation->{'upload_file_with_required_file'} = {
summary => 'uploads an image (required)',
params => $params,
returns => 'ApiResponse',
};
}
# @return ApiResponse
#
sub upload_file_with_required_file {
my ( $self, %args ) = @_;
# verify the required parameter 'pet_id' is set
unless ( exists $args{'pet_id'} ) {
croak(
"Missing the required parameter 'pet_id' when calling upload_file_with_required_file"
);
}
# verify the required parameter 'required_file' is set
unless ( exists $args{'required_file'} ) {
croak(
"Missing the required parameter 'required_file' when calling upload_file_with_required_file"
);
}
# parse inputs
my $_resource_path = '/fake/{petId}/uploadImageWithRequiredFile';
my $_method = 'POST';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept =
$self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} =
$self->{api_client}->select_header_content_type('multipart/form-data');
# path params
if ( exists $args{'pet_id'} ) {
my $_base_variable = "{" . "petId" . "}";
my $_base_value = $self->{api_client}->to_path_value( $args{'pet_id'} );
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
# form params
if ( exists $args{'additional_metadata'} ) {
$form_params->{'additionalMetadata'} =
$self->{api_client}->to_form_value( $args{'additional_metadata'} );
}
# form params
if ( exists $args{'required_file'} ) {
$form_params->{'requiredFile'} = []
unless defined $form_params->{'requiredFile'};
push @{ $form_params->{'requiredFile'} }, $args{'required_file'};
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw(petstore_auth )];
# 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( 'ApiResponse', $response );
return $_response_object;
}

View File

@@ -1,3 +1,4 @@
=begin comment
OpenAPI Petstore
@@ -26,39 +27,49 @@ use Class::Inspector;
use Log::Any qw($log);
use WWW::OpenAPIClient::ApiFactory;
has base_url => ( is => 'ro',
has base_url => (
is => 'ro',
required => 0,
isa => 'Str',
documentation => 'Root of the server that requests are sent to',
);
has api_factory => ( is => 'ro',
has api_factory => (
is => 'ro',
isa => 'WWW::OpenAPIClient::ApiFactory',
builder => '_build_af',
lazy => 1,
documentation => 'Builds an instance of the endpoint API class',
);
has tokens => ( is => 'ro',
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)',
documentation =>
'The auth tokens required by the application - basic, OAuth and/or API key(s)',
);
has _cfg => ( is => 'ro',
has _cfg => (
is => 'ro',
isa => 'WWW::OpenAPIClient::Configuration',
default => sub { WWW::OpenAPIClient::Configuration->new() },
);
has version_info => ( is => 'ro',
has version_info => (
is => 'ro',
isa => 'HashRef',
default => sub { {
default => sub {
{
app_name => 'OpenAPI Petstore',
app_version => '1.0.0',
generator_class => 'org.openapitools.codegen.languages.PerlClientCodegen',
} },
documentation => 'Information about the application version and the codegen codebase version'
generator_class =>
'org.openapitools.codegen.languages.PerlClientCodegen',
}
},
documentation =>
'Information about the application version and the codegen codebase version'
);
sub BUILD {
@@ -74,9 +85,16 @@ sub BUILD {
# collect the methods callable on each API
foreach my $api_name ( $self->api_factory->apis_available ) {
my $api_class = $self->api_factory->classname_for($api_name);
my $methods = Class::Inspector->methods($api_class, 'expanded'); # not Moose, so use CI instead
my @local_methods = grep {! /^_/} grep {! $outsiders{$_}} map {$_->[2]} grep {$_->[1] eq $api_class} @$methods;
push( @{$delegates{$_}}, {api_name => $api_name, api_class => $api_class} ) for @local_methods;
my $methods = Class::Inspector->methods( $api_class, 'expanded' )
; # not Moose, so use CI instead
my @local_methods =
grep { !/^_/ }
grep { !$outsiders{$_} }
map { $_->[2] } grep { $_->[1] eq $api_class } @$methods;
push(
@{ $delegates{$_} },
{ api_name => $api_name, api_class => $api_class }
) for @local_methods;
}
# remove clashes
@@ -90,15 +108,19 @@ sub BUILD {
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 => (
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,
) );
)
);
}
}

View File

@@ -1,3 +1,4 @@
=begin comment
OpenAPI Petstore
@@ -41,6 +42,7 @@ sub _printisa {
my $super = join ', ', $meta->superclasses;
my @roles = $meta->calculate_all_roles;
#shift(@roles) if @roles > 1; # if > 1, the first is a composite, the rest are the roles
my $isa = join ', ', grep { $_ ne $myclass } $meta->linearized_isa;
@@ -165,6 +167,7 @@ $role_reqs
.
# ----- / format specs -----
}
@@ -189,25 +192,28 @@ HEAD
die "Don't know how to print '$how'";
}
$self->_printmethod($_, $how) for uniq sort $self->meta->get_all_method_names; #$self->meta->get_method_list,
$self->_printmethod( $_, $how )
for uniq
sort $self->meta->get_all_method_names; #$self->meta->get_method_list,
if ( $how eq 'pod' ) {
$~ = 'METHOD_POD_CLOSE';
write;
}
}
sub _printmethod {
my ( $self, $methodname, $how ) = @_;
return if $methodname =~ /^_/;
return if $self->meta->has_attribute($methodname);
my %internal = map {$_ => 1} qw(BUILD BUILDARGS meta can new DEMOLISHALL DESTROY
my %internal = map { $_ => 1 }
qw(BUILD BUILDARGS meta can new DEMOLISHALL DESTROY
DOES isa BUILDALL does VERSION dump
);
return if $internal{$methodname};
my $method = $self->meta->get_method($methodname) or return; # symbols imported into namespaces i.e. not known by Moose
my $method = $self->meta->get_method($methodname)
or return; # symbols imported into namespaces i.e. not known by Moose
return if $method->original_package_name eq __PACKAGE__;
@@ -310,6 +316,7 @@ $methodname
format METHOD_POD_CLOSE =
.
# ----- / format specs -----
}
@@ -345,7 +352,8 @@ HEAD
sub _printattr {
my ( $self, $attrname, $how ) = @_;
return if $attrname =~ /^_/;
my $attr = $self->meta->get_attribute($attrname) or die "No attr for $attrname";
my $attr = $self->meta->get_attribute($attrname)
or die "No attr for $attrname";
my $is;
$is = 'rw' if $attr->get_read_method && $attr->get_write_method;
@@ -358,7 +366,11 @@ sub _printattr {
my $from = $attr->associated_class->name || '';
my $reqd = $attr->is_required ? 'yes' : 'no';
my $lazy = $attr->is_lazy ? 'yes' : 'no';
my $has_doc = $attr->has_documentation ? 'yes' : 'no'; # *_api attributes will never have doc, but other attributes might have
my $has_doc =
$attr->has_documentation
? 'yes'
: 'no'
; # *_api attributes will never have doc, but other attributes might have
my $doc = $attr->documentation || '';
my $handles = join ', ', sort @{ $attr->handles || [] };
$handles ||= '';
@@ -438,9 +450,8 @@ $attrname
.
# ----- / format specs -----
}
1;

View File

@@ -1,3 +1,4 @@
=begin comment
OpenAPI Petstore
@@ -39,7 +40,8 @@ sub new {
if ( $_[0] && ref $_[0] && ref $_[0] eq 'WWW::OpenAPIClient::ApiClient' ) {
$api_client = $_[0];
} else {
}
else {
$api_client = WWW::OpenAPIClient::ApiClient->new(@_);
}
@@ -47,7 +49,6 @@ sub new {
}
#
# delete_order
#
@@ -68,6 +69,7 @@ sub new {
returns => undef,
};
}
# @return void
#
sub delete_order {
@@ -75,7 +77,9 @@ sub delete_order {
# verify the required parameter 'order_id' is set
unless ( exists $args{'order_id'} ) {
croak("Missing the required parameter 'order_id' when calling delete_order");
croak(
"Missing the required parameter 'order_id' when calling delete_order"
);
}
# parse inputs
@@ -91,23 +95,27 @@ sub delete_order {
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
$header_params->{'Content-Type'} =
$self->{api_client}->select_header_content_type();
# path params
if ( exists $args{'order_id'} ) {
my $_base_variable = "{" . "order_id" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'order_id'});
my $_base_value =
$self->{api_client}->to_path_value( $args{'order_id'} );
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw()];
# make the API Call
$self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
$self->{api_client}->call_api(
$_resource_path, $_method, $query_params, $form_params,
$header_params, $_body_data, $auth_settings
);
return;
}
@@ -117,14 +125,14 @@ sub delete_order {
# Returns pet inventories by status
#
{
my $params = {
};
my $params = {};
__PACKAGE__->method_documentation->{'get_inventory'} = {
summary => 'Returns pet inventories by status',
params => $params,
returns => 'HASH[string,int]',
};
}
# @return HASH[string,int]
#
sub get_inventory {
@@ -139,24 +147,29 @@ sub get_inventory {
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
my $_header_accept =
$self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
$header_params->{'Content-Type'} =
$self->{api_client}->select_header_content_type();
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw(api_key )];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
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('HASH[string,int]', $response);
my $_response_object =
$self->{api_client}->deserialize( 'HASH[string,int]', $response );
return $_response_object;
}
@@ -180,6 +193,7 @@ sub get_inventory {
returns => 'Order',
};
}
# @return Order
#
sub get_order_by_id {
@@ -187,7 +201,9 @@ sub get_order_by_id {
# verify the required parameter 'order_id' is set
unless ( exists $args{'order_id'} ) {
croak("Missing the required parameter 'order_id' when calling get_order_by_id");
croak(
"Missing the required parameter 'order_id' when calling get_order_by_id"
);
}
# parse inputs
@@ -199,31 +215,37 @@ sub get_order_by_id {
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/xml', 'application/json');
my $_header_accept = $self->{api_client}
->select_header_accept( 'application/xml', 'application/json' );
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
$header_params->{'Content-Type'} =
$self->{api_client}->select_header_content_type();
# path params
if ( exists $args{'order_id'} ) {
my $_base_variable = "{" . "order_id" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'order_id'});
my $_base_value =
$self->{api_client}->to_path_value( $args{'order_id'} );
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
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);
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('Order', $response);
my $_response_object =
$self->{api_client}->deserialize( 'Order', $response );
return $_response_object;
}
@@ -247,6 +269,7 @@ sub get_order_by_id {
returns => 'Order',
};
}
# @return Order
#
sub place_order {
@@ -254,7 +277,8 @@ sub place_order {
# verify the required parameter 'order' is set
unless ( exists $args{'order'} ) {
croak("Missing the required parameter 'order' when calling place_order");
croak(
"Missing the required parameter 'order' when calling place_order");
}
# parse inputs
@@ -266,13 +290,16 @@ sub place_order {
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/xml', 'application/json');
my $_header_accept = $self->{api_client}
->select_header_accept( 'application/xml', 'application/json' );
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
$header_params->{'Content-Type'} =
$self->{api_client}->select_header_content_type();
my $_body_data;
# body params
if ( exists $args{'order'} ) {
$_body_data = $args{'order'};
@@ -282,13 +309,15 @@ sub place_order {
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);
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('Order', $response);
my $_response_object =
$self->{api_client}->deserialize( 'Order', $response );
return $_response_object;
}

View File

@@ -1,3 +1,4 @@
=begin comment
OpenAPI Petstore
@@ -39,7 +40,8 @@ sub new {
if ( $_[0] && ref $_[0] && ref $_[0] eq 'WWW::OpenAPIClient::ApiClient' ) {
$api_client = $_[0];
} else {
}
else {
$api_client = WWW::OpenAPIClient::ApiClient->new(@_);
}
@@ -47,7 +49,6 @@ sub new {
}
#
# create_user
#
@@ -68,6 +69,7 @@ sub new {
returns => undef,
};
}
# @return void
#
sub create_user {
@@ -91,9 +93,11 @@ sub create_user {
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
$header_params->{'Content-Type'} =
$self->{api_client}->select_header_content_type();
my $_body_data;
# body params
if ( exists $args{'user'} ) {
$_body_data = $args{'user'};
@@ -103,9 +107,10 @@ sub create_user {
my $auth_settings = [qw()];
# make the API Call
$self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
$self->{api_client}->call_api(
$_resource_path, $_method, $query_params, $form_params,
$header_params, $_body_data, $auth_settings
);
return;
}
@@ -129,6 +134,7 @@ sub create_user {
returns => undef,
};
}
# @return void
#
sub create_users_with_array_input {
@@ -136,7 +142,9 @@ sub create_users_with_array_input {
# verify the required parameter 'user' is set
unless ( exists $args{'user'} ) {
croak("Missing the required parameter 'user' when calling create_users_with_array_input");
croak(
"Missing the required parameter 'user' when calling create_users_with_array_input"
);
}
# parse inputs
@@ -152,9 +160,11 @@ sub create_users_with_array_input {
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
$header_params->{'Content-Type'} =
$self->{api_client}->select_header_content_type();
my $_body_data;
# body params
if ( exists $args{'user'} ) {
$_body_data = $args{'user'};
@@ -164,9 +174,10 @@ sub create_users_with_array_input {
my $auth_settings = [qw()];
# make the API Call
$self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
$self->{api_client}->call_api(
$_resource_path, $_method, $query_params, $form_params,
$header_params, $_body_data, $auth_settings
);
return;
}
@@ -190,6 +201,7 @@ sub create_users_with_array_input {
returns => undef,
};
}
# @return void
#
sub create_users_with_list_input {
@@ -197,7 +209,9 @@ sub create_users_with_list_input {
# verify the required parameter 'user' is set
unless ( exists $args{'user'} ) {
croak("Missing the required parameter 'user' when calling create_users_with_list_input");
croak(
"Missing the required parameter 'user' when calling create_users_with_list_input"
);
}
# parse inputs
@@ -213,9 +227,11 @@ sub create_users_with_list_input {
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
$header_params->{'Content-Type'} =
$self->{api_client}->select_header_content_type();
my $_body_data;
# body params
if ( exists $args{'user'} ) {
$_body_data = $args{'user'};
@@ -225,9 +241,10 @@ sub create_users_with_list_input {
my $auth_settings = [qw()];
# make the API Call
$self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
$self->{api_client}->call_api(
$_resource_path, $_method, $query_params, $form_params,
$header_params, $_body_data, $auth_settings
);
return;
}
@@ -251,6 +268,7 @@ sub create_users_with_list_input {
returns => undef,
};
}
# @return void
#
sub delete_user {
@@ -258,7 +276,9 @@ sub delete_user {
# verify the required parameter 'username' is set
unless ( exists $args{'username'} ) {
croak("Missing the required parameter 'username' when calling delete_user");
croak(
"Missing the required parameter 'username' when calling delete_user"
);
}
# parse inputs
@@ -274,23 +294,27 @@ sub delete_user {
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
$header_params->{'Content-Type'} =
$self->{api_client}->select_header_content_type();
# path params
if ( exists $args{'username'} ) {
my $_base_variable = "{" . "username" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'username'});
my $_base_value =
$self->{api_client}->to_path_value( $args{'username'} );
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw()];
# make the API Call
$self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
$self->{api_client}->call_api(
$_resource_path, $_method, $query_params, $form_params,
$header_params, $_body_data, $auth_settings
);
return;
}
@@ -304,7 +328,8 @@ sub delete_user {
my $params = {
'username' => {
data_type => 'string',
description => 'The name that needs to be fetched. Use user1 for testing.',
description =>
'The name that needs to be fetched. Use user1 for testing.',
required => '1',
},
};
@@ -314,6 +339,7 @@ sub delete_user {
returns => 'User',
};
}
# @return User
#
sub get_user_by_name {
@@ -321,7 +347,9 @@ sub get_user_by_name {
# verify the required parameter 'username' is set
unless ( exists $args{'username'} ) {
croak("Missing the required parameter 'username' when calling get_user_by_name");
croak(
"Missing the required parameter 'username' when calling get_user_by_name"
);
}
# parse inputs
@@ -333,31 +361,37 @@ sub get_user_by_name {
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/xml', 'application/json');
my $_header_accept = $self->{api_client}
->select_header_accept( 'application/xml', 'application/json' );
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
$header_params->{'Content-Type'} =
$self->{api_client}->select_header_content_type();
# path params
if ( exists $args{'username'} ) {
my $_base_variable = "{" . "username" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'username'});
my $_base_value =
$self->{api_client}->to_path_value( $args{'username'} );
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
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);
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('User', $response);
my $_response_object =
$self->{api_client}->deserialize( 'User', $response );
return $_response_object;
}
@@ -387,6 +421,7 @@ sub get_user_by_name {
returns => 'string',
};
}
# @return string
#
sub login_user {
@@ -394,12 +429,16 @@ sub login_user {
# verify the required parameter 'username' is set
unless ( exists $args{'username'} ) {
croak("Missing the required parameter 'username' when calling login_user");
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");
croak(
"Missing the required parameter 'password' when calling login_user"
);
}
# parse inputs
@@ -411,34 +450,41 @@ sub login_user {
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/xml', 'application/json');
my $_header_accept = $self->{api_client}
->select_header_accept( 'application/xml', 'application/json' );
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
$header_params->{'Content-Type'} =
$self->{api_client}->select_header_content_type();
# query params
if ( exists $args{'username'} ) {
$query_params->{'username'} = $self->{api_client}->to_query_value($args{'username'});
$query_params->{'username'} =
$self->{api_client}->to_query_value( $args{'username'} );
}
# query params
if ( exists $args{'password'} ) {
$query_params->{'password'} = $self->{api_client}->to_query_value($args{'password'});
$query_params->{'password'} =
$self->{api_client}->to_query_value( $args{'password'} );
}
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);
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('string', $response);
my $_response_object =
$self->{api_client}->deserialize( 'string', $response );
return $_response_object;
}
@@ -448,14 +494,14 @@ sub login_user {
# Logs out current logged in user session
#
{
my $params = {
};
my $params = {};
__PACKAGE__->method_documentation->{'logout_user'} = {
summary => 'Logs out current logged in user session',
params => $params,
returns => undef,
};
}
# @return void
#
sub logout_user {
@@ -474,16 +520,19 @@ sub logout_user {
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
$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
$self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
$self->{api_client}->call_api(
$_resource_path, $_method, $query_params, $form_params,
$header_params, $_body_data, $auth_settings
);
return;
}
@@ -513,6 +562,7 @@ sub logout_user {
returns => undef,
};
}
# @return void
#
sub update_user {
@@ -520,7 +570,9 @@ sub update_user {
# verify the required parameter 'username' is set
unless ( exists $args{'username'} ) {
croak("Missing the required parameter 'username' when calling update_user");
croak(
"Missing the required parameter 'username' when calling update_user"
);
}
# verify the required parameter 'user' is set
@@ -541,16 +593,19 @@ sub update_user {
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
$header_params->{'Content-Type'} =
$self->{api_client}->select_header_content_type();
# path params
if ( exists $args{'username'} ) {
my $_base_variable = "{" . "username" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'username'});
my $_base_value =
$self->{api_client}->to_path_value( $args{'username'} );
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
my $_body_data;
# body params
if ( exists $args{'user'} ) {
$_body_data = $args{'user'};
@@ -560,9 +615,10 @@ sub update_user {
my $auth_settings = [qw()];
# make the API Call
$self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
$self->{api_client}->call_api(
$_resource_path, $_method, $query_params, $form_params,
$header_params, $_body_data, $auth_settings
);
return;
}

View File

@@ -0,0 +1,33 @@
=begin comment
OpenAPI Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0
Generated by: https://openapi-generator.tech
=end comment
=cut
#
# NOTE: This class is auto generated by the OpenAPI Generator
# Please update the test cases below to test the model.
# Ref: https://openapi-generator.tech
#
use Test::More tests => 2;
use Test::Exception;
use lib 'lib';
use strict;
use warnings;
use_ok('WWW::OpenAPIClient::Object::FileSchemaTestClass');
my $instance = WWW::OpenAPIClient::Object::FileSchemaTestClass->new();
isa_ok($instance, 'WWW::OpenAPIClient::Object::FileSchemaTestClass');

View File

@@ -0,0 +1,33 @@
=begin comment
OpenAPI Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0
Generated by: https://openapi-generator.tech
=end comment
=cut
#
# NOTE: This class is auto generated by the OpenAPI Generator
# Please update the test cases below to test the model.
# Ref: https://openapi-generator.tech
#
use Test::More tests => 2;
use Test::Exception;
use lib 'lib';
use strict;
use warnings;
use_ok('WWW::OpenAPIClient::Object::File');
my $instance = WWW::OpenAPIClient::Object::File->new();
isa_ok($instance, 'WWW::OpenAPIClient::Object::File');

View File

@@ -0,0 +1,33 @@
=begin comment
OpenAPI Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0
Generated by: https://openapi-generator.tech
=end comment
=cut
#
# NOTE: This class is auto generated by the OpenAPI Generator
# Please update the test cases below to test the model.
# Ref: https://openapi-generator.tech
#
use Test::More tests => 2;
use Test::Exception;
use lib 'lib';
use strict;
use warnings;
use_ok('WWW::OpenAPIClient::Object::StringBooleanMap');
my $instance = WWW::OpenAPIClient::Object::StringBooleanMap->new();
isa_ok($instance, 'WWW::OpenAPIClient::Object::StringBooleanMap');

View File

@@ -34,10 +34,18 @@ my $api = WWW::OpenAPIClient::PetApi->new(
my $pet_id = 10008;
my $category = WWW::OpenAPIClient::Object::Category->new('id' => '2', 'name' => 'perl');
my $tag = WWW::OpenAPIClient::Object::Tag->new('id' => '1', 'name' => 'just kidding');
my $pet = WWW::OpenAPIClient::Object::Pet->new('id' => $pet_id, 'name' => 'perl test',
"photoUrls" => ['123', 'oop'], 'tags' => [$tag], 'status' => 'pending', 'category' => $category);
my $category =
WWW::OpenAPIClient::Object::Category->new( 'id' => '2', 'name' => 'perl' );
my $tag =
WWW::OpenAPIClient::Object::Tag->new( 'id' => '1', 'name' => 'just kidding' );
my $pet = WWW::OpenAPIClient::Object::Pet->new(
'id' => $pet_id,
'name' => 'perl test',
"photoUrls" => [ '123', 'oop' ],
'tags' => [$tag],
'status' => 'pending',
'category' => $category
);
print "\npet(object)=" . Dumper $pet;
my $json = JSON->new->convert_blessed;
@@ -47,10 +55,20 @@ $new_pet = $new_pet->from_hash($pet->to_hash);
print "new_pet(hash):" . Dumper( $new_pet->to_hash );
print "\nTest Petstore endpoints\n";
print "\nupload_file:".Dumper $api->upload_file(pet_id => $pet_id, additional_metadata => 'testabc', file => './test.pl');
print "\nupload_file:"
. Dumper $api->upload_file(
pet_id => $pet_id,
additional_metadata => 'testabc',
file => './test.pl'
);
print "\nadd_pet:" . Dumper $api->add_pet( body => $pet );
print "\nget_pet_by_id:" . Dumper $api->get_pet_by_id( pet_id => $pet_id );
print "\nupdate_pet_with_form:".Dumper $api->update_pet_with_form(pet_id => $pet_id, name => 'test_name', status => 'test status');
print "\nupdate_pet_with_form:"
. Dumper $api->update_pet_with_form(
pet_id => $pet_id,
name => 'test_name',
status => 'test status'
);
print "\ndelete_pet:" . Dumper $api->delete_pet( pet_id => $pet_id );
my $store_api = WWW::OpenAPIClient::StoreApi->new();
@@ -79,4 +97,5 @@ my $pet_json = <<JSON;
}
JSON
print "\napi_client->deserialize:".Dumper($api->{api_client}->deserialize("HASH[string,Pet]", $pet_json));
print "\napi_client->deserialize:"
. Dumper( $api->{api_client}->deserialize( "HASH[string,Pet]", $pet_json ) );

View File

@@ -50,7 +50,7 @@ is $get_pet->tags->[0]->id, '11', 'stored and retrieved: got the proper tag id';
# API method docs
is_deeply( [sort keys %{$api->pet_api->method_documentation}],
[ 'add_pet', 'delete_pet', 'find_pets_by_status', 'find_pets_by_tags', 'get_pet_by_id', 'update_pet', 'update_pet_with_form', 'upload_file'],
[ 'add_pet', 'delete_pet', 'find_pets_by_status', 'find_pets_by_tags', 'get_pet_by_id', 'update_pet', 'update_pet_with_form', 'upload_file', 'upload_file_with_required_file'],
"Pet API method_documentation has the correct keys");
is $api->pet_api->method_documentation->{get_pet_by_id}->{params}->{pet_id}->{description},
'ID of pet to return', 'get_pet_by_id parameter pet_id description is correct';