mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-07 10:58:55 +00:00
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:
parent
39c734fc25
commit
e29f263941
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
3.0.0-SNAPSHOT
|
||||
3.3.0-SNAPSHOT
|
@ -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)
|
||||
|
||||
|
@ -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";
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -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
|
||||
|
15
samples/client/petstore/perl/docs/File.md
Normal file
15
samples/client/petstore/perl/docs/File.md
Normal 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)
|
||||
|
||||
|
16
samples/client/petstore/perl/docs/FileSchemaTestClass.md
Normal file
16
samples/client/petstore/perl/docs/FileSchemaTestClass.md
Normal 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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
14
samples/client/petstore/perl/docs/StringBooleanMap.md
Normal file
14
samples/client/petstore/perl/docs/StringBooleanMap.md
Normal 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)
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
=begin comment
|
||||
|
||||
OpenAPI Petstore
|
||||
@ -22,7 +23,7 @@ package WWW::OpenAPIClient::AnotherFakeApi;
|
||||
require 5.6.0;
|
||||
use strict;
|
||||
use warnings;
|
||||
use utf8;
|
||||
use utf8;
|
||||
use Exporter;
|
||||
use Carp qw( croak );
|
||||
use Log::Any qw($log);
|
||||
@ -31,15 +32,16 @@ use WWW::OpenAPIClient::ApiClient;
|
||||
|
||||
use base "Class::Data::Inheritable";
|
||||
|
||||
__PACKAGE__->mk_classdata('method_documentation' => {});
|
||||
__PACKAGE__->mk_classdata( 'method_documentation' => {} );
|
||||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
my $api_client;
|
||||
|
||||
if ($_[0] && ref $_[0] && ref $_[0] eq 'WWW::OpenAPIClient::ApiClient' ) {
|
||||
if ( $_[0] && ref $_[0] && ref $_[0] eq 'WWW::OpenAPIClient::ApiClient' ) {
|
||||
$api_client = $_[0];
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$api_client = WWW::OpenAPIClient::ApiClient->new(@_);
|
||||
}
|
||||
|
||||
@ -47,55 +49,60 @@ sub new {
|
||||
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# test_special_tags
|
||||
# call_123_test_special_tags
|
||||
#
|
||||
# To test special tags
|
||||
#
|
||||
#
|
||||
# @param Client $client client model (required)
|
||||
{
|
||||
my $params = {
|
||||
'client' => {
|
||||
data_type => 'Client',
|
||||
description => 'client model',
|
||||
required => '1',
|
||||
},
|
||||
'client' => {
|
||||
data_type => 'Client',
|
||||
description => 'client model',
|
||||
required => '1',
|
||||
},
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ 'test_special_tags' } = {
|
||||
summary => 'To test special tags',
|
||||
params => $params,
|
||||
__PACKAGE__->method_documentation->{'call_123_test_special_tags'} = {
|
||||
summary => 'To test special tags',
|
||||
params => $params,
|
||||
returns => 'Client',
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
# @return Client
|
||||
#
|
||||
sub test_special_tags {
|
||||
my ($self, %args) = @_;
|
||||
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");
|
||||
unless ( exists $args{'client'} ) {
|
||||
croak(
|
||||
"Missing the required parameter 'client' when calling call_123_test_special_tags"
|
||||
);
|
||||
}
|
||||
|
||||
# parse inputs
|
||||
my $_resource_path = '/another-fake/dummy';
|
||||
|
||||
my $_method = 'PATCH';
|
||||
my $query_params = {};
|
||||
my $_method = 'PATCH';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
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'}) {
|
||||
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);
|
||||
if (!$response) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
=begin comment
|
||||
|
||||
OpenAPI Petstore
|
||||
@ -39,22 +40,25 @@ 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(@_);
|
||||
}
|
||||
|
||||
my (%args) = (
|
||||
'ua' => LWP::UserAgent->new,
|
||||
'ua' => LWP::UserAgent->new,
|
||||
'config' => $config,
|
||||
);
|
||||
|
||||
|
||||
return bless \%args, $class;
|
||||
}
|
||||
|
||||
@ -63,17 +67,17 @@ sub new {
|
||||
# @param string $user_agent The user agent of the API client
|
||||
#
|
||||
sub set_user_agent {
|
||||
my ($self, $user_agent) = @_;
|
||||
$self->{http_user_agent}= $user_agent;
|
||||
my ( $self, $user_agent ) = @_;
|
||||
$self->{http_user_agent} = $user_agent;
|
||||
}
|
||||
|
||||
# Set timeout
|
||||
#
|
||||
# @param integer $seconds Number of seconds before timing out [set to 0 for no timeout]
|
||||
#
|
||||
#
|
||||
sub set_timeout {
|
||||
my ($self, $seconds) = @_;
|
||||
if (!looks_like_number($seconds)) {
|
||||
my ( $self, $seconds ) = @_;
|
||||
if ( !looks_like_number($seconds) ) {
|
||||
croak('Timeout variable must be numeric.');
|
||||
}
|
||||
$self->{http_timeout} = $seconds;
|
||||
@ -88,72 +92,86 @@ 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
|
||||
|
||||
# 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') {
|
||||
if ( $method eq 'POST' ) {
|
||||
|
||||
# multipart
|
||||
$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);
|
||||
|
||||
$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') {
|
||||
elsif ( $method eq 'PUT' ) {
|
||||
|
||||
# multipart
|
||||
$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);
|
||||
|
||||
$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 );
|
||||
|
||||
}
|
||||
elsif ($method eq 'GET') {
|
||||
elsif ( $method eq 'GET' ) {
|
||||
my $headers = HTTP::Headers->new(%$header_params);
|
||||
$_request = GET($_url, %$header_params);
|
||||
$_request = GET( $_url, %$header_params );
|
||||
}
|
||||
elsif ($method eq 'HEAD') {
|
||||
elsif ( $method eq 'HEAD' ) {
|
||||
my $headers = HTTP::Headers->new(%$header_params);
|
||||
$_request = HEAD($_url,%$header_params);
|
||||
$_request = HEAD( $_url, %$header_params );
|
||||
}
|
||||
elsif ($method eq 'DELETE') { #TODO support form data
|
||||
elsif ( $method eq 'DELETE' ) { #TODO support form data
|
||||
my $headers = HTTP::Headers->new(%$header_params);
|
||||
$_request = DELETE($_url, %$headers);
|
||||
$_request = DELETE( $_url, %$headers );
|
||||
}
|
||||
elsif ($method eq 'PATCH') { #TODO
|
||||
elsif ( $method eq 'PATCH' ) { #TODO
|
||||
}
|
||||
else {
|
||||
}
|
||||
|
||||
$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);
|
||||
|
||||
$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);
|
||||
$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 );
|
||||
}
|
||||
|
||||
|
||||
return $_response->content;
|
||||
|
||||
|
||||
}
|
||||
|
||||
# Take value and turn it into a string suitable for inclusion in
|
||||
@ -161,11 +179,10 @@ sub call_api {
|
||||
# @param string $value a string which will be part of the path
|
||||
# @return string the serialized object
|
||||
sub to_path_value {
|
||||
my ($self, $value) = @_;
|
||||
return uri_escape($self->to_string($value));
|
||||
my ( $self, $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
|
||||
@ -173,22 +190,22 @@ sub to_path_value {
|
||||
# @param object $object an object to be serialized to a string
|
||||
# @return string the serialized object
|
||||
sub to_query_value {
|
||||
my ($self, $object) = @_;
|
||||
if (ref($object) eq 'ARRAY') {
|
||||
return join(',', @$object);
|
||||
} else {
|
||||
return $self->to_string($object);
|
||||
}
|
||||
my ( $self, $object ) = @_;
|
||||
if ( ref($object) eq 'ARRAY' ) {
|
||||
return join( ',', @$object );
|
||||
}
|
||||
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
|
||||
# @param string $value a string which will be part of the header
|
||||
# @return string the header string
|
||||
sub to_header_value {
|
||||
my ($self, $value) = @_;
|
||||
my ( $self, $value ) = @_;
|
||||
return $self->to_string($value);
|
||||
}
|
||||
|
||||
@ -198,7 +215,7 @@ sub to_header_value {
|
||||
# @param string $value the value of the form parameter
|
||||
# @return string the form string
|
||||
sub to_form_value {
|
||||
my ($self, $value) = @_;
|
||||
my ( $self, $value ) = @_;
|
||||
return $self->to_string($value);
|
||||
}
|
||||
|
||||
@ -208,8 +225,8 @@ sub to_form_value {
|
||||
# @param string $value the value of the parameter
|
||||
# @return string the header string
|
||||
sub to_string {
|
||||
my ($self, $value) = @_;
|
||||
if (ref($value) eq "DateTime") { # datetime in ISO8601 format
|
||||
my ( $self, $value ) = @_;
|
||||
if ( ref($value) eq "DateTime" ) { # datetime in ISO8601 format
|
||||
return $value->datetime();
|
||||
}
|
||||
else {
|
||||
@ -218,197 +235,216 @@ sub to_string {
|
||||
}
|
||||
|
||||
# Deserialize a JSON string into an object
|
||||
#
|
||||
#
|
||||
# @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
|
||||
{
|
||||
my ($self, $class, $data) = @_;
|
||||
$log->debugf("deserializing %s for %s", $data, $class);
|
||||
|
||||
if (not defined $data) {
|
||||
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
|
||||
if ($class =~ /^HASH\[(.*),(.*)\]$/) {
|
||||
my ($key_type, $type) = ($1, $2);
|
||||
}
|
||||
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});
|
||||
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} );
|
||||
}
|
||||
}
|
||||
return \%hash;
|
||||
} else {
|
||||
#TODO log error
|
||||
}
|
||||
|
||||
} 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);
|
||||
else {
|
||||
#TODO log error
|
||||
}
|
||||
|
||||
}
|
||||
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 );
|
||||
my $_json_data = decode_json $data;
|
||||
my @_values = ();
|
||||
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, $_value);
|
||||
if ( ref $_value eq 'ARRAY' ) {
|
||||
push @_values,
|
||||
$self->deserialize( $_sub_class, encode_json $_value);
|
||||
}
|
||||
else {
|
||||
push @_values, $self->deserialize( $_sub_class, $_value );
|
||||
}
|
||||
}
|
||||
return \@_values;
|
||||
} elsif ($class eq 'DateTime') {
|
||||
return DateTime->from_epoch(epoch => str2time($data));
|
||||
} elsif (grep /^$class$/, ('string', 'int', 'float', 'bool', 'object')) {
|
||||
}
|
||||
elsif ( $class eq 'DateTime' ) {
|
||||
return DateTime->from_epoch( epoch => str2time($data) );
|
||||
}
|
||||
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") {
|
||||
if ( ref $data eq "HASH" ) {
|
||||
return $_instance->from_hash($data);
|
||||
} else { # string, need to json decode first
|
||||
return $_instance->from_hash(decode_json $data);
|
||||
}
|
||||
else { # string, need to json decode first
|
||||
return $_instance->from_hash( decode_json $data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
# 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
|
||||
{
|
||||
my ($self, @header) = @_;
|
||||
|
||||
if (@header == 0 || (@header == 1 && $header[0] eq '')) {
|
||||
sub select_header_accept {
|
||||
my ( $self, @header ) = @_;
|
||||
|
||||
if ( @header == 0 || ( @header == 1 && $header[0] eq '' ) ) {
|
||||
return undef;
|
||||
} elsif (grep(/^application\/json$/i, @header)) {
|
||||
return 'application/json';
|
||||
} else {
|
||||
return join(',', @header);
|
||||
}
|
||||
|
||||
elsif ( grep( /^application\/json$/i, @header ) ) {
|
||||
return 'application/json';
|
||||
}
|
||||
else {
|
||||
return join( ',', @header );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
# 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
|
||||
{
|
||||
my ($self, @header) = @_;
|
||||
|
||||
if (@header == 0 || (@header == 1 && $header[0] eq '')) {
|
||||
return 'application/json'; # default to application/json
|
||||
} elsif (grep(/^application\/json$/i, @header)) {
|
||||
return 'application/json';
|
||||
} else {
|
||||
return join(',', @header);
|
||||
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 ) ) {
|
||||
return 'application/json';
|
||||
}
|
||||
else {
|
||||
return join( ',', @header );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
# Get API key (with prefix if set)
|
||||
# @param string key name
|
||||
# @return string API key with the prefix
|
||||
sub get_api_key_with_prefix
|
||||
{
|
||||
my ($self, $key_name) = @_;
|
||||
sub get_api_key_with_prefix {
|
||||
my ( $self, $key_name ) = @_;
|
||||
|
||||
my $api_key = $self->{config}{api_key}{$key_name};
|
||||
|
||||
return unless $api_key;
|
||||
|
||||
my $prefix = $self->{config}{api_key_prefix}{$key_name};
|
||||
return $prefix ? "$prefix $api_key" : $api_key;
|
||||
}
|
||||
my $api_key = $self->{config}{api_key}{$key_name};
|
||||
|
||||
return unless $api_key;
|
||||
|
||||
my $prefix = $self->{config}{api_key_prefix}{$key_name};
|
||||
return $prefix ? "$prefix $api_key" : $api_key;
|
||||
}
|
||||
|
||||
# update header and query param based on authentication setting
|
||||
#
|
||||
#
|
||||
# @param array $headerParams header parameters (by ref)
|
||||
# @param array $queryParams query parameters (by ref)
|
||||
# @param array $authSettings array of authentication scheme (e.g ['api_key'])
|
||||
sub update_params_for_auth {
|
||||
my ($self, $header_params, $query_params, $auth_settings) = @_;
|
||||
|
||||
return $self->_global_auth_setup($header_params, $query_params)
|
||||
unless $auth_settings && @$auth_settings;
|
||||
|
||||
my ( $self, $header_params, $query_params, $auth_settings ) = @_;
|
||||
|
||||
return $self->_global_auth_setup( $header_params, $query_params )
|
||||
unless $auth_settings && @$auth_settings;
|
||||
|
||||
# one endpoint can have more than 1 auth settings
|
||||
foreach my $auth (@$auth_settings) {
|
||||
|
||||
# determine which one to use
|
||||
if (!defined($auth)) {
|
||||
if ( !defined($auth) ) {
|
||||
|
||||
# TODO show warning about auth setting not defined
|
||||
}
|
||||
elsif ($auth eq 'api_key') {
|
||||
|
||||
elsif ( $auth eq 'api_key' ) {
|
||||
|
||||
my $api_key = $self->get_api_key_with_prefix('api_key');
|
||||
if ($api_key) {
|
||||
$header_params->{'api_key'} = $api_key;
|
||||
}
|
||||
}
|
||||
elsif ($auth eq 'api_key_query') {
|
||||
|
||||
elsif ( $auth eq 'api_key_query' ) {
|
||||
|
||||
my $api_key = $self->get_api_key_with_prefix('api_key_query');
|
||||
if ($api_key) {
|
||||
$query_params->{'api_key_query'} = $api_key;
|
||||
}
|
||||
}
|
||||
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});
|
||||
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} );
|
||||
}
|
||||
}
|
||||
elsif ($auth eq 'petstore_auth') {
|
||||
|
||||
if ($self->{config}{access_token}) {
|
||||
$header_params->{'Authorization'} = 'Bearer ' . $self->{config}{access_token};
|
||||
elsif ( $auth eq 'petstore_auth' ) {
|
||||
|
||||
if ( $self->{config}{access_token} ) {
|
||||
$header_params->{'Authorization'} =
|
||||
'Bearer ' . $self->{config}{access_token};
|
||||
}
|
||||
}
|
||||
else {
|
||||
# TODO show warning about security definition not found
|
||||
# TODO show warning about security definition not found
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# The endpoint API class has not found any settings for auth. This may be deliberate,
|
||||
# in which case update_params_for_auth() will be a no-op. But it may also be that the
|
||||
# OpenAPI Spec does not describe the intended authorization. So we check in the config for any
|
||||
# auth tokens and if we find any, we use them for all endpoints;
|
||||
# The endpoint API class has not found any settings for auth. This may be deliberate,
|
||||
# in which case update_params_for_auth() will be a no-op. But it may also be that the
|
||||
# OpenAPI Spec does not describe the intended authorization. So we check in the config for any
|
||||
# auth tokens and if we find any, we use them for all endpoints;
|
||||
sub _global_auth_setup {
|
||||
my ($self, $header_params, $query_params) = @_;
|
||||
|
||||
my $tokens = $self->{config}->get_tokens;
|
||||
return unless keys %$tokens;
|
||||
|
||||
# basic
|
||||
if (my $uname = delete $tokens->{username}) {
|
||||
my $pword = delete $tokens->{password};
|
||||
$header_params->{'Authorization'} = 'Basic '.encode_base64($uname.":".$pword);
|
||||
}
|
||||
|
||||
# oauth
|
||||
if (my $access_token = delete $tokens->{access_token}) {
|
||||
$header_params->{'Authorization'} = 'Bearer ' . $access_token;
|
||||
}
|
||||
|
||||
# other keys
|
||||
foreach my $token_name (keys %$tokens) {
|
||||
my $in = $tokens->{$token_name}->{in};
|
||||
my $token = $self->get_api_key_with_prefix($token_name);
|
||||
if ($in eq 'head') {
|
||||
$header_params->{$token_name} = $token;
|
||||
}
|
||||
elsif ($in eq 'query') {
|
||||
$query_params->{$token_name} = $token;
|
||||
}
|
||||
else {
|
||||
die "Don't know where to put token '$token_name' ('$in' is not 'head' or 'query')";
|
||||
}
|
||||
}
|
||||
my ( $self, $header_params, $query_params ) = @_;
|
||||
|
||||
my $tokens = $self->{config}->get_tokens;
|
||||
return unless keys %$tokens;
|
||||
|
||||
# basic
|
||||
if ( my $uname = delete $tokens->{username} ) {
|
||||
my $pword = delete $tokens->{password};
|
||||
$header_params->{'Authorization'} =
|
||||
'Basic ' . encode_base64( $uname . ":" . $pword );
|
||||
}
|
||||
|
||||
# oauth
|
||||
if ( my $access_token = delete $tokens->{access_token} ) {
|
||||
$header_params->{'Authorization'} = 'Bearer ' . $access_token;
|
||||
}
|
||||
|
||||
# other keys
|
||||
foreach my $token_name ( keys %$tokens ) {
|
||||
my $in = $tokens->{$token_name}->{in};
|
||||
my $token = $self->get_api_key_with_prefix($token_name);
|
||||
if ( $in eq 'head' ) {
|
||||
$header_params->{$token_name} = $token;
|
||||
}
|
||||
elsif ( $in eq 'query' ) {
|
||||
$query_params->{$token_name} = $token;
|
||||
}
|
||||
else {
|
||||
die
|
||||
"Don't know where to put token '$token_name' ('$in' is not 'head' or 'query')";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
=begin comment
|
||||
|
||||
OpenAPI Petstore
|
||||
@ -58,9 +59,8 @@ use WWW::OpenAPIClient::ApiClient;
|
||||
=cut
|
||||
|
||||
# Load all the API classes and construct a lookup table at startup time
|
||||
my %_apis = map { $_ =~ /^WWW::OpenAPIClient::(.*)$/; $1 => $_ }
|
||||
grep {$_ =~ /Api$/}
|
||||
usesub 'WWW::OpenAPIClient';
|
||||
my %_apis = map { $_ =~ /^WWW::OpenAPIClient::(.*)$/; $1 => $_ }
|
||||
grep { $_ =~ /Api$/ } usesub 'WWW::OpenAPIClient';
|
||||
|
||||
=head1 new($api_client)
|
||||
|
||||
@ -78,9 +78,10 @@ sub new {
|
||||
my ($class) = shift;
|
||||
|
||||
my $api_client;
|
||||
if ($_[0] && ref $_[0] && ref $_[0] eq 'WWW::OpenAPIClient::ApiClient' ) {
|
||||
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;
|
||||
@ -97,10 +98,10 @@ sub new {
|
||||
=cut
|
||||
|
||||
sub get_api {
|
||||
my ($self, $which) = @_;
|
||||
croak "API not specified" unless $which;
|
||||
my $api_class = $_apis{"${which}Api"} || croak "No known API for '$which'";
|
||||
return $api_class->new($self->api_client);
|
||||
my ( $self, $which ) = @_;
|
||||
croak "API not specified" unless $which;
|
||||
my $api_class = $_apis{"${which}Api"} || croak "No known API for '$which'";
|
||||
return $api_class->new( $self->api_client );
|
||||
}
|
||||
|
||||
=head1 api_client()
|
||||
@ -114,15 +115,16 @@ 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
|
||||
|
||||
sub classname_for {
|
||||
my ($self, $api_name) = @_;
|
||||
return $_apis{"${api_name}Api"};
|
||||
my ( $self, $api_name ) = @_;
|
||||
return $_apis{"${api_name}Api"};
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
=begin comment
|
||||
|
||||
OpenAPI Petstore
|
||||
@ -91,80 +92,81 @@ default: http://petstore.swagger.io:80/v2
|
||||
=cut
|
||||
|
||||
sub new {
|
||||
my ($self, %p) = (shift,@_);
|
||||
my ( $self, %p ) = ( shift, @_ );
|
||||
|
||||
# class/static variables
|
||||
$p{http_timeout} //= 180;
|
||||
$p{http_user_agent} //= 'OpenAPI-Generator/1.0.0/perl';
|
||||
# class/static variables
|
||||
$p{http_timeout} //= 180;
|
||||
$p{http_user_agent} //= 'OpenAPI-Generator/1.0.0/perl';
|
||||
|
||||
# authentication setting
|
||||
$p{api_key} //= {};
|
||||
$p{api_key_prefix} //= {};
|
||||
$p{api_key_in} //= {};
|
||||
# authentication setting
|
||||
$p{api_key} //= {};
|
||||
$p{api_key_prefix} //= {};
|
||||
$p{api_key_in} //= {};
|
||||
|
||||
# username and password for HTTP basic authentication
|
||||
$p{username} //= '';
|
||||
$p{password} //= '';
|
||||
# username and password for HTTP basic authentication
|
||||
$p{username} //= '';
|
||||
$p{password} //= '';
|
||||
|
||||
# access token for OAuth
|
||||
$p{access_token} //= '';
|
||||
# access token for OAuth
|
||||
$p{access_token} //= '';
|
||||
|
||||
# base_url
|
||||
$p{base_url} //= 'http://petstore.swagger.io:80/v2';
|
||||
# base_url
|
||||
$p{base_url} //= 'http://petstore.swagger.io:80/v2';
|
||||
|
||||
return bless \%p => $self;
|
||||
return bless \%p => $self;
|
||||
}
|
||||
|
||||
|
||||
sub get_tokens {
|
||||
my $self = shift;
|
||||
|
||||
my $tokens = {};
|
||||
$tokens->{username} = $self->{username} if $self->{username};
|
||||
$tokens->{password} = $self->{password} if $self->{password};
|
||||
$tokens->{access_token} = $self->{access_token} if $self->{access_token};
|
||||
|
||||
foreach my $token_name (keys %{ $self->{api_key} }) {
|
||||
$tokens->{$token_name}->{token} = $self->{api_key}{$token_name};
|
||||
$tokens->{$token_name}->{prefix} = $self->{api_key_prefix}{$token_name};
|
||||
$tokens->{$token_name}->{in} = $self->{api_key_in}{$token_name};
|
||||
}
|
||||
my $self = shift;
|
||||
|
||||
return $tokens;
|
||||
my $tokens = {};
|
||||
$tokens->{username} = $self->{username} if $self->{username};
|
||||
$tokens->{password} = $self->{password} if $self->{password};
|
||||
$tokens->{access_token} = $self->{access_token} if $self->{access_token};
|
||||
|
||||
foreach my $token_name ( keys %{ $self->{api_key} } ) {
|
||||
$tokens->{$token_name}->{token} = $self->{api_key}{$token_name};
|
||||
$tokens->{$token_name}->{prefix} = $self->{api_key_prefix}{$token_name};
|
||||
$tokens->{$token_name}->{in} = $self->{api_key_in}{$token_name};
|
||||
}
|
||||
|
||||
return $tokens;
|
||||
}
|
||||
|
||||
sub clear_tokens {
|
||||
my $self = shift;
|
||||
my %tokens = %{$self->get_tokens}; # copy
|
||||
|
||||
$self->{username} = '';
|
||||
$self->{password} = '';
|
||||
$self->{access_token} = '';
|
||||
my $self = shift;
|
||||
my %tokens = %{ $self->get_tokens }; # copy
|
||||
|
||||
$self->{api_key} = {};
|
||||
$self->{api_key_prefix} = {};
|
||||
$self->{api_key_in} = {};
|
||||
|
||||
return \%tokens;
|
||||
$self->{username} = '';
|
||||
$self->{password} = '';
|
||||
$self->{access_token} = '';
|
||||
|
||||
$self->{api_key} = {};
|
||||
$self->{api_key_prefix} = {};
|
||||
$self->{api_key_in} = {};
|
||||
|
||||
return \%tokens;
|
||||
}
|
||||
|
||||
sub accept_tokens {
|
||||
my ($self, $tokens) = @_;
|
||||
|
||||
foreach my $known_name (qw(username password access_token)) {
|
||||
next unless $tokens->{$known_name};
|
||||
$self->{$known_name} = delete $tokens->{$known_name};
|
||||
}
|
||||
|
||||
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};
|
||||
}
|
||||
my $in = $tokens->{$token_name}->{in} || 'head';
|
||||
croak "Tokens can only go in 'head' or 'query' (not in '$in')" unless $in =~ /^(?:head|query)$/;
|
||||
$self->{api_key_in}{$token_name} = $in;
|
||||
}
|
||||
}
|
||||
my ( $self, $tokens ) = @_;
|
||||
|
||||
foreach my $known_name (qw(username password access_token)) {
|
||||
next unless $tokens->{$known_name};
|
||||
$self->{$known_name} = delete $tokens->{$known_name};
|
||||
}
|
||||
|
||||
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};
|
||||
}
|
||||
my $in = $tokens->{$token_name}->{in} || 'head';
|
||||
croak "Tokens can only go in 'head' or 'query' (not in '$in')"
|
||||
unless $in =~ /^(?:head|query)$/;
|
||||
$self->{api_key_in}{$token_name} = $in;
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,3 +1,4 @@
|
||||
|
||||
=begin comment
|
||||
|
||||
OpenAPI Petstore
|
||||
@ -22,7 +23,7 @@ package WWW::OpenAPIClient::FakeClassnameTags123Api;
|
||||
require 5.6.0;
|
||||
use strict;
|
||||
use warnings;
|
||||
use utf8;
|
||||
use utf8;
|
||||
use Exporter;
|
||||
use Carp qw( croak );
|
||||
use Log::Any qw($log);
|
||||
@ -31,15 +32,16 @@ use WWW::OpenAPIClient::ApiClient;
|
||||
|
||||
use base "Class::Data::Inheritable";
|
||||
|
||||
__PACKAGE__->mk_classdata('method_documentation' => {});
|
||||
__PACKAGE__->mk_classdata( 'method_documentation' => {} );
|
||||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
my $api_client;
|
||||
|
||||
if ($_[0] && ref $_[0] && ref $_[0] eq 'WWW::OpenAPIClient::ApiClient' ) {
|
||||
if ( $_[0] && ref $_[0] && ref $_[0] eq 'WWW::OpenAPIClient::ApiClient' ) {
|
||||
$api_client = $_[0];
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$api_client = WWW::OpenAPIClient::ApiClient->new(@_);
|
||||
}
|
||||
|
||||
@ -47,55 +49,60 @@ sub new {
|
||||
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# test_classname
|
||||
#
|
||||
# To test class name in snake case
|
||||
#
|
||||
#
|
||||
# @param Client $client client model (required)
|
||||
{
|
||||
my $params = {
|
||||
'client' => {
|
||||
data_type => 'Client',
|
||||
description => 'client model',
|
||||
required => '1',
|
||||
},
|
||||
'client' => {
|
||||
data_type => 'Client',
|
||||
description => 'client model',
|
||||
required => '1',
|
||||
},
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ 'test_classname' } = {
|
||||
summary => 'To test class name in snake case',
|
||||
params => $params,
|
||||
__PACKAGE__->method_documentation->{'test_classname'} = {
|
||||
summary => 'To test class name in snake case',
|
||||
params => $params,
|
||||
returns => 'Client',
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
# @return Client
|
||||
#
|
||||
sub test_classname {
|
||||
my ($self, %args) = @_;
|
||||
my ( $self, %args ) = @_;
|
||||
|
||||
# verify the required parameter 'client' is set
|
||||
unless (exists $args{'client'}) {
|
||||
croak("Missing the required parameter 'client' when calling test_classname");
|
||||
unless ( exists $args{'client'} ) {
|
||||
croak(
|
||||
"Missing the required parameter 'client' when calling test_classname"
|
||||
);
|
||||
}
|
||||
|
||||
# parse inputs
|
||||
my $_resource_path = '/fake_classname_test';
|
||||
|
||||
my $_method = 'PATCH';
|
||||
my $query_params = {};
|
||||
my $_method = 'PATCH';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
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'}) {
|
||||
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);
|
||||
if (!$response) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
=begin comment
|
||||
|
||||
OpenAPI Petstore
|
||||
@ -30,9 +31,7 @@ use Log::Any qw($log);
|
||||
use Date::Parse;
|
||||
use DateTime;
|
||||
|
||||
|
||||
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||
|
||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
||||
|
||||
#
|
||||
#
|
||||
@ -60,37 +59,37 @@ Generated by: 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' => {});
|
||||
__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) = @_;
|
||||
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;
|
||||
}
|
||||
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 ));
|
||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
||||
}
|
||||
|
||||
# used by JSON for serialization
|
||||
sub TO_JSON {
|
||||
my $self = shift;
|
||||
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};
|
||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
||||
if ( defined $self->{$_key} ) {
|
||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
||||
}
|
||||
}
|
||||
return $_data;
|
||||
@ -98,78 +97,91 @@ sub TO_JSON {
|
||||
|
||||
# from Perl hashref
|
||||
sub from_hash {
|
||||
my ($self, $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);
|
||||
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);
|
||||
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);
|
||||
}
|
||||
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'))) {
|
||||
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)
|
||||
}
|
||||
else { # hash(model)
|
||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||
return $_instance->from_hash($data);
|
||||
}
|
||||
}
|
||||
|
||||
__PACKAGE__->class_documentation(
|
||||
{
|
||||
description => '',
|
||||
class => 'AdditionalPropertiesClass',
|
||||
required => [], # TODO
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation(
|
||||
{
|
||||
'map_property' => {
|
||||
datatype => 'HASH[string,string]',
|
||||
base_name => 'map_property',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'map_of_map_property' => {
|
||||
datatype => 'HASH[string,HASH[string,string]]',
|
||||
base_name => 'map_of_map_property',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->class_documentation({description => '',
|
||||
class => 'AdditionalPropertiesClass',
|
||||
required => [], # TODO
|
||||
} );
|
||||
__PACKAGE__->openapi_types(
|
||||
{
|
||||
'map_property' => 'HASH[string,string]',
|
||||
'map_of_map_property' => 'HASH[string,HASH[string,string]]'
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation({
|
||||
'map_property' => {
|
||||
datatype => 'HASH[string,string]',
|
||||
base_name => 'map_property',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'map_of_map_property' => {
|
||||
datatype => 'HASH[string,HASH[string,string]]',
|
||||
base_name => 'map_of_map_property',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
});
|
||||
|
||||
__PACKAGE__->openapi_types( {
|
||||
'map_property' => 'HASH[string,string]',
|
||||
'map_of_map_property' => 'HASH[string,HASH[string,string]]'
|
||||
} );
|
||||
|
||||
__PACKAGE__->attribute_map( {
|
||||
'map_property' => 'map_property',
|
||||
'map_of_map_property' => 'map_of_map_property'
|
||||
} );
|
||||
|
||||
__PACKAGE__->mk_accessors(keys %{__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;
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
=begin comment
|
||||
|
||||
OpenAPI Petstore
|
||||
@ -30,9 +31,7 @@ use Log::Any qw($log);
|
||||
use Date::Parse;
|
||||
use DateTime;
|
||||
|
||||
|
||||
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||
|
||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
||||
|
||||
#
|
||||
#
|
||||
@ -60,37 +59,37 @@ Generated by: 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' => {});
|
||||
__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) = @_;
|
||||
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;
|
||||
}
|
||||
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 ));
|
||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
||||
}
|
||||
|
||||
# used by JSON for serialization
|
||||
sub TO_JSON {
|
||||
my $self = shift;
|
||||
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};
|
||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
||||
if ( defined $self->{$_key} ) {
|
||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
||||
}
|
||||
}
|
||||
return $_data;
|
||||
@ -98,78 +97,91 @@ sub TO_JSON {
|
||||
|
||||
# from Perl hashref
|
||||
sub from_hash {
|
||||
my ($self, $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);
|
||||
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);
|
||||
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);
|
||||
}
|
||||
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'))) {
|
||||
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)
|
||||
}
|
||||
else { # hash(model)
|
||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||
return $_instance->from_hash($data);
|
||||
}
|
||||
}
|
||||
|
||||
__PACKAGE__->class_documentation(
|
||||
{
|
||||
description => '',
|
||||
class => 'Animal',
|
||||
required => [], # TODO
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation(
|
||||
{
|
||||
'class_name' => {
|
||||
datatype => 'string',
|
||||
base_name => 'className',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'color' => {
|
||||
datatype => 'string',
|
||||
base_name => 'color',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->class_documentation({description => '',
|
||||
class => 'Animal',
|
||||
required => [], # TODO
|
||||
} );
|
||||
__PACKAGE__->openapi_types(
|
||||
{
|
||||
'class_name' => 'string',
|
||||
'color' => 'string'
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation({
|
||||
'class_name' => {
|
||||
datatype => 'string',
|
||||
base_name => 'className',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'color' => {
|
||||
datatype => 'string',
|
||||
base_name => 'color',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
});
|
||||
|
||||
__PACKAGE__->openapi_types( {
|
||||
'class_name' => 'string',
|
||||
'color' => 'string'
|
||||
} );
|
||||
|
||||
__PACKAGE__->attribute_map( {
|
||||
'class_name' => 'className',
|
||||
'color' => 'color'
|
||||
} );
|
||||
|
||||
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
||||
__PACKAGE__->attribute_map(
|
||||
{
|
||||
'class_name' => 'className',
|
||||
'color' => 'color'
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
||||
|
||||
1;
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
=begin comment
|
||||
|
||||
OpenAPI Petstore
|
||||
@ -32,8 +33,7 @@ use DateTime;
|
||||
|
||||
use WWW::OpenAPIClient::Object::Animal;
|
||||
|
||||
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||
|
||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
||||
|
||||
#
|
||||
#
|
||||
@ -61,37 +61,37 @@ Generated by: 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' => {});
|
||||
__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) = @_;
|
||||
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;
|
||||
}
|
||||
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 ));
|
||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
||||
}
|
||||
|
||||
# used by JSON for serialization
|
||||
sub TO_JSON {
|
||||
my $self = shift;
|
||||
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};
|
||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
||||
if ( defined $self->{$_key} ) {
|
||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
||||
}
|
||||
}
|
||||
return $_data;
|
||||
@ -99,62 +99,72 @@ sub TO_JSON {
|
||||
|
||||
# from Perl hashref
|
||||
sub from_hash {
|
||||
my ($self, $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);
|
||||
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);
|
||||
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);
|
||||
}
|
||||
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'))) {
|
||||
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)
|
||||
}
|
||||
else { # hash(model)
|
||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||
return $_instance->from_hash($data);
|
||||
}
|
||||
}
|
||||
|
||||
__PACKAGE__->class_documentation(
|
||||
{
|
||||
description => '',
|
||||
class => 'AnimalFarm',
|
||||
required => [], # TODO
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation( {} );
|
||||
|
||||
__PACKAGE__->class_documentation({description => '',
|
||||
class => 'AnimalFarm',
|
||||
required => [], # TODO
|
||||
} );
|
||||
__PACKAGE__->openapi_types(
|
||||
{
|
||||
|
||||
__PACKAGE__->method_documentation({
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->openapi_types( {
|
||||
|
||||
} );
|
||||
__PACKAGE__->attribute_map(
|
||||
{
|
||||
|
||||
__PACKAGE__->attribute_map( {
|
||||
|
||||
} );
|
||||
|
||||
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
||||
|
||||
1;
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
=begin comment
|
||||
|
||||
OpenAPI Petstore
|
||||
@ -30,9 +31,7 @@ use Log::Any qw($log);
|
||||
use Date::Parse;
|
||||
use DateTime;
|
||||
|
||||
|
||||
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||
|
||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
||||
|
||||
#
|
||||
#
|
||||
@ -60,37 +59,37 @@ Generated by: 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' => {});
|
||||
__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) = @_;
|
||||
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;
|
||||
}
|
||||
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 ));
|
||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
||||
}
|
||||
|
||||
# used by JSON for serialization
|
||||
sub TO_JSON {
|
||||
my $self = shift;
|
||||
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};
|
||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
||||
if ( defined $self->{$_key} ) {
|
||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
||||
}
|
||||
}
|
||||
return $_data;
|
||||
@ -98,87 +97,100 @@ sub TO_JSON {
|
||||
|
||||
# from Perl hashref
|
||||
sub from_hash {
|
||||
my ($self, $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);
|
||||
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);
|
||||
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);
|
||||
}
|
||||
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'))) {
|
||||
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)
|
||||
}
|
||||
else { # hash(model)
|
||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||
return $_instance->from_hash($data);
|
||||
}
|
||||
}
|
||||
|
||||
__PACKAGE__->class_documentation(
|
||||
{
|
||||
description => '',
|
||||
class => 'ApiResponse',
|
||||
required => [], # TODO
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation(
|
||||
{
|
||||
'code' => {
|
||||
datatype => 'int',
|
||||
base_name => 'code',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'type' => {
|
||||
datatype => 'string',
|
||||
base_name => 'type',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'message' => {
|
||||
datatype => 'string',
|
||||
base_name => 'message',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->class_documentation({description => '',
|
||||
class => 'ApiResponse',
|
||||
required => [], # TODO
|
||||
} );
|
||||
__PACKAGE__->openapi_types(
|
||||
{
|
||||
'code' => 'int',
|
||||
'type' => 'string',
|
||||
'message' => 'string'
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation({
|
||||
'code' => {
|
||||
datatype => 'int',
|
||||
base_name => 'code',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'type' => {
|
||||
datatype => 'string',
|
||||
base_name => 'type',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'message' => {
|
||||
datatype => 'string',
|
||||
base_name => 'message',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
});
|
||||
|
||||
__PACKAGE__->openapi_types( {
|
||||
'code' => 'int',
|
||||
'type' => 'string',
|
||||
'message' => 'string'
|
||||
} );
|
||||
|
||||
__PACKAGE__->attribute_map( {
|
||||
'code' => 'code',
|
||||
'type' => 'type',
|
||||
'message' => 'message'
|
||||
} );
|
||||
|
||||
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
||||
__PACKAGE__->attribute_map(
|
||||
{
|
||||
'code' => 'code',
|
||||
'type' => 'type',
|
||||
'message' => 'message'
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
||||
|
||||
1;
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
=begin comment
|
||||
|
||||
OpenAPI Petstore
|
||||
@ -30,9 +31,7 @@ use Log::Any qw($log);
|
||||
use Date::Parse;
|
||||
use DateTime;
|
||||
|
||||
|
||||
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||
|
||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
||||
|
||||
#
|
||||
#
|
||||
@ -60,37 +59,37 @@ Generated by: 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' => {});
|
||||
__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) = @_;
|
||||
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;
|
||||
}
|
||||
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 ));
|
||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
||||
}
|
||||
|
||||
# used by JSON for serialization
|
||||
sub TO_JSON {
|
||||
my $self = shift;
|
||||
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};
|
||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
||||
if ( defined $self->{$_key} ) {
|
||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
||||
}
|
||||
}
|
||||
return $_data;
|
||||
@ -98,69 +97,82 @@ sub TO_JSON {
|
||||
|
||||
# from Perl hashref
|
||||
sub from_hash {
|
||||
my ($self, $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);
|
||||
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);
|
||||
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);
|
||||
}
|
||||
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'))) {
|
||||
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)
|
||||
}
|
||||
else { # hash(model)
|
||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||
return $_instance->from_hash($data);
|
||||
}
|
||||
}
|
||||
|
||||
__PACKAGE__->class_documentation(
|
||||
{
|
||||
description => '',
|
||||
class => 'ArrayOfArrayOfNumberOnly',
|
||||
required => [], # TODO
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation(
|
||||
{
|
||||
'array_array_number' => {
|
||||
datatype => 'ARRAY[ARRAY[double]]',
|
||||
base_name => 'ArrayArrayNumber',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->class_documentation({description => '',
|
||||
class => 'ArrayOfArrayOfNumberOnly',
|
||||
required => [], # TODO
|
||||
} );
|
||||
__PACKAGE__->openapi_types(
|
||||
{
|
||||
'array_array_number' => 'ARRAY[ARRAY[double]]'
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation({
|
||||
'array_array_number' => {
|
||||
datatype => 'ARRAY[ARRAY[double]]',
|
||||
base_name => 'ArrayArrayNumber',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
});
|
||||
|
||||
__PACKAGE__->openapi_types( {
|
||||
'array_array_number' => 'ARRAY[ARRAY[double]]'
|
||||
} );
|
||||
|
||||
__PACKAGE__->attribute_map( {
|
||||
'array_array_number' => 'ArrayArrayNumber'
|
||||
} );
|
||||
|
||||
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
||||
__PACKAGE__->attribute_map(
|
||||
{
|
||||
'array_array_number' => 'ArrayArrayNumber'
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
||||
|
||||
1;
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
=begin comment
|
||||
|
||||
OpenAPI Petstore
|
||||
@ -30,9 +31,7 @@ use Log::Any qw($log);
|
||||
use Date::Parse;
|
||||
use DateTime;
|
||||
|
||||
|
||||
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||
|
||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
||||
|
||||
#
|
||||
#
|
||||
@ -60,37 +59,37 @@ Generated by: 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' => {});
|
||||
__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) = @_;
|
||||
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;
|
||||
}
|
||||
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 ));
|
||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
||||
}
|
||||
|
||||
# used by JSON for serialization
|
||||
sub TO_JSON {
|
||||
my $self = shift;
|
||||
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};
|
||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
||||
if ( defined $self->{$_key} ) {
|
||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
||||
}
|
||||
}
|
||||
return $_data;
|
||||
@ -98,69 +97,82 @@ sub TO_JSON {
|
||||
|
||||
# from Perl hashref
|
||||
sub from_hash {
|
||||
my ($self, $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);
|
||||
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);
|
||||
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);
|
||||
}
|
||||
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'))) {
|
||||
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)
|
||||
}
|
||||
else { # hash(model)
|
||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||
return $_instance->from_hash($data);
|
||||
}
|
||||
}
|
||||
|
||||
__PACKAGE__->class_documentation(
|
||||
{
|
||||
description => '',
|
||||
class => 'ArrayOfNumberOnly',
|
||||
required => [], # TODO
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation(
|
||||
{
|
||||
'array_number' => {
|
||||
datatype => 'ARRAY[double]',
|
||||
base_name => 'ArrayNumber',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->class_documentation({description => '',
|
||||
class => 'ArrayOfNumberOnly',
|
||||
required => [], # TODO
|
||||
} );
|
||||
__PACKAGE__->openapi_types(
|
||||
{
|
||||
'array_number' => 'ARRAY[double]'
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation({
|
||||
'array_number' => {
|
||||
datatype => 'ARRAY[double]',
|
||||
base_name => 'ArrayNumber',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
});
|
||||
|
||||
__PACKAGE__->openapi_types( {
|
||||
'array_number' => 'ARRAY[double]'
|
||||
} );
|
||||
|
||||
__PACKAGE__->attribute_map( {
|
||||
'array_number' => 'ArrayNumber'
|
||||
} );
|
||||
|
||||
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
||||
__PACKAGE__->attribute_map(
|
||||
{
|
||||
'array_number' => 'ArrayNumber'
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
||||
|
||||
1;
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
=begin comment
|
||||
|
||||
OpenAPI Petstore
|
||||
@ -32,8 +33,7 @@ use DateTime;
|
||||
|
||||
use WWW::OpenAPIClient::Object::ReadOnlyFirst;
|
||||
|
||||
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||
|
||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
||||
|
||||
#
|
||||
#
|
||||
@ -61,37 +61,37 @@ Generated by: 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' => {});
|
||||
__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) = @_;
|
||||
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;
|
||||
}
|
||||
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 ));
|
||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
||||
}
|
||||
|
||||
# used by JSON for serialization
|
||||
sub TO_JSON {
|
||||
my $self = shift;
|
||||
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};
|
||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
||||
if ( defined $self->{$_key} ) {
|
||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
||||
}
|
||||
}
|
||||
return $_data;
|
||||
@ -99,87 +99,100 @@ sub TO_JSON {
|
||||
|
||||
# from Perl hashref
|
||||
sub from_hash {
|
||||
my ($self, $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);
|
||||
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);
|
||||
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);
|
||||
}
|
||||
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'))) {
|
||||
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)
|
||||
}
|
||||
else { # hash(model)
|
||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||
return $_instance->from_hash($data);
|
||||
}
|
||||
}
|
||||
|
||||
__PACKAGE__->class_documentation(
|
||||
{
|
||||
description => '',
|
||||
class => 'ArrayTest',
|
||||
required => [], # TODO
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation(
|
||||
{
|
||||
'array_of_string' => {
|
||||
datatype => 'ARRAY[string]',
|
||||
base_name => 'array_of_string',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'array_array_of_integer' => {
|
||||
datatype => 'ARRAY[ARRAY[int]]',
|
||||
base_name => 'array_array_of_integer',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'array_array_of_model' => {
|
||||
datatype => 'ARRAY[ARRAY[ReadOnlyFirst]]',
|
||||
base_name => 'array_array_of_model',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->class_documentation({description => '',
|
||||
class => 'ArrayTest',
|
||||
required => [], # TODO
|
||||
} );
|
||||
__PACKAGE__->openapi_types(
|
||||
{
|
||||
'array_of_string' => 'ARRAY[string]',
|
||||
'array_array_of_integer' => 'ARRAY[ARRAY[int]]',
|
||||
'array_array_of_model' => 'ARRAY[ARRAY[ReadOnlyFirst]]'
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation({
|
||||
'array_of_string' => {
|
||||
datatype => 'ARRAY[string]',
|
||||
base_name => 'array_of_string',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'array_array_of_integer' => {
|
||||
datatype => 'ARRAY[ARRAY[int]]',
|
||||
base_name => 'array_array_of_integer',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'array_array_of_model' => {
|
||||
datatype => 'ARRAY[ARRAY[ReadOnlyFirst]]',
|
||||
base_name => 'array_array_of_model',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
});
|
||||
|
||||
__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( {
|
||||
'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});
|
||||
__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;
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
=begin comment
|
||||
|
||||
OpenAPI Petstore
|
||||
@ -30,9 +31,7 @@ use Log::Any qw($log);
|
||||
use Date::Parse;
|
||||
use DateTime;
|
||||
|
||||
|
||||
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||
|
||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
||||
|
||||
#
|
||||
#
|
||||
@ -60,37 +59,37 @@ Generated by: 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' => {});
|
||||
__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) = @_;
|
||||
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;
|
||||
}
|
||||
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 ));
|
||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
||||
}
|
||||
|
||||
# used by JSON for serialization
|
||||
sub TO_JSON {
|
||||
my $self = shift;
|
||||
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};
|
||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
||||
if ( defined $self->{$_key} ) {
|
||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
||||
}
|
||||
}
|
||||
return $_data;
|
||||
@ -98,114 +97,127 @@ sub TO_JSON {
|
||||
|
||||
# from Perl hashref
|
||||
sub from_hash {
|
||||
my ($self, $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);
|
||||
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);
|
||||
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);
|
||||
}
|
||||
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'))) {
|
||||
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)
|
||||
}
|
||||
else { # hash(model)
|
||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||
return $_instance->from_hash($data);
|
||||
}
|
||||
}
|
||||
|
||||
__PACKAGE__->class_documentation(
|
||||
{
|
||||
description => '',
|
||||
class => 'Capitalization',
|
||||
required => [], # TODO
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation(
|
||||
{
|
||||
'small_camel' => {
|
||||
datatype => 'string',
|
||||
base_name => 'smallCamel',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'capital_camel' => {
|
||||
datatype => 'string',
|
||||
base_name => 'CapitalCamel',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'small_snake' => {
|
||||
datatype => 'string',
|
||||
base_name => 'small_Snake',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'capital_snake' => {
|
||||
datatype => 'string',
|
||||
base_name => 'Capital_Snake',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'sca_eth_flow_points' => {
|
||||
datatype => 'string',
|
||||
base_name => 'SCA_ETH_Flow_Points',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'att_name' => {
|
||||
datatype => 'string',
|
||||
base_name => 'ATT_NAME',
|
||||
description => 'Name of the pet ',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->class_documentation({description => '',
|
||||
class => 'Capitalization',
|
||||
required => [], # TODO
|
||||
} );
|
||||
__PACKAGE__->openapi_types(
|
||||
{
|
||||
'small_camel' => 'string',
|
||||
'capital_camel' => 'string',
|
||||
'small_snake' => 'string',
|
||||
'capital_snake' => 'string',
|
||||
'sca_eth_flow_points' => 'string',
|
||||
'att_name' => 'string'
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation({
|
||||
'small_camel' => {
|
||||
datatype => 'string',
|
||||
base_name => 'smallCamel',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'capital_camel' => {
|
||||
datatype => 'string',
|
||||
base_name => 'CapitalCamel',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'small_snake' => {
|
||||
datatype => 'string',
|
||||
base_name => 'small_Snake',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'capital_snake' => {
|
||||
datatype => 'string',
|
||||
base_name => 'Capital_Snake',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'sca_eth_flow_points' => {
|
||||
datatype => 'string',
|
||||
base_name => 'SCA_ETH_Flow_Points',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'att_name' => {
|
||||
datatype => 'string',
|
||||
base_name => 'ATT_NAME',
|
||||
description => 'Name of the pet ',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
});
|
||||
|
||||
__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( {
|
||||
'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});
|
||||
__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;
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
=begin comment
|
||||
|
||||
OpenAPI Petstore
|
||||
@ -32,8 +33,7 @@ use DateTime;
|
||||
|
||||
use WWW::OpenAPIClient::Object::Animal;
|
||||
|
||||
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||
|
||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
||||
|
||||
#
|
||||
#
|
||||
@ -61,37 +61,37 @@ Generated by: 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' => {});
|
||||
__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) = @_;
|
||||
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;
|
||||
}
|
||||
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 ));
|
||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
||||
}
|
||||
|
||||
# used by JSON for serialization
|
||||
sub TO_JSON {
|
||||
my $self = shift;
|
||||
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};
|
||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
||||
if ( defined $self->{$_key} ) {
|
||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
||||
}
|
||||
}
|
||||
return $_data;
|
||||
@ -99,87 +99,100 @@ sub TO_JSON {
|
||||
|
||||
# from Perl hashref
|
||||
sub from_hash {
|
||||
my ($self, $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);
|
||||
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);
|
||||
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);
|
||||
}
|
||||
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'))) {
|
||||
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)
|
||||
}
|
||||
else { # hash(model)
|
||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||
return $_instance->from_hash($data);
|
||||
}
|
||||
}
|
||||
|
||||
__PACKAGE__->class_documentation(
|
||||
{
|
||||
description => '',
|
||||
class => 'Cat',
|
||||
required => [], # TODO
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation(
|
||||
{
|
||||
'class_name' => {
|
||||
datatype => 'string',
|
||||
base_name => 'className',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'color' => {
|
||||
datatype => 'string',
|
||||
base_name => 'color',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'declawed' => {
|
||||
datatype => 'boolean',
|
||||
base_name => 'declawed',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->class_documentation({description => '',
|
||||
class => 'Cat',
|
||||
required => [], # TODO
|
||||
} );
|
||||
__PACKAGE__->openapi_types(
|
||||
{
|
||||
'class_name' => 'string',
|
||||
'color' => 'string',
|
||||
'declawed' => 'boolean'
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation({
|
||||
'class_name' => {
|
||||
datatype => 'string',
|
||||
base_name => 'className',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'color' => {
|
||||
datatype => 'string',
|
||||
base_name => 'color',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'declawed' => {
|
||||
datatype => 'boolean',
|
||||
base_name => 'declawed',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
});
|
||||
|
||||
__PACKAGE__->openapi_types( {
|
||||
'class_name' => 'string',
|
||||
'color' => 'string',
|
||||
'declawed' => 'boolean'
|
||||
} );
|
||||
|
||||
__PACKAGE__->attribute_map( {
|
||||
'class_name' => 'className',
|
||||
'color' => 'color',
|
||||
'declawed' => 'declawed'
|
||||
} );
|
||||
|
||||
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
||||
__PACKAGE__->attribute_map(
|
||||
{
|
||||
'class_name' => 'className',
|
||||
'color' => 'color',
|
||||
'declawed' => 'declawed'
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
||||
|
||||
1;
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
=begin comment
|
||||
|
||||
OpenAPI Petstore
|
||||
@ -30,9 +31,7 @@ use Log::Any qw($log);
|
||||
use Date::Parse;
|
||||
use DateTime;
|
||||
|
||||
|
||||
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||
|
||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
||||
|
||||
#
|
||||
#
|
||||
@ -60,37 +59,37 @@ Generated by: 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' => {});
|
||||
__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) = @_;
|
||||
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;
|
||||
}
|
||||
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 ));
|
||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
||||
}
|
||||
|
||||
# used by JSON for serialization
|
||||
sub TO_JSON {
|
||||
my $self = shift;
|
||||
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};
|
||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
||||
if ( defined $self->{$_key} ) {
|
||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
||||
}
|
||||
}
|
||||
return $_data;
|
||||
@ -98,78 +97,91 @@ sub TO_JSON {
|
||||
|
||||
# from Perl hashref
|
||||
sub from_hash {
|
||||
my ($self, $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);
|
||||
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);
|
||||
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);
|
||||
}
|
||||
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'))) {
|
||||
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)
|
||||
}
|
||||
else { # hash(model)
|
||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||
return $_instance->from_hash($data);
|
||||
}
|
||||
}
|
||||
|
||||
__PACKAGE__->class_documentation(
|
||||
{
|
||||
description => '',
|
||||
class => 'Category',
|
||||
required => [], # TODO
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation(
|
||||
{
|
||||
'id' => {
|
||||
datatype => 'int',
|
||||
base_name => 'id',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'name' => {
|
||||
datatype => 'string',
|
||||
base_name => 'name',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->class_documentation({description => '',
|
||||
class => 'Category',
|
||||
required => [], # TODO
|
||||
} );
|
||||
__PACKAGE__->openapi_types(
|
||||
{
|
||||
'id' => 'int',
|
||||
'name' => 'string'
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation({
|
||||
'id' => {
|
||||
datatype => 'int',
|
||||
base_name => 'id',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'name' => {
|
||||
datatype => 'string',
|
||||
base_name => 'name',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
});
|
||||
|
||||
__PACKAGE__->openapi_types( {
|
||||
'id' => 'int',
|
||||
'name' => 'string'
|
||||
} );
|
||||
|
||||
__PACKAGE__->attribute_map( {
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
} );
|
||||
|
||||
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
||||
__PACKAGE__->attribute_map(
|
||||
{
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
||||
|
||||
1;
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
=begin comment
|
||||
|
||||
OpenAPI Petstore
|
||||
@ -30,9 +31,7 @@ use Log::Any qw($log);
|
||||
use Date::Parse;
|
||||
use DateTime;
|
||||
|
||||
|
||||
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||
|
||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
||||
|
||||
#
|
||||
#Model for testing model with \"_class\" property
|
||||
@ -60,37 +59,37 @@ Generated by: 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' => {});
|
||||
__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) = @_;
|
||||
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;
|
||||
}
|
||||
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 ));
|
||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
||||
}
|
||||
|
||||
# used by JSON for serialization
|
||||
sub TO_JSON {
|
||||
my $self = shift;
|
||||
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};
|
||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
||||
if ( defined $self->{$_key} ) {
|
||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
||||
}
|
||||
}
|
||||
return $_data;
|
||||
@ -98,69 +97,83 @@ sub TO_JSON {
|
||||
|
||||
# from Perl hashref
|
||||
sub from_hash {
|
||||
my ($self, $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);
|
||||
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);
|
||||
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);
|
||||
}
|
||||
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'))) {
|
||||
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)
|
||||
}
|
||||
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',
|
||||
class => 'ClassModel',
|
||||
required => [], # TODO
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation(
|
||||
{
|
||||
'_class' => {
|
||||
datatype => 'string',
|
||||
base_name => '_class',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->class_documentation({description => 'Model for testing model with \"_class\" property',
|
||||
class => 'ClassModel',
|
||||
required => [], # TODO
|
||||
} );
|
||||
__PACKAGE__->openapi_types(
|
||||
{
|
||||
'_class' => 'string'
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation({
|
||||
'_class' => {
|
||||
datatype => 'string',
|
||||
base_name => '_class',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
});
|
||||
|
||||
__PACKAGE__->openapi_types( {
|
||||
'_class' => 'string'
|
||||
} );
|
||||
|
||||
__PACKAGE__->attribute_map( {
|
||||
'_class' => '_class'
|
||||
} );
|
||||
|
||||
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
||||
__PACKAGE__->attribute_map(
|
||||
{
|
||||
'_class' => '_class'
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
||||
|
||||
1;
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
=begin comment
|
||||
|
||||
OpenAPI Petstore
|
||||
@ -30,9 +31,7 @@ use Log::Any qw($log);
|
||||
use Date::Parse;
|
||||
use DateTime;
|
||||
|
||||
|
||||
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||
|
||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
||||
|
||||
#
|
||||
#
|
||||
@ -60,37 +59,37 @@ Generated by: 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' => {});
|
||||
__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) = @_;
|
||||
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;
|
||||
}
|
||||
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 ));
|
||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
||||
}
|
||||
|
||||
# used by JSON for serialization
|
||||
sub TO_JSON {
|
||||
my $self = shift;
|
||||
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};
|
||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
||||
if ( defined $self->{$_key} ) {
|
||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
||||
}
|
||||
}
|
||||
return $_data;
|
||||
@ -98,69 +97,82 @@ sub TO_JSON {
|
||||
|
||||
# from Perl hashref
|
||||
sub from_hash {
|
||||
my ($self, $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);
|
||||
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);
|
||||
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);
|
||||
}
|
||||
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'))) {
|
||||
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)
|
||||
}
|
||||
else { # hash(model)
|
||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||
return $_instance->from_hash($data);
|
||||
}
|
||||
}
|
||||
|
||||
__PACKAGE__->class_documentation(
|
||||
{
|
||||
description => '',
|
||||
class => 'Client',
|
||||
required => [], # TODO
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation(
|
||||
{
|
||||
'client' => {
|
||||
datatype => 'string',
|
||||
base_name => 'client',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->class_documentation({description => '',
|
||||
class => 'Client',
|
||||
required => [], # TODO
|
||||
} );
|
||||
__PACKAGE__->openapi_types(
|
||||
{
|
||||
'client' => 'string'
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation({
|
||||
'client' => {
|
||||
datatype => 'string',
|
||||
base_name => 'client',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
});
|
||||
|
||||
__PACKAGE__->openapi_types( {
|
||||
'client' => 'string'
|
||||
} );
|
||||
|
||||
__PACKAGE__->attribute_map( {
|
||||
'client' => 'client'
|
||||
} );
|
||||
|
||||
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
||||
__PACKAGE__->attribute_map(
|
||||
{
|
||||
'client' => 'client'
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
||||
|
||||
1;
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
=begin comment
|
||||
|
||||
OpenAPI Petstore
|
||||
@ -32,8 +33,7 @@ use DateTime;
|
||||
|
||||
use WWW::OpenAPIClient::Object::Animal;
|
||||
|
||||
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||
|
||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
||||
|
||||
#
|
||||
#
|
||||
@ -61,37 +61,37 @@ Generated by: 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' => {});
|
||||
__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) = @_;
|
||||
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;
|
||||
}
|
||||
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 ));
|
||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
||||
}
|
||||
|
||||
# used by JSON for serialization
|
||||
sub TO_JSON {
|
||||
my $self = shift;
|
||||
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};
|
||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
||||
if ( defined $self->{$_key} ) {
|
||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
||||
}
|
||||
}
|
||||
return $_data;
|
||||
@ -99,87 +99,100 @@ sub TO_JSON {
|
||||
|
||||
# from Perl hashref
|
||||
sub from_hash {
|
||||
my ($self, $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);
|
||||
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);
|
||||
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);
|
||||
}
|
||||
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'))) {
|
||||
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)
|
||||
}
|
||||
else { # hash(model)
|
||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||
return $_instance->from_hash($data);
|
||||
}
|
||||
}
|
||||
|
||||
__PACKAGE__->class_documentation(
|
||||
{
|
||||
description => '',
|
||||
class => 'Dog',
|
||||
required => [], # TODO
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation(
|
||||
{
|
||||
'class_name' => {
|
||||
datatype => 'string',
|
||||
base_name => 'className',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'color' => {
|
||||
datatype => 'string',
|
||||
base_name => 'color',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'breed' => {
|
||||
datatype => 'string',
|
||||
base_name => 'breed',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->class_documentation({description => '',
|
||||
class => 'Dog',
|
||||
required => [], # TODO
|
||||
} );
|
||||
__PACKAGE__->openapi_types(
|
||||
{
|
||||
'class_name' => 'string',
|
||||
'color' => 'string',
|
||||
'breed' => 'string'
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation({
|
||||
'class_name' => {
|
||||
datatype => 'string',
|
||||
base_name => 'className',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'color' => {
|
||||
datatype => 'string',
|
||||
base_name => 'color',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'breed' => {
|
||||
datatype => 'string',
|
||||
base_name => 'breed',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
});
|
||||
|
||||
__PACKAGE__->openapi_types( {
|
||||
'class_name' => 'string',
|
||||
'color' => 'string',
|
||||
'breed' => 'string'
|
||||
} );
|
||||
|
||||
__PACKAGE__->attribute_map( {
|
||||
'class_name' => 'className',
|
||||
'color' => 'color',
|
||||
'breed' => 'breed'
|
||||
} );
|
||||
|
||||
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
||||
__PACKAGE__->attribute_map(
|
||||
{
|
||||
'class_name' => 'className',
|
||||
'color' => 'color',
|
||||
'breed' => 'breed'
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
||||
|
||||
1;
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
=begin comment
|
||||
|
||||
OpenAPI Petstore
|
||||
@ -30,9 +31,7 @@ use Log::Any qw($log);
|
||||
use Date::Parse;
|
||||
use DateTime;
|
||||
|
||||
|
||||
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||
|
||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
||||
|
||||
#
|
||||
#
|
||||
@ -60,37 +59,37 @@ Generated by: 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' => {});
|
||||
__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) = @_;
|
||||
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;
|
||||
}
|
||||
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 ));
|
||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
||||
}
|
||||
|
||||
# used by JSON for serialization
|
||||
sub TO_JSON {
|
||||
my $self = shift;
|
||||
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};
|
||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
||||
if ( defined $self->{$_key} ) {
|
||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
||||
}
|
||||
}
|
||||
return $_data;
|
||||
@ -98,78 +97,91 @@ sub TO_JSON {
|
||||
|
||||
# from Perl hashref
|
||||
sub from_hash {
|
||||
my ($self, $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);
|
||||
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);
|
||||
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);
|
||||
}
|
||||
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'))) {
|
||||
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)
|
||||
}
|
||||
else { # hash(model)
|
||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||
return $_instance->from_hash($data);
|
||||
}
|
||||
}
|
||||
|
||||
__PACKAGE__->class_documentation(
|
||||
{
|
||||
description => '',
|
||||
class => 'EnumArrays',
|
||||
required => [], # TODO
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation(
|
||||
{
|
||||
'just_symbol' => {
|
||||
datatype => 'string',
|
||||
base_name => 'just_symbol',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'array_enum' => {
|
||||
datatype => 'ARRAY[string]',
|
||||
base_name => 'array_enum',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->class_documentation({description => '',
|
||||
class => 'EnumArrays',
|
||||
required => [], # TODO
|
||||
} );
|
||||
__PACKAGE__->openapi_types(
|
||||
{
|
||||
'just_symbol' => 'string',
|
||||
'array_enum' => 'ARRAY[string]'
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation({
|
||||
'just_symbol' => {
|
||||
datatype => 'string',
|
||||
base_name => 'just_symbol',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'array_enum' => {
|
||||
datatype => 'ARRAY[string]',
|
||||
base_name => 'array_enum',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
});
|
||||
|
||||
__PACKAGE__->openapi_types( {
|
||||
'just_symbol' => 'string',
|
||||
'array_enum' => 'ARRAY[string]'
|
||||
} );
|
||||
|
||||
__PACKAGE__->attribute_map( {
|
||||
'just_symbol' => 'just_symbol',
|
||||
'array_enum' => 'array_enum'
|
||||
} );
|
||||
|
||||
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
||||
__PACKAGE__->attribute_map(
|
||||
{
|
||||
'just_symbol' => 'just_symbol',
|
||||
'array_enum' => 'array_enum'
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
||||
|
||||
1;
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
=begin comment
|
||||
|
||||
OpenAPI Petstore
|
||||
@ -30,9 +31,7 @@ use Log::Any qw($log);
|
||||
use Date::Parse;
|
||||
use DateTime;
|
||||
|
||||
|
||||
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||
|
||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
||||
|
||||
#
|
||||
#
|
||||
@ -60,37 +59,37 @@ Generated by: 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' => {});
|
||||
__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) = @_;
|
||||
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;
|
||||
}
|
||||
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 ));
|
||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
||||
}
|
||||
|
||||
# used by JSON for serialization
|
||||
sub TO_JSON {
|
||||
my $self = shift;
|
||||
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};
|
||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
||||
if ( defined $self->{$_key} ) {
|
||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
||||
}
|
||||
}
|
||||
return $_data;
|
||||
@ -98,62 +97,72 @@ sub TO_JSON {
|
||||
|
||||
# from Perl hashref
|
||||
sub from_hash {
|
||||
my ($self, $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);
|
||||
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);
|
||||
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);
|
||||
}
|
||||
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'))) {
|
||||
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)
|
||||
}
|
||||
else { # hash(model)
|
||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||
return $_instance->from_hash($data);
|
||||
}
|
||||
}
|
||||
|
||||
__PACKAGE__->class_documentation(
|
||||
{
|
||||
description => '',
|
||||
class => 'EnumClass',
|
||||
required => [], # TODO
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation( {} );
|
||||
|
||||
__PACKAGE__->class_documentation({description => '',
|
||||
class => 'EnumClass',
|
||||
required => [], # TODO
|
||||
} );
|
||||
__PACKAGE__->openapi_types(
|
||||
{
|
||||
|
||||
__PACKAGE__->method_documentation({
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->openapi_types( {
|
||||
|
||||
} );
|
||||
__PACKAGE__->attribute_map(
|
||||
{
|
||||
|
||||
__PACKAGE__->attribute_map( {
|
||||
|
||||
} );
|
||||
|
||||
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
||||
|
||||
1;
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
=begin comment
|
||||
|
||||
OpenAPI Petstore
|
||||
@ -32,8 +33,7 @@ use DateTime;
|
||||
|
||||
use WWW::OpenAPIClient::Object::OuterEnum;
|
||||
|
||||
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||
|
||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
||||
|
||||
#
|
||||
#
|
||||
@ -61,37 +61,37 @@ Generated by: 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' => {});
|
||||
__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) = @_;
|
||||
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;
|
||||
}
|
||||
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 ));
|
||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
||||
}
|
||||
|
||||
# used by JSON for serialization
|
||||
sub TO_JSON {
|
||||
my $self = shift;
|
||||
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};
|
||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
||||
if ( defined $self->{$_key} ) {
|
||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
||||
}
|
||||
}
|
||||
return $_data;
|
||||
@ -99,105 +99,118 @@ sub TO_JSON {
|
||||
|
||||
# from Perl hashref
|
||||
sub from_hash {
|
||||
my ($self, $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);
|
||||
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);
|
||||
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);
|
||||
}
|
||||
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'))) {
|
||||
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)
|
||||
}
|
||||
else { # hash(model)
|
||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||
return $_instance->from_hash($data);
|
||||
}
|
||||
}
|
||||
|
||||
__PACKAGE__->class_documentation(
|
||||
{
|
||||
description => '',
|
||||
class => 'EnumTest',
|
||||
required => [], # TODO
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation(
|
||||
{
|
||||
'enum_string' => {
|
||||
datatype => 'string',
|
||||
base_name => 'enum_string',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'enum_string_required' => {
|
||||
datatype => 'string',
|
||||
base_name => 'enum_string_required',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'enum_integer' => {
|
||||
datatype => 'int',
|
||||
base_name => 'enum_integer',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'enum_number' => {
|
||||
datatype => 'double',
|
||||
base_name => 'enum_number',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'outer_enum' => {
|
||||
datatype => 'OuterEnum',
|
||||
base_name => 'outerEnum',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->class_documentation({description => '',
|
||||
class => 'EnumTest',
|
||||
required => [], # TODO
|
||||
} );
|
||||
__PACKAGE__->openapi_types(
|
||||
{
|
||||
'enum_string' => 'string',
|
||||
'enum_string_required' => 'string',
|
||||
'enum_integer' => 'int',
|
||||
'enum_number' => 'double',
|
||||
'outer_enum' => 'OuterEnum'
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation({
|
||||
'enum_string' => {
|
||||
datatype => 'string',
|
||||
base_name => 'enum_string',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'enum_string_required' => {
|
||||
datatype => 'string',
|
||||
base_name => 'enum_string_required',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'enum_integer' => {
|
||||
datatype => 'int',
|
||||
base_name => 'enum_integer',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'enum_number' => {
|
||||
datatype => 'double',
|
||||
base_name => 'enum_number',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'outer_enum' => {
|
||||
datatype => 'OuterEnum',
|
||||
base_name => 'outerEnum',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
});
|
||||
|
||||
__PACKAGE__->openapi_types( {
|
||||
'enum_string' => 'string',
|
||||
'enum_string_required' => 'string',
|
||||
'enum_integer' => 'int',
|
||||
'enum_number' => 'double',
|
||||
'outer_enum' => 'OuterEnum'
|
||||
} );
|
||||
|
||||
__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});
|
||||
__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;
|
||||
|
@ -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;
|
@ -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;
|
@ -1,3 +1,4 @@
|
||||
|
||||
=begin comment
|
||||
|
||||
OpenAPI Petstore
|
||||
@ -30,9 +31,7 @@ use Log::Any qw($log);
|
||||
use Date::Parse;
|
||||
use DateTime;
|
||||
|
||||
|
||||
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||
|
||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
||||
|
||||
#
|
||||
#
|
||||
@ -60,37 +59,37 @@ Generated by: 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' => {});
|
||||
__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) = @_;
|
||||
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;
|
||||
}
|
||||
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 ));
|
||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
||||
}
|
||||
|
||||
# used by JSON for serialization
|
||||
sub TO_JSON {
|
||||
my $self = shift;
|
||||
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};
|
||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
||||
if ( defined $self->{$_key} ) {
|
||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
||||
}
|
||||
}
|
||||
return $_data;
|
||||
@ -98,177 +97,190 @@ sub TO_JSON {
|
||||
|
||||
# from Perl hashref
|
||||
sub from_hash {
|
||||
my ($self, $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);
|
||||
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);
|
||||
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);
|
||||
}
|
||||
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'))) {
|
||||
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)
|
||||
}
|
||||
else { # hash(model)
|
||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||
return $_instance->from_hash($data);
|
||||
}
|
||||
}
|
||||
|
||||
__PACKAGE__->class_documentation(
|
||||
{
|
||||
description => '',
|
||||
class => 'FormatTest',
|
||||
required => [], # TODO
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation(
|
||||
{
|
||||
'integer' => {
|
||||
datatype => 'int',
|
||||
base_name => 'integer',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'int32' => {
|
||||
datatype => 'int',
|
||||
base_name => 'int32',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'int64' => {
|
||||
datatype => 'int',
|
||||
base_name => 'int64',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'number' => {
|
||||
datatype => 'double',
|
||||
base_name => 'number',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'float' => {
|
||||
datatype => 'double',
|
||||
base_name => 'float',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'double' => {
|
||||
datatype => 'double',
|
||||
base_name => 'double',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'string' => {
|
||||
datatype => 'string',
|
||||
base_name => 'string',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'byte' => {
|
||||
datatype => 'string',
|
||||
base_name => 'byte',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'binary' => {
|
||||
datatype => 'string',
|
||||
base_name => 'binary',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'date' => {
|
||||
datatype => 'DateTime',
|
||||
base_name => 'date',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'date_time' => {
|
||||
datatype => 'DateTime',
|
||||
base_name => 'dateTime',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'uuid' => {
|
||||
datatype => 'string',
|
||||
base_name => 'uuid',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'password' => {
|
||||
datatype => 'string',
|
||||
base_name => 'password',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->class_documentation({description => '',
|
||||
class => 'FormatTest',
|
||||
required => [], # TODO
|
||||
} );
|
||||
__PACKAGE__->openapi_types(
|
||||
{
|
||||
'integer' => 'int',
|
||||
'int32' => 'int',
|
||||
'int64' => 'int',
|
||||
'number' => 'double',
|
||||
'float' => 'double',
|
||||
'double' => 'double',
|
||||
'string' => 'string',
|
||||
'byte' => 'string',
|
||||
'binary' => 'string',
|
||||
'date' => 'DateTime',
|
||||
'date_time' => 'DateTime',
|
||||
'uuid' => 'string',
|
||||
'password' => 'string'
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation({
|
||||
'integer' => {
|
||||
datatype => 'int',
|
||||
base_name => 'integer',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'int32' => {
|
||||
datatype => 'int',
|
||||
base_name => 'int32',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'int64' => {
|
||||
datatype => 'int',
|
||||
base_name => 'int64',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'number' => {
|
||||
datatype => 'double',
|
||||
base_name => 'number',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'float' => {
|
||||
datatype => 'double',
|
||||
base_name => 'float',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'double' => {
|
||||
datatype => 'double',
|
||||
base_name => 'double',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'string' => {
|
||||
datatype => 'string',
|
||||
base_name => 'string',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'byte' => {
|
||||
datatype => 'string',
|
||||
base_name => 'byte',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'binary' => {
|
||||
datatype => 'string',
|
||||
base_name => 'binary',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'date' => {
|
||||
datatype => 'DateTime',
|
||||
base_name => 'date',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'date_time' => {
|
||||
datatype => 'DateTime',
|
||||
base_name => 'dateTime',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'uuid' => {
|
||||
datatype => 'string',
|
||||
base_name => 'uuid',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'password' => {
|
||||
datatype => 'string',
|
||||
base_name => 'password',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
});
|
||||
|
||||
__PACKAGE__->openapi_types( {
|
||||
'integer' => 'int',
|
||||
'int32' => 'int',
|
||||
'int64' => 'int',
|
||||
'number' => 'double',
|
||||
'float' => 'double',
|
||||
'double' => 'double',
|
||||
'string' => 'string',
|
||||
'byte' => 'string',
|
||||
'binary' => 'string',
|
||||
'date' => 'DateTime',
|
||||
'date_time' => 'DateTime',
|
||||
'uuid' => 'string',
|
||||
'password' => 'string'
|
||||
} );
|
||||
|
||||
__PACKAGE__->attribute_map( {
|
||||
'integer' => 'integer',
|
||||
'int32' => 'int32',
|
||||
'int64' => 'int64',
|
||||
'number' => 'number',
|
||||
'float' => 'float',
|
||||
'double' => 'double',
|
||||
'string' => 'string',
|
||||
'byte' => 'byte',
|
||||
'binary' => 'binary',
|
||||
'date' => 'date',
|
||||
'date_time' => 'dateTime',
|
||||
'uuid' => 'uuid',
|
||||
'password' => 'password'
|
||||
} );
|
||||
|
||||
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
||||
__PACKAGE__->attribute_map(
|
||||
{
|
||||
'integer' => 'integer',
|
||||
'int32' => 'int32',
|
||||
'int64' => 'int64',
|
||||
'number' => 'number',
|
||||
'float' => 'float',
|
||||
'double' => 'double',
|
||||
'string' => 'string',
|
||||
'byte' => 'byte',
|
||||
'binary' => 'binary',
|
||||
'date' => 'date',
|
||||
'date_time' => 'dateTime',
|
||||
'uuid' => 'uuid',
|
||||
'password' => 'password'
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
||||
|
||||
1;
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
=begin comment
|
||||
|
||||
OpenAPI Petstore
|
||||
@ -30,9 +31,7 @@ use Log::Any qw($log);
|
||||
use Date::Parse;
|
||||
use DateTime;
|
||||
|
||||
|
||||
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||
|
||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
||||
|
||||
#
|
||||
#
|
||||
@ -60,37 +59,37 @@ Generated by: 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' => {});
|
||||
__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) = @_;
|
||||
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;
|
||||
}
|
||||
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 ));
|
||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
||||
}
|
||||
|
||||
# used by JSON for serialization
|
||||
sub TO_JSON {
|
||||
my $self = shift;
|
||||
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};
|
||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
||||
if ( defined $self->{$_key} ) {
|
||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
||||
}
|
||||
}
|
||||
return $_data;
|
||||
@ -98,78 +97,91 @@ sub TO_JSON {
|
||||
|
||||
# from Perl hashref
|
||||
sub from_hash {
|
||||
my ($self, $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);
|
||||
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);
|
||||
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);
|
||||
}
|
||||
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'))) {
|
||||
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)
|
||||
}
|
||||
else { # hash(model)
|
||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||
return $_instance->from_hash($data);
|
||||
}
|
||||
}
|
||||
|
||||
__PACKAGE__->class_documentation(
|
||||
{
|
||||
description => '',
|
||||
class => 'HasOnlyReadOnly',
|
||||
required => [], # TODO
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation(
|
||||
{
|
||||
'bar' => {
|
||||
datatype => 'string',
|
||||
base_name => 'bar',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'foo' => {
|
||||
datatype => 'string',
|
||||
base_name => 'foo',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->class_documentation({description => '',
|
||||
class => 'HasOnlyReadOnly',
|
||||
required => [], # TODO
|
||||
} );
|
||||
__PACKAGE__->openapi_types(
|
||||
{
|
||||
'bar' => 'string',
|
||||
'foo' => 'string'
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation({
|
||||
'bar' => {
|
||||
datatype => 'string',
|
||||
base_name => 'bar',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'foo' => {
|
||||
datatype => 'string',
|
||||
base_name => 'foo',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
});
|
||||
|
||||
__PACKAGE__->openapi_types( {
|
||||
'bar' => 'string',
|
||||
'foo' => 'string'
|
||||
} );
|
||||
|
||||
__PACKAGE__->attribute_map( {
|
||||
'bar' => 'bar',
|
||||
'foo' => 'foo'
|
||||
} );
|
||||
|
||||
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
||||
__PACKAGE__->attribute_map(
|
||||
{
|
||||
'bar' => 'bar',
|
||||
'foo' => 'foo'
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
||||
|
||||
1;
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
=begin comment
|
||||
|
||||
OpenAPI Petstore
|
||||
@ -30,9 +31,7 @@ use Log::Any qw($log);
|
||||
use Date::Parse;
|
||||
use DateTime;
|
||||
|
||||
|
||||
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||
|
||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
||||
|
||||
#
|
||||
#
|
||||
@ -60,37 +59,37 @@ Generated by: 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' => {});
|
||||
__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) = @_;
|
||||
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;
|
||||
}
|
||||
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 ));
|
||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
||||
}
|
||||
|
||||
# used by JSON for serialization
|
||||
sub TO_JSON {
|
||||
my $self = shift;
|
||||
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};
|
||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
||||
if ( defined $self->{$_key} ) {
|
||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
||||
}
|
||||
}
|
||||
return $_data;
|
||||
@ -98,69 +97,82 @@ sub TO_JSON {
|
||||
|
||||
# from Perl hashref
|
||||
sub from_hash {
|
||||
my ($self, $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);
|
||||
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);
|
||||
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);
|
||||
}
|
||||
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'))) {
|
||||
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)
|
||||
}
|
||||
else { # hash(model)
|
||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||
return $_instance->from_hash($data);
|
||||
}
|
||||
}
|
||||
|
||||
__PACKAGE__->class_documentation(
|
||||
{
|
||||
description => '',
|
||||
class => 'List',
|
||||
required => [], # TODO
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation(
|
||||
{
|
||||
'_123_list' => {
|
||||
datatype => 'string',
|
||||
base_name => '123-list',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->class_documentation({description => '',
|
||||
class => 'List',
|
||||
required => [], # TODO
|
||||
} );
|
||||
__PACKAGE__->openapi_types(
|
||||
{
|
||||
'_123_list' => 'string'
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation({
|
||||
'_123_list' => {
|
||||
datatype => 'string',
|
||||
base_name => '123-list',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
});
|
||||
|
||||
__PACKAGE__->openapi_types( {
|
||||
'_123_list' => 'string'
|
||||
} );
|
||||
|
||||
__PACKAGE__->attribute_map( {
|
||||
'_123_list' => '123-list'
|
||||
} );
|
||||
|
||||
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
||||
__PACKAGE__->attribute_map(
|
||||
{
|
||||
'_123_list' => '123-list'
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
||||
|
||||
1;
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
=begin comment
|
||||
|
||||
OpenAPI Petstore
|
||||
@ -30,9 +31,9 @@ use Log::Any qw($log);
|
||||
use Date::Parse;
|
||||
use DateTime;
|
||||
|
||||
use WWW::OpenAPIClient::Object::StringBooleanMap;
|
||||
|
||||
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||
|
||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
||||
|
||||
#
|
||||
#
|
||||
@ -60,37 +61,37 @@ Generated by: 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' => {});
|
||||
__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) = @_;
|
||||
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;
|
||||
}
|
||||
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 ));
|
||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
||||
}
|
||||
|
||||
# used by JSON for serialization
|
||||
sub TO_JSON {
|
||||
my $self = shift;
|
||||
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};
|
||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
||||
if ( defined $self->{$_key} ) {
|
||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
||||
}
|
||||
}
|
||||
return $_data;
|
||||
@ -98,78 +99,109 @@ sub TO_JSON {
|
||||
|
||||
# from Perl hashref
|
||||
sub from_hash {
|
||||
my ($self, $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);
|
||||
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);
|
||||
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);
|
||||
}
|
||||
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'))) {
|
||||
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)
|
||||
}
|
||||
else { # hash(model)
|
||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||
return $_instance->from_hash($data);
|
||||
}
|
||||
}
|
||||
|
||||
__PACKAGE__->class_documentation(
|
||||
{
|
||||
description => '',
|
||||
class => 'MapTest',
|
||||
required => [], # TODO
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation(
|
||||
{
|
||||
'map_map_of_string' => {
|
||||
datatype => 'HASH[string,HASH[string,string]]',
|
||||
base_name => 'map_map_of_string',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'map_of_enum_string' => {
|
||||
datatype => 'HASH[string,string]',
|
||||
base_name => 'map_of_enum_string',
|
||||
description => '',
|
||||
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__->class_documentation({description => '',
|
||||
class => 'MapTest',
|
||||
required => [], # TODO
|
||||
} );
|
||||
__PACKAGE__->openapi_types(
|
||||
{
|
||||
'map_map_of_string' => 'HASH[string,HASH[string,string]]',
|
||||
'map_of_enum_string' => 'HASH[string,string]',
|
||||
'direct_map' => 'HASH[string,boolean]',
|
||||
'indirect_map' => 'StringBooleanMap'
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation({
|
||||
'map_map_of_string' => {
|
||||
datatype => 'HASH[string,HASH[string,string]]',
|
||||
base_name => 'map_map_of_string',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'map_of_enum_string' => {
|
||||
datatype => 'HASH[string,string]',
|
||||
base_name => 'map_of_enum_string',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
});
|
||||
|
||||
__PACKAGE__->openapi_types( {
|
||||
'map_map_of_string' => 'HASH[string,HASH[string,string]]',
|
||||
'map_of_enum_string' => 'HASH[string,string]'
|
||||
} );
|
||||
|
||||
__PACKAGE__->attribute_map( {
|
||||
'map_map_of_string' => 'map_map_of_string',
|
||||
'map_of_enum_string' => 'map_of_enum_string'
|
||||
} );
|
||||
|
||||
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
||||
__PACKAGE__->attribute_map(
|
||||
{
|
||||
'map_map_of_string' => 'map_map_of_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;
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
=begin comment
|
||||
|
||||
OpenAPI Petstore
|
||||
@ -32,8 +33,7 @@ use DateTime;
|
||||
|
||||
use WWW::OpenAPIClient::Object::Animal;
|
||||
|
||||
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||
|
||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
||||
|
||||
#
|
||||
#
|
||||
@ -61,37 +61,37 @@ Generated by: 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' => {});
|
||||
__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) = @_;
|
||||
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;
|
||||
}
|
||||
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 ));
|
||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
||||
}
|
||||
|
||||
# used by JSON for serialization
|
||||
sub TO_JSON {
|
||||
my $self = shift;
|
||||
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};
|
||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
||||
if ( defined $self->{$_key} ) {
|
||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
||||
}
|
||||
}
|
||||
return $_data;
|
||||
@ -99,87 +99,100 @@ sub TO_JSON {
|
||||
|
||||
# from Perl hashref
|
||||
sub from_hash {
|
||||
my ($self, $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);
|
||||
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);
|
||||
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);
|
||||
}
|
||||
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'))) {
|
||||
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)
|
||||
}
|
||||
else { # hash(model)
|
||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||
return $_instance->from_hash($data);
|
||||
}
|
||||
}
|
||||
|
||||
__PACKAGE__->class_documentation(
|
||||
{
|
||||
description => '',
|
||||
class => 'MixedPropertiesAndAdditionalPropertiesClass',
|
||||
required => [], # TODO
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation(
|
||||
{
|
||||
'uuid' => {
|
||||
datatype => 'string',
|
||||
base_name => 'uuid',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'date_time' => {
|
||||
datatype => 'DateTime',
|
||||
base_name => 'dateTime',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'map' => {
|
||||
datatype => 'HASH[string,Animal]',
|
||||
base_name => 'map',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->class_documentation({description => '',
|
||||
class => 'MixedPropertiesAndAdditionalPropertiesClass',
|
||||
required => [], # TODO
|
||||
} );
|
||||
__PACKAGE__->openapi_types(
|
||||
{
|
||||
'uuid' => 'string',
|
||||
'date_time' => 'DateTime',
|
||||
'map' => 'HASH[string,Animal]'
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation({
|
||||
'uuid' => {
|
||||
datatype => 'string',
|
||||
base_name => 'uuid',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'date_time' => {
|
||||
datatype => 'DateTime',
|
||||
base_name => 'dateTime',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'map' => {
|
||||
datatype => 'HASH[string,Animal]',
|
||||
base_name => 'map',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
});
|
||||
|
||||
__PACKAGE__->openapi_types( {
|
||||
'uuid' => 'string',
|
||||
'date_time' => 'DateTime',
|
||||
'map' => 'HASH[string,Animal]'
|
||||
} );
|
||||
|
||||
__PACKAGE__->attribute_map( {
|
||||
'uuid' => 'uuid',
|
||||
'date_time' => 'dateTime',
|
||||
'map' => 'map'
|
||||
} );
|
||||
|
||||
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
||||
__PACKAGE__->attribute_map(
|
||||
{
|
||||
'uuid' => 'uuid',
|
||||
'date_time' => 'dateTime',
|
||||
'map' => 'map'
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
||||
|
||||
1;
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
=begin comment
|
||||
|
||||
OpenAPI Petstore
|
||||
@ -30,9 +31,7 @@ use Log::Any qw($log);
|
||||
use Date::Parse;
|
||||
use DateTime;
|
||||
|
||||
|
||||
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||
|
||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
||||
|
||||
#
|
||||
#Model for testing model name starting with number
|
||||
@ -60,37 +59,37 @@ Generated by: 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' => {});
|
||||
__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) = @_;
|
||||
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;
|
||||
}
|
||||
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 ));
|
||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
||||
}
|
||||
|
||||
# used by JSON for serialization
|
||||
sub TO_JSON {
|
||||
my $self = shift;
|
||||
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};
|
||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
||||
if ( defined $self->{$_key} ) {
|
||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
||||
}
|
||||
}
|
||||
return $_data;
|
||||
@ -98,78 +97,91 @@ sub TO_JSON {
|
||||
|
||||
# from Perl hashref
|
||||
sub from_hash {
|
||||
my ($self, $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);
|
||||
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);
|
||||
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);
|
||||
}
|
||||
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'))) {
|
||||
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)
|
||||
}
|
||||
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',
|
||||
class => 'Model200Response',
|
||||
required => [], # TODO
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation(
|
||||
{
|
||||
'name' => {
|
||||
datatype => 'int',
|
||||
base_name => 'name',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'class' => {
|
||||
datatype => 'string',
|
||||
base_name => 'class',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->class_documentation({description => 'Model for testing model name starting with number',
|
||||
class => 'Model200Response',
|
||||
required => [], # TODO
|
||||
} );
|
||||
__PACKAGE__->openapi_types(
|
||||
{
|
||||
'name' => 'int',
|
||||
'class' => 'string'
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation({
|
||||
'name' => {
|
||||
datatype => 'int',
|
||||
base_name => 'name',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'class' => {
|
||||
datatype => 'string',
|
||||
base_name => 'class',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
});
|
||||
|
||||
__PACKAGE__->openapi_types( {
|
||||
'name' => 'int',
|
||||
'class' => 'string'
|
||||
} );
|
||||
|
||||
__PACKAGE__->attribute_map( {
|
||||
'name' => 'name',
|
||||
'class' => 'class'
|
||||
} );
|
||||
|
||||
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
||||
__PACKAGE__->attribute_map(
|
||||
{
|
||||
'name' => 'name',
|
||||
'class' => 'class'
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
||||
|
||||
1;
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
=begin comment
|
||||
|
||||
OpenAPI Petstore
|
||||
@ -30,9 +31,7 @@ use Log::Any qw($log);
|
||||
use Date::Parse;
|
||||
use DateTime;
|
||||
|
||||
|
||||
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||
|
||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
||||
|
||||
#
|
||||
#Model for testing reserved words
|
||||
@ -60,37 +59,37 @@ Generated by: 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' => {});
|
||||
__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) = @_;
|
||||
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;
|
||||
}
|
||||
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 ));
|
||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
||||
}
|
||||
|
||||
# used by JSON for serialization
|
||||
sub TO_JSON {
|
||||
my $self = shift;
|
||||
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};
|
||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
||||
if ( defined $self->{$_key} ) {
|
||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
||||
}
|
||||
}
|
||||
return $_data;
|
||||
@ -98,69 +97,82 @@ sub TO_JSON {
|
||||
|
||||
# from Perl hashref
|
||||
sub from_hash {
|
||||
my ($self, $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);
|
||||
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);
|
||||
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);
|
||||
}
|
||||
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'))) {
|
||||
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)
|
||||
}
|
||||
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',
|
||||
class => 'ModelReturn',
|
||||
required => [], # TODO
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation(
|
||||
{
|
||||
'return' => {
|
||||
datatype => 'int',
|
||||
base_name => 'return',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->class_documentation({description => 'Model for testing reserved words',
|
||||
class => 'ModelReturn',
|
||||
required => [], # TODO
|
||||
} );
|
||||
__PACKAGE__->openapi_types(
|
||||
{
|
||||
'return' => 'int'
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation({
|
||||
'return' => {
|
||||
datatype => 'int',
|
||||
base_name => 'return',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
});
|
||||
|
||||
__PACKAGE__->openapi_types( {
|
||||
'return' => 'int'
|
||||
} );
|
||||
|
||||
__PACKAGE__->attribute_map( {
|
||||
'return' => 'return'
|
||||
} );
|
||||
|
||||
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
||||
__PACKAGE__->attribute_map(
|
||||
{
|
||||
'return' => 'return'
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
||||
|
||||
1;
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
=begin comment
|
||||
|
||||
OpenAPI Petstore
|
||||
@ -30,9 +31,7 @@ use Log::Any qw($log);
|
||||
use Date::Parse;
|
||||
use DateTime;
|
||||
|
||||
|
||||
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||
|
||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
||||
|
||||
#
|
||||
#Model for testing model name same as property name
|
||||
@ -60,37 +59,37 @@ Generated by: 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' => {});
|
||||
__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) = @_;
|
||||
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;
|
||||
}
|
||||
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 ));
|
||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
||||
}
|
||||
|
||||
# used by JSON for serialization
|
||||
sub TO_JSON {
|
||||
my $self = shift;
|
||||
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};
|
||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
||||
if ( defined $self->{$_key} ) {
|
||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
||||
}
|
||||
}
|
||||
return $_data;
|
||||
@ -98,96 +97,109 @@ sub TO_JSON {
|
||||
|
||||
# from Perl hashref
|
||||
sub from_hash {
|
||||
my ($self, $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);
|
||||
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);
|
||||
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);
|
||||
}
|
||||
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'))) {
|
||||
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)
|
||||
}
|
||||
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',
|
||||
class => 'Name',
|
||||
required => [], # TODO
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation(
|
||||
{
|
||||
'name' => {
|
||||
datatype => 'int',
|
||||
base_name => 'name',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'snake_case' => {
|
||||
datatype => 'int',
|
||||
base_name => 'snake_case',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'property' => {
|
||||
datatype => 'string',
|
||||
base_name => 'property',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'_123_number' => {
|
||||
datatype => 'int',
|
||||
base_name => '123Number',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->class_documentation({description => 'Model for testing model name same as property name',
|
||||
class => 'Name',
|
||||
required => [], # TODO
|
||||
} );
|
||||
__PACKAGE__->openapi_types(
|
||||
{
|
||||
'name' => 'int',
|
||||
'snake_case' => 'int',
|
||||
'property' => 'string',
|
||||
'_123_number' => 'int'
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation({
|
||||
'name' => {
|
||||
datatype => 'int',
|
||||
base_name => 'name',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'snake_case' => {
|
||||
datatype => 'int',
|
||||
base_name => 'snake_case',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'property' => {
|
||||
datatype => 'string',
|
||||
base_name => 'property',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'_123_number' => {
|
||||
datatype => 'int',
|
||||
base_name => '123Number',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
});
|
||||
|
||||
__PACKAGE__->openapi_types( {
|
||||
'name' => 'int',
|
||||
'snake_case' => 'int',
|
||||
'property' => 'string',
|
||||
'_123_number' => 'int'
|
||||
} );
|
||||
|
||||
__PACKAGE__->attribute_map( {
|
||||
'name' => 'name',
|
||||
'snake_case' => 'snake_case',
|
||||
'property' => 'property',
|
||||
'_123_number' => '123Number'
|
||||
} );
|
||||
|
||||
__PACKAGE__->mk_accessors(keys %{__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;
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
=begin comment
|
||||
|
||||
OpenAPI Petstore
|
||||
@ -30,9 +31,7 @@ use Log::Any qw($log);
|
||||
use Date::Parse;
|
||||
use DateTime;
|
||||
|
||||
|
||||
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||
|
||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
||||
|
||||
#
|
||||
#
|
||||
@ -60,37 +59,37 @@ Generated by: 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' => {});
|
||||
__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) = @_;
|
||||
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;
|
||||
}
|
||||
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 ));
|
||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
||||
}
|
||||
|
||||
# used by JSON for serialization
|
||||
sub TO_JSON {
|
||||
my $self = shift;
|
||||
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};
|
||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
||||
if ( defined $self->{$_key} ) {
|
||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
||||
}
|
||||
}
|
||||
return $_data;
|
||||
@ -98,69 +97,82 @@ sub TO_JSON {
|
||||
|
||||
# from Perl hashref
|
||||
sub from_hash {
|
||||
my ($self, $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);
|
||||
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);
|
||||
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);
|
||||
}
|
||||
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'))) {
|
||||
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)
|
||||
}
|
||||
else { # hash(model)
|
||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||
return $_instance->from_hash($data);
|
||||
}
|
||||
}
|
||||
|
||||
__PACKAGE__->class_documentation(
|
||||
{
|
||||
description => '',
|
||||
class => 'NumberOnly',
|
||||
required => [], # TODO
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation(
|
||||
{
|
||||
'just_number' => {
|
||||
datatype => 'double',
|
||||
base_name => 'JustNumber',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->class_documentation({description => '',
|
||||
class => 'NumberOnly',
|
||||
required => [], # TODO
|
||||
} );
|
||||
__PACKAGE__->openapi_types(
|
||||
{
|
||||
'just_number' => 'double'
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation({
|
||||
'just_number' => {
|
||||
datatype => 'double',
|
||||
base_name => 'JustNumber',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
});
|
||||
|
||||
__PACKAGE__->openapi_types( {
|
||||
'just_number' => 'double'
|
||||
} );
|
||||
|
||||
__PACKAGE__->attribute_map( {
|
||||
'just_number' => 'JustNumber'
|
||||
} );
|
||||
|
||||
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
||||
__PACKAGE__->attribute_map(
|
||||
{
|
||||
'just_number' => 'JustNumber'
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
||||
|
||||
1;
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
=begin comment
|
||||
|
||||
OpenAPI Petstore
|
||||
@ -30,9 +31,7 @@ use Log::Any qw($log);
|
||||
use Date::Parse;
|
||||
use DateTime;
|
||||
|
||||
|
||||
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||
|
||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
||||
|
||||
#
|
||||
#
|
||||
@ -60,37 +59,37 @@ Generated by: 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' => {});
|
||||
__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) = @_;
|
||||
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;
|
||||
}
|
||||
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 ));
|
||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
||||
}
|
||||
|
||||
# used by JSON for serialization
|
||||
sub TO_JSON {
|
||||
my $self = shift;
|
||||
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};
|
||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
||||
if ( defined $self->{$_key} ) {
|
||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
||||
}
|
||||
}
|
||||
return $_data;
|
||||
@ -98,114 +97,127 @@ sub TO_JSON {
|
||||
|
||||
# from Perl hashref
|
||||
sub from_hash {
|
||||
my ($self, $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);
|
||||
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);
|
||||
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);
|
||||
}
|
||||
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'))) {
|
||||
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)
|
||||
}
|
||||
else { # hash(model)
|
||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||
return $_instance->from_hash($data);
|
||||
}
|
||||
}
|
||||
|
||||
__PACKAGE__->class_documentation(
|
||||
{
|
||||
description => '',
|
||||
class => 'Order',
|
||||
required => [], # TODO
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation(
|
||||
{
|
||||
'id' => {
|
||||
datatype => 'int',
|
||||
base_name => 'id',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'pet_id' => {
|
||||
datatype => 'int',
|
||||
base_name => 'petId',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'quantity' => {
|
||||
datatype => 'int',
|
||||
base_name => 'quantity',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'ship_date' => {
|
||||
datatype => 'DateTime',
|
||||
base_name => 'shipDate',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'status' => {
|
||||
datatype => 'string',
|
||||
base_name => 'status',
|
||||
description => 'Order Status',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'complete' => {
|
||||
datatype => 'boolean',
|
||||
base_name => 'complete',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->class_documentation({description => '',
|
||||
class => 'Order',
|
||||
required => [], # TODO
|
||||
} );
|
||||
__PACKAGE__->openapi_types(
|
||||
{
|
||||
'id' => 'int',
|
||||
'pet_id' => 'int',
|
||||
'quantity' => 'int',
|
||||
'ship_date' => 'DateTime',
|
||||
'status' => 'string',
|
||||
'complete' => 'boolean'
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation({
|
||||
'id' => {
|
||||
datatype => 'int',
|
||||
base_name => 'id',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'pet_id' => {
|
||||
datatype => 'int',
|
||||
base_name => 'petId',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'quantity' => {
|
||||
datatype => 'int',
|
||||
base_name => 'quantity',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'ship_date' => {
|
||||
datatype => 'DateTime',
|
||||
base_name => 'shipDate',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'status' => {
|
||||
datatype => 'string',
|
||||
base_name => 'status',
|
||||
description => 'Order Status',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'complete' => {
|
||||
datatype => 'boolean',
|
||||
base_name => 'complete',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
});
|
||||
|
||||
__PACKAGE__->openapi_types( {
|
||||
'id' => 'int',
|
||||
'pet_id' => 'int',
|
||||
'quantity' => 'int',
|
||||
'ship_date' => 'DateTime',
|
||||
'status' => 'string',
|
||||
'complete' => 'boolean'
|
||||
} );
|
||||
|
||||
__PACKAGE__->attribute_map( {
|
||||
'id' => 'id',
|
||||
'pet_id' => 'petId',
|
||||
'quantity' => 'quantity',
|
||||
'ship_date' => 'shipDate',
|
||||
'status' => 'status',
|
||||
'complete' => 'complete'
|
||||
} );
|
||||
|
||||
__PACKAGE__->mk_accessors(keys %{__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;
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
=begin comment
|
||||
|
||||
OpenAPI Petstore
|
||||
@ -30,9 +31,7 @@ use Log::Any qw($log);
|
||||
use Date::Parse;
|
||||
use DateTime;
|
||||
|
||||
|
||||
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||
|
||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
||||
|
||||
#
|
||||
#
|
||||
@ -60,37 +59,37 @@ Generated by: 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' => {});
|
||||
__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) = @_;
|
||||
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;
|
||||
}
|
||||
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 ));
|
||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
||||
}
|
||||
|
||||
# used by JSON for serialization
|
||||
sub TO_JSON {
|
||||
my $self = shift;
|
||||
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};
|
||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
||||
if ( defined $self->{$_key} ) {
|
||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
||||
}
|
||||
}
|
||||
return $_data;
|
||||
@ -98,87 +97,100 @@ sub TO_JSON {
|
||||
|
||||
# from Perl hashref
|
||||
sub from_hash {
|
||||
my ($self, $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);
|
||||
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);
|
||||
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);
|
||||
}
|
||||
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'))) {
|
||||
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)
|
||||
}
|
||||
else { # hash(model)
|
||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||
return $_instance->from_hash($data);
|
||||
}
|
||||
}
|
||||
|
||||
__PACKAGE__->class_documentation(
|
||||
{
|
||||
description => '',
|
||||
class => 'OuterComposite',
|
||||
required => [], # TODO
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation(
|
||||
{
|
||||
'my_number' => {
|
||||
datatype => 'double',
|
||||
base_name => 'my_number',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'my_string' => {
|
||||
datatype => 'string',
|
||||
base_name => 'my_string',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'my_boolean' => {
|
||||
datatype => 'boolean',
|
||||
base_name => 'my_boolean',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->class_documentation({description => '',
|
||||
class => 'OuterComposite',
|
||||
required => [], # TODO
|
||||
} );
|
||||
__PACKAGE__->openapi_types(
|
||||
{
|
||||
'my_number' => 'double',
|
||||
'my_string' => 'string',
|
||||
'my_boolean' => 'boolean'
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation({
|
||||
'my_number' => {
|
||||
datatype => 'double',
|
||||
base_name => 'my_number',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'my_string' => {
|
||||
datatype => 'string',
|
||||
base_name => 'my_string',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'my_boolean' => {
|
||||
datatype => 'boolean',
|
||||
base_name => 'my_boolean',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
});
|
||||
|
||||
__PACKAGE__->openapi_types( {
|
||||
'my_number' => 'double',
|
||||
'my_string' => 'string',
|
||||
'my_boolean' => 'boolean'
|
||||
} );
|
||||
|
||||
__PACKAGE__->attribute_map( {
|
||||
'my_number' => 'my_number',
|
||||
'my_string' => 'my_string',
|
||||
'my_boolean' => 'my_boolean'
|
||||
} );
|
||||
|
||||
__PACKAGE__->mk_accessors(keys %{__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;
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
=begin comment
|
||||
|
||||
OpenAPI Petstore
|
||||
@ -30,9 +31,7 @@ use Log::Any qw($log);
|
||||
use Date::Parse;
|
||||
use DateTime;
|
||||
|
||||
|
||||
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||
|
||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
||||
|
||||
#
|
||||
#
|
||||
@ -60,37 +59,37 @@ Generated by: 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' => {});
|
||||
__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) = @_;
|
||||
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;
|
||||
}
|
||||
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 ));
|
||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
||||
}
|
||||
|
||||
# used by JSON for serialization
|
||||
sub TO_JSON {
|
||||
my $self = shift;
|
||||
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};
|
||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
||||
if ( defined $self->{$_key} ) {
|
||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
||||
}
|
||||
}
|
||||
return $_data;
|
||||
@ -98,62 +97,72 @@ sub TO_JSON {
|
||||
|
||||
# from Perl hashref
|
||||
sub from_hash {
|
||||
my ($self, $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);
|
||||
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);
|
||||
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);
|
||||
}
|
||||
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'))) {
|
||||
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)
|
||||
}
|
||||
else { # hash(model)
|
||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||
return $_instance->from_hash($data);
|
||||
}
|
||||
}
|
||||
|
||||
__PACKAGE__->class_documentation(
|
||||
{
|
||||
description => '',
|
||||
class => 'OuterEnum',
|
||||
required => [], # TODO
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation( {} );
|
||||
|
||||
__PACKAGE__->class_documentation({description => '',
|
||||
class => 'OuterEnum',
|
||||
required => [], # TODO
|
||||
} );
|
||||
__PACKAGE__->openapi_types(
|
||||
{
|
||||
|
||||
__PACKAGE__->method_documentation({
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->openapi_types( {
|
||||
|
||||
} );
|
||||
__PACKAGE__->attribute_map(
|
||||
{
|
||||
|
||||
__PACKAGE__->attribute_map( {
|
||||
|
||||
} );
|
||||
|
||||
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
||||
|
||||
1;
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
=begin comment
|
||||
|
||||
OpenAPI Petstore
|
||||
@ -33,8 +34,7 @@ use DateTime;
|
||||
use WWW::OpenAPIClient::Object::Category;
|
||||
use WWW::OpenAPIClient::Object::Tag;
|
||||
|
||||
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||
|
||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
||||
|
||||
#
|
||||
#
|
||||
@ -62,37 +62,37 @@ Generated by: 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' => {});
|
||||
__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) = @_;
|
||||
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;
|
||||
}
|
||||
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 ));
|
||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
||||
}
|
||||
|
||||
# used by JSON for serialization
|
||||
sub TO_JSON {
|
||||
my $self = shift;
|
||||
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};
|
||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
||||
if ( defined $self->{$_key} ) {
|
||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
||||
}
|
||||
}
|
||||
return $_data;
|
||||
@ -100,114 +100,127 @@ sub TO_JSON {
|
||||
|
||||
# from Perl hashref
|
||||
sub from_hash {
|
||||
my ($self, $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);
|
||||
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);
|
||||
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);
|
||||
}
|
||||
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'))) {
|
||||
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)
|
||||
}
|
||||
else { # hash(model)
|
||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||
return $_instance->from_hash($data);
|
||||
}
|
||||
}
|
||||
|
||||
__PACKAGE__->class_documentation(
|
||||
{
|
||||
description => '',
|
||||
class => 'Pet',
|
||||
required => [], # TODO
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation(
|
||||
{
|
||||
'id' => {
|
||||
datatype => 'int',
|
||||
base_name => 'id',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'category' => {
|
||||
datatype => 'Category',
|
||||
base_name => 'category',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'name' => {
|
||||
datatype => 'string',
|
||||
base_name => 'name',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'photo_urls' => {
|
||||
datatype => 'ARRAY[string]',
|
||||
base_name => 'photoUrls',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'tags' => {
|
||||
datatype => 'ARRAY[Tag]',
|
||||
base_name => 'tags',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'status' => {
|
||||
datatype => 'string',
|
||||
base_name => 'status',
|
||||
description => 'pet status in the store',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->class_documentation({description => '',
|
||||
class => 'Pet',
|
||||
required => [], # TODO
|
||||
} );
|
||||
__PACKAGE__->openapi_types(
|
||||
{
|
||||
'id' => 'int',
|
||||
'category' => 'Category',
|
||||
'name' => 'string',
|
||||
'photo_urls' => 'ARRAY[string]',
|
||||
'tags' => 'ARRAY[Tag]',
|
||||
'status' => 'string'
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation({
|
||||
'id' => {
|
||||
datatype => 'int',
|
||||
base_name => 'id',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'category' => {
|
||||
datatype => 'Category',
|
||||
base_name => 'category',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'name' => {
|
||||
datatype => 'string',
|
||||
base_name => 'name',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'photo_urls' => {
|
||||
datatype => 'ARRAY[string]',
|
||||
base_name => 'photoUrls',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'tags' => {
|
||||
datatype => 'ARRAY[Tag]',
|
||||
base_name => 'tags',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'status' => {
|
||||
datatype => 'string',
|
||||
base_name => 'status',
|
||||
description => 'pet status in the store',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
});
|
||||
|
||||
__PACKAGE__->openapi_types( {
|
||||
'id' => 'int',
|
||||
'category' => 'Category',
|
||||
'name' => 'string',
|
||||
'photo_urls' => 'ARRAY[string]',
|
||||
'tags' => 'ARRAY[Tag]',
|
||||
'status' => 'string'
|
||||
} );
|
||||
|
||||
__PACKAGE__->attribute_map( {
|
||||
'id' => 'id',
|
||||
'category' => 'category',
|
||||
'name' => 'name',
|
||||
'photo_urls' => 'photoUrls',
|
||||
'tags' => 'tags',
|
||||
'status' => 'status'
|
||||
} );
|
||||
|
||||
__PACKAGE__->mk_accessors(keys %{__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;
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
=begin comment
|
||||
|
||||
OpenAPI Petstore
|
||||
@ -30,9 +31,7 @@ use Log::Any qw($log);
|
||||
use Date::Parse;
|
||||
use DateTime;
|
||||
|
||||
|
||||
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||
|
||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
||||
|
||||
#
|
||||
#
|
||||
@ -60,37 +59,37 @@ Generated by: 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' => {});
|
||||
__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) = @_;
|
||||
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;
|
||||
}
|
||||
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 ));
|
||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
||||
}
|
||||
|
||||
# used by JSON for serialization
|
||||
sub TO_JSON {
|
||||
my $self = shift;
|
||||
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};
|
||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
||||
if ( defined $self->{$_key} ) {
|
||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
||||
}
|
||||
}
|
||||
return $_data;
|
||||
@ -98,78 +97,91 @@ sub TO_JSON {
|
||||
|
||||
# from Perl hashref
|
||||
sub from_hash {
|
||||
my ($self, $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);
|
||||
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);
|
||||
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);
|
||||
}
|
||||
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'))) {
|
||||
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)
|
||||
}
|
||||
else { # hash(model)
|
||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||
return $_instance->from_hash($data);
|
||||
}
|
||||
}
|
||||
|
||||
__PACKAGE__->class_documentation(
|
||||
{
|
||||
description => '',
|
||||
class => 'ReadOnlyFirst',
|
||||
required => [], # TODO
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation(
|
||||
{
|
||||
'bar' => {
|
||||
datatype => 'string',
|
||||
base_name => 'bar',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'baz' => {
|
||||
datatype => 'string',
|
||||
base_name => 'baz',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->class_documentation({description => '',
|
||||
class => 'ReadOnlyFirst',
|
||||
required => [], # TODO
|
||||
} );
|
||||
__PACKAGE__->openapi_types(
|
||||
{
|
||||
'bar' => 'string',
|
||||
'baz' => 'string'
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation({
|
||||
'bar' => {
|
||||
datatype => 'string',
|
||||
base_name => 'bar',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'baz' => {
|
||||
datatype => 'string',
|
||||
base_name => 'baz',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
});
|
||||
|
||||
__PACKAGE__->openapi_types( {
|
||||
'bar' => 'string',
|
||||
'baz' => 'string'
|
||||
} );
|
||||
|
||||
__PACKAGE__->attribute_map( {
|
||||
'bar' => 'bar',
|
||||
'baz' => 'baz'
|
||||
} );
|
||||
|
||||
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
||||
__PACKAGE__->attribute_map(
|
||||
{
|
||||
'bar' => 'bar',
|
||||
'baz' => 'baz'
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
||||
|
||||
1;
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
=begin comment
|
||||
|
||||
OpenAPI Petstore
|
||||
@ -30,9 +31,7 @@ use Log::Any qw($log);
|
||||
use Date::Parse;
|
||||
use DateTime;
|
||||
|
||||
|
||||
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||
|
||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
||||
|
||||
#
|
||||
#
|
||||
@ -60,37 +59,37 @@ Generated by: 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' => {});
|
||||
__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) = @_;
|
||||
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;
|
||||
}
|
||||
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 ));
|
||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
||||
}
|
||||
|
||||
# used by JSON for serialization
|
||||
sub TO_JSON {
|
||||
my $self = shift;
|
||||
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};
|
||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
||||
if ( defined $self->{$_key} ) {
|
||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
||||
}
|
||||
}
|
||||
return $_data;
|
||||
@ -98,69 +97,82 @@ sub TO_JSON {
|
||||
|
||||
# from Perl hashref
|
||||
sub from_hash {
|
||||
my ($self, $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);
|
||||
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);
|
||||
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);
|
||||
}
|
||||
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'))) {
|
||||
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)
|
||||
}
|
||||
else { # hash(model)
|
||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||
return $_instance->from_hash($data);
|
||||
}
|
||||
}
|
||||
|
||||
__PACKAGE__->class_documentation(
|
||||
{
|
||||
description => '',
|
||||
class => 'SpecialModelName',
|
||||
required => [], # TODO
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation(
|
||||
{
|
||||
'__special[property/name]' => {
|
||||
datatype => 'int',
|
||||
base_name => '$special[property.name]',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->class_documentation({description => '',
|
||||
class => 'SpecialModelName',
|
||||
required => [], # TODO
|
||||
} );
|
||||
__PACKAGE__->openapi_types(
|
||||
{
|
||||
'__special[property/name]' => 'int'
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation({
|
||||
'__special[property/name]' => {
|
||||
datatype => 'int',
|
||||
base_name => '$special[property.name]',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
});
|
||||
|
||||
__PACKAGE__->openapi_types( {
|
||||
'__special[property/name]' => 'int'
|
||||
} );
|
||||
|
||||
__PACKAGE__->attribute_map( {
|
||||
'__special[property/name]' => '$special[property.name]'
|
||||
} );
|
||||
|
||||
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
||||
__PACKAGE__->attribute_map(
|
||||
{
|
||||
'__special[property/name]' => '$special[property.name]'
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
||||
|
||||
1;
|
||||
|
@ -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;
|
@ -1,3 +1,4 @@
|
||||
|
||||
=begin comment
|
||||
|
||||
OpenAPI Petstore
|
||||
@ -30,9 +31,7 @@ use Log::Any qw($log);
|
||||
use Date::Parse;
|
||||
use DateTime;
|
||||
|
||||
|
||||
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||
|
||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
||||
|
||||
#
|
||||
#
|
||||
@ -60,37 +59,37 @@ Generated by: 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' => {});
|
||||
__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) = @_;
|
||||
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;
|
||||
}
|
||||
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 ));
|
||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
||||
}
|
||||
|
||||
# used by JSON for serialization
|
||||
sub TO_JSON {
|
||||
my $self = shift;
|
||||
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};
|
||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
||||
if ( defined $self->{$_key} ) {
|
||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
||||
}
|
||||
}
|
||||
return $_data;
|
||||
@ -98,78 +97,91 @@ sub TO_JSON {
|
||||
|
||||
# from Perl hashref
|
||||
sub from_hash {
|
||||
my ($self, $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);
|
||||
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);
|
||||
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);
|
||||
}
|
||||
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'))) {
|
||||
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)
|
||||
}
|
||||
else { # hash(model)
|
||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||
return $_instance->from_hash($data);
|
||||
}
|
||||
}
|
||||
|
||||
__PACKAGE__->class_documentation(
|
||||
{
|
||||
description => '',
|
||||
class => 'Tag',
|
||||
required => [], # TODO
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation(
|
||||
{
|
||||
'id' => {
|
||||
datatype => 'int',
|
||||
base_name => 'id',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'name' => {
|
||||
datatype => 'string',
|
||||
base_name => 'name',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->class_documentation({description => '',
|
||||
class => 'Tag',
|
||||
required => [], # TODO
|
||||
} );
|
||||
__PACKAGE__->openapi_types(
|
||||
{
|
||||
'id' => 'int',
|
||||
'name' => 'string'
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation({
|
||||
'id' => {
|
||||
datatype => 'int',
|
||||
base_name => 'id',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'name' => {
|
||||
datatype => 'string',
|
||||
base_name => 'name',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
});
|
||||
|
||||
__PACKAGE__->openapi_types( {
|
||||
'id' => 'int',
|
||||
'name' => 'string'
|
||||
} );
|
||||
|
||||
__PACKAGE__->attribute_map( {
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
} );
|
||||
|
||||
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
||||
__PACKAGE__->attribute_map(
|
||||
{
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
||||
|
||||
1;
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
=begin comment
|
||||
|
||||
OpenAPI Petstore
|
||||
@ -30,9 +31,7 @@ use Log::Any qw($log);
|
||||
use Date::Parse;
|
||||
use DateTime;
|
||||
|
||||
|
||||
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||
|
||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
||||
|
||||
#
|
||||
#
|
||||
@ -60,37 +59,37 @@ Generated by: 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' => {});
|
||||
__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) = @_;
|
||||
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;
|
||||
}
|
||||
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 ));
|
||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
||||
}
|
||||
|
||||
# used by JSON for serialization
|
||||
sub TO_JSON {
|
||||
my $self = shift;
|
||||
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};
|
||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
||||
if ( defined $self->{$_key} ) {
|
||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
||||
}
|
||||
}
|
||||
return $_data;
|
||||
@ -98,132 +97,145 @@ sub TO_JSON {
|
||||
|
||||
# from Perl hashref
|
||||
sub from_hash {
|
||||
my ($self, $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);
|
||||
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);
|
||||
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);
|
||||
}
|
||||
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'))) {
|
||||
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)
|
||||
}
|
||||
else { # hash(model)
|
||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||
return $_instance->from_hash($data);
|
||||
}
|
||||
}
|
||||
|
||||
__PACKAGE__->class_documentation(
|
||||
{
|
||||
description => '',
|
||||
class => 'User',
|
||||
required => [], # TODO
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation(
|
||||
{
|
||||
'id' => {
|
||||
datatype => 'int',
|
||||
base_name => 'id',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'username' => {
|
||||
datatype => 'string',
|
||||
base_name => 'username',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'first_name' => {
|
||||
datatype => 'string',
|
||||
base_name => 'firstName',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'last_name' => {
|
||||
datatype => 'string',
|
||||
base_name => 'lastName',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'email' => {
|
||||
datatype => 'string',
|
||||
base_name => 'email',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'password' => {
|
||||
datatype => 'string',
|
||||
base_name => 'password',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'phone' => {
|
||||
datatype => 'string',
|
||||
base_name => 'phone',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'user_status' => {
|
||||
datatype => 'int',
|
||||
base_name => 'userStatus',
|
||||
description => 'User Status',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->class_documentation({description => '',
|
||||
class => 'User',
|
||||
required => [], # TODO
|
||||
} );
|
||||
__PACKAGE__->openapi_types(
|
||||
{
|
||||
'id' => 'int',
|
||||
'username' => 'string',
|
||||
'first_name' => 'string',
|
||||
'last_name' => 'string',
|
||||
'email' => 'string',
|
||||
'password' => 'string',
|
||||
'phone' => 'string',
|
||||
'user_status' => 'int'
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->method_documentation({
|
||||
'id' => {
|
||||
datatype => 'int',
|
||||
base_name => 'id',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'username' => {
|
||||
datatype => 'string',
|
||||
base_name => 'username',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'first_name' => {
|
||||
datatype => 'string',
|
||||
base_name => 'firstName',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'last_name' => {
|
||||
datatype => 'string',
|
||||
base_name => 'lastName',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'email' => {
|
||||
datatype => 'string',
|
||||
base_name => 'email',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'password' => {
|
||||
datatype => 'string',
|
||||
base_name => 'password',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'phone' => {
|
||||
datatype => 'string',
|
||||
base_name => 'phone',
|
||||
description => '',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
'user_status' => {
|
||||
datatype => 'int',
|
||||
base_name => 'userStatus',
|
||||
description => 'User Status',
|
||||
format => '',
|
||||
read_only => '',
|
||||
},
|
||||
});
|
||||
|
||||
__PACKAGE__->openapi_types( {
|
||||
'id' => 'int',
|
||||
'username' => 'string',
|
||||
'first_name' => 'string',
|
||||
'last_name' => 'string',
|
||||
'email' => 'string',
|
||||
'password' => 'string',
|
||||
'phone' => 'string',
|
||||
'user_status' => 'int'
|
||||
} );
|
||||
|
||||
__PACKAGE__->attribute_map( {
|
||||
'id' => 'id',
|
||||
'username' => 'username',
|
||||
'first_name' => 'firstName',
|
||||
'last_name' => 'lastName',
|
||||
'email' => 'email',
|
||||
'password' => 'password',
|
||||
'phone' => 'phone',
|
||||
'user_status' => 'userStatus'
|
||||
} );
|
||||
|
||||
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
||||
__PACKAGE__->attribute_map(
|
||||
{
|
||||
'id' => 'id',
|
||||
'username' => 'username',
|
||||
'first_name' => 'firstName',
|
||||
'last_name' => 'lastName',
|
||||
'email' => 'email',
|
||||
'password' => 'password',
|
||||
'phone' => 'phone',
|
||||
'user_status' => 'userStatus'
|
||||
}
|
||||
);
|
||||
|
||||
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
||||
|
||||
1;
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
=begin comment
|
||||
|
||||
OpenAPI Petstore
|
||||
@ -22,7 +23,7 @@ package WWW::OpenAPIClient::PetApi;
|
||||
require 5.6.0;
|
||||
use strict;
|
||||
use warnings;
|
||||
use utf8;
|
||||
use utf8;
|
||||
use Exporter;
|
||||
use Carp qw( croak );
|
||||
use Log::Any qw($log);
|
||||
@ -31,15 +32,16 @@ use WWW::OpenAPIClient::ApiClient;
|
||||
|
||||
use base "Class::Data::Inheritable";
|
||||
|
||||
__PACKAGE__->mk_classdata('method_documentation' => {});
|
||||
__PACKAGE__->mk_classdata( 'method_documentation' => {} );
|
||||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
my $api_client;
|
||||
|
||||
if ($_[0] && ref $_[0] && ref $_[0] eq 'WWW::OpenAPIClient::ApiClient' ) {
|
||||
if ( $_[0] && ref $_[0] && ref $_[0] eq 'WWW::OpenAPIClient::ApiClient' ) {
|
||||
$api_client = $_[0];
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$api_client = WWW::OpenAPIClient::ApiClient->new(@_);
|
||||
}
|
||||
|
||||
@ -47,55 +49,57 @@ sub new {
|
||||
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# add_pet
|
||||
#
|
||||
# Add a new pet to the store
|
||||
#
|
||||
#
|
||||
# @param Pet $pet Pet object that needs to be added to the store (required)
|
||||
{
|
||||
my $params = {
|
||||
'pet' => {
|
||||
data_type => 'Pet',
|
||||
description => 'Pet object that needs to be added to the store',
|
||||
required => '1',
|
||||
},
|
||||
'pet' => {
|
||||
data_type => 'Pet',
|
||||
description => 'Pet object that needs to be added to the store',
|
||||
required => '1',
|
||||
},
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ 'add_pet' } = {
|
||||
summary => 'Add a new pet to the store',
|
||||
params => $params,
|
||||
__PACKAGE__->method_documentation->{'add_pet'} = {
|
||||
summary => 'Add a new pet to the store',
|
||||
params => $params,
|
||||
returns => undef,
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
# @return void
|
||||
#
|
||||
sub add_pet {
|
||||
my ($self, %args) = @_;
|
||||
my ( $self, %args ) = @_;
|
||||
|
||||
# verify the required parameter 'pet' is set
|
||||
unless (exists $args{'pet'}) {
|
||||
croak("Missing the required parameter 'pet' when calling add_pet");
|
||||
unless ( exists $args{'pet'} ) {
|
||||
croak("Missing the required parameter 'pet' when calling add_pet");
|
||||
}
|
||||
|
||||
# parse inputs
|
||||
my $_resource_path = '/pet';
|
||||
|
||||
my $_method = 'POST';
|
||||
my $query_params = {};
|
||||
my $_method = 'POST';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_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', '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'}) {
|
||||
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;
|
||||
}
|
||||
|
||||
@ -113,73 +118,79 @@ sub add_pet {
|
||||
# delete_pet
|
||||
#
|
||||
# Deletes a pet
|
||||
#
|
||||
#
|
||||
# @param int $pet_id Pet id to delete (required)
|
||||
# @param string $api_key (optional)
|
||||
{
|
||||
my $params = {
|
||||
'pet_id' => {
|
||||
data_type => 'int',
|
||||
description => 'Pet id to delete',
|
||||
required => '1',
|
||||
},
|
||||
'api_key' => {
|
||||
data_type => 'string',
|
||||
description => '',
|
||||
required => '0',
|
||||
},
|
||||
'pet_id' => {
|
||||
data_type => 'int',
|
||||
description => 'Pet id to delete',
|
||||
required => '1',
|
||||
},
|
||||
'api_key' => {
|
||||
data_type => 'string',
|
||||
description => '',
|
||||
required => '0',
|
||||
},
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ 'delete_pet' } = {
|
||||
summary => 'Deletes a pet',
|
||||
params => $params,
|
||||
__PACKAGE__->method_documentation->{'delete_pet'} = {
|
||||
summary => 'Deletes a pet',
|
||||
params => $params,
|
||||
returns => undef,
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
# @return void
|
||||
#
|
||||
sub delete_pet {
|
||||
my ($self, %args) = @_;
|
||||
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 delete_pet");
|
||||
unless ( exists $args{'pet_id'} ) {
|
||||
croak(
|
||||
"Missing the required parameter 'pet_id' when calling delete_pet");
|
||||
}
|
||||
|
||||
# parse inputs
|
||||
my $_resource_path = '/pet/{petId}';
|
||||
|
||||
my $_method = 'DELETE';
|
||||
my $query_params = {};
|
||||
my $_method = 'DELETE';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_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();
|
||||
$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'});
|
||||
if ( exists $args{'api_key'} ) {
|
||||
$header_params->{'api_key'} =
|
||||
$self->{api_client}->to_header_value( $args{'api_key'} );
|
||||
}
|
||||
|
||||
# path params
|
||||
if ( exists $args{'pet_id'}) {
|
||||
if ( exists $args{'pet_id'} ) {
|
||||
my $_base_variable = "{" . "petId" . "}";
|
||||
my $_base_value = $self->{api_client}->to_path_value($args{'pet_id'});
|
||||
my $_base_value = $self->{api_client}->to_path_value( $args{'pet_id'} );
|
||||
$_resource_path =~ s/$_base_variable/$_base_value/g;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -187,64 +198,74 @@ sub delete_pet {
|
||||
# find_pets_by_status
|
||||
#
|
||||
# Finds Pets by status
|
||||
#
|
||||
#
|
||||
# @param ARRAY[string] $status Status values that need to be considered for filter (required)
|
||||
{
|
||||
my $params = {
|
||||
'status' => {
|
||||
data_type => 'ARRAY[string]',
|
||||
description => 'Status values that need to be considered for filter',
|
||||
required => '1',
|
||||
},
|
||||
'status' => {
|
||||
data_type => 'ARRAY[string]',
|
||||
description =>
|
||||
'Status values that need to be considered for filter',
|
||||
required => '1',
|
||||
},
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ 'find_pets_by_status' } = {
|
||||
summary => 'Finds Pets by status',
|
||||
params => $params,
|
||||
__PACKAGE__->method_documentation->{'find_pets_by_status'} = {
|
||||
summary => 'Finds Pets by status',
|
||||
params => $params,
|
||||
returns => 'ARRAY[Pet]',
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
# @return ARRAY[Pet]
|
||||
#
|
||||
sub find_pets_by_status {
|
||||
my ($self, %args) = @_;
|
||||
my ( $self, %args ) = @_;
|
||||
|
||||
# verify the required parameter 'status' is set
|
||||
unless (exists $args{'status'}) {
|
||||
croak("Missing the required parameter 'status' when calling find_pets_by_status");
|
||||
unless ( exists $args{'status'} ) {
|
||||
croak(
|
||||
"Missing the required parameter 'status' when calling find_pets_by_status"
|
||||
);
|
||||
}
|
||||
|
||||
# parse inputs
|
||||
my $_resource_path = '/pet/findByStatus';
|
||||
|
||||
my $_method = 'GET';
|
||||
my $query_params = {};
|
||||
my $_method = 'GET';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
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'});
|
||||
if ( exists $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);
|
||||
if (!$response) {
|
||||
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;
|
||||
}
|
||||
|
||||
@ -252,64 +273,73 @@ sub find_pets_by_status {
|
||||
# find_pets_by_tags
|
||||
#
|
||||
# Finds Pets by tags
|
||||
#
|
||||
#
|
||||
# @param ARRAY[string] $tags Tags to filter by (required)
|
||||
{
|
||||
my $params = {
|
||||
'tags' => {
|
||||
data_type => 'ARRAY[string]',
|
||||
description => 'Tags to filter by',
|
||||
required => '1',
|
||||
},
|
||||
'tags' => {
|
||||
data_type => 'ARRAY[string]',
|
||||
description => 'Tags to filter by',
|
||||
required => '1',
|
||||
},
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ 'find_pets_by_tags' } = {
|
||||
summary => 'Finds Pets by tags',
|
||||
params => $params,
|
||||
__PACKAGE__->method_documentation->{'find_pets_by_tags'} = {
|
||||
summary => 'Finds Pets by tags',
|
||||
params => $params,
|
||||
returns => 'ARRAY[Pet]',
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
# @return ARRAY[Pet]
|
||||
#
|
||||
sub find_pets_by_tags {
|
||||
my ($self, %args) = @_;
|
||||
my ( $self, %args ) = @_;
|
||||
|
||||
# verify the required parameter 'tags' is set
|
||||
unless (exists $args{'tags'}) {
|
||||
croak("Missing the required parameter 'tags' when calling find_pets_by_tags");
|
||||
unless ( exists $args{'tags'} ) {
|
||||
croak(
|
||||
"Missing the required parameter 'tags' when calling find_pets_by_tags"
|
||||
);
|
||||
}
|
||||
|
||||
# parse inputs
|
||||
my $_resource_path = '/pet/findByTags';
|
||||
|
||||
my $_method = 'GET';
|
||||
my $query_params = {};
|
||||
my $_method = 'GET';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
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'});
|
||||
if ( exists $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);
|
||||
if (!$response) {
|
||||
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;
|
||||
}
|
||||
|
||||
@ -317,66 +347,73 @@ sub find_pets_by_tags {
|
||||
# get_pet_by_id
|
||||
#
|
||||
# Find pet by ID
|
||||
#
|
||||
#
|
||||
# @param int $pet_id ID of pet to return (required)
|
||||
{
|
||||
my $params = {
|
||||
'pet_id' => {
|
||||
data_type => 'int',
|
||||
description => 'ID of pet to return',
|
||||
required => '1',
|
||||
},
|
||||
'pet_id' => {
|
||||
data_type => 'int',
|
||||
description => 'ID of pet to return',
|
||||
required => '1',
|
||||
},
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ 'get_pet_by_id' } = {
|
||||
summary => 'Find pet by ID',
|
||||
params => $params,
|
||||
__PACKAGE__->method_documentation->{'get_pet_by_id'} = {
|
||||
summary => 'Find pet by ID',
|
||||
params => $params,
|
||||
returns => 'Pet',
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
# @return Pet
|
||||
#
|
||||
sub get_pet_by_id {
|
||||
my ($self, %args) = @_;
|
||||
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 get_pet_by_id");
|
||||
unless ( exists $args{'pet_id'} ) {
|
||||
croak(
|
||||
"Missing the required parameter 'pet_id' when calling get_pet_by_id"
|
||||
);
|
||||
}
|
||||
|
||||
# parse inputs
|
||||
my $_resource_path = '/pet/{petId}';
|
||||
|
||||
my $_method = 'GET';
|
||||
my $query_params = {};
|
||||
my $_method = 'GET';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
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'}) {
|
||||
if ( exists $args{'pet_id'} ) {
|
||||
my $_base_variable = "{" . "petId" . "}";
|
||||
my $_base_value = $self->{api_client}->to_path_value($args{'pet_id'});
|
||||
my $_base_value = $self->{api_client}->to_path_value( $args{'pet_id'} );
|
||||
$_resource_path =~ s/$_base_variable/$_base_value/g;
|
||||
}
|
||||
|
||||
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);
|
||||
if (!$response) {
|
||||
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('Pet', $response);
|
||||
my $_response_object = $self->{api_client}->deserialize( 'Pet', $response );
|
||||
return $_response_object;
|
||||
}
|
||||
|
||||
@ -384,50 +421,53 @@ sub get_pet_by_id {
|
||||
# update_pet
|
||||
#
|
||||
# Update an existing pet
|
||||
#
|
||||
#
|
||||
# @param Pet $pet Pet object that needs to be added to the store (required)
|
||||
{
|
||||
my $params = {
|
||||
'pet' => {
|
||||
data_type => 'Pet',
|
||||
description => 'Pet object that needs to be added to the store',
|
||||
required => '1',
|
||||
},
|
||||
'pet' => {
|
||||
data_type => 'Pet',
|
||||
description => 'Pet object that needs to be added to the store',
|
||||
required => '1',
|
||||
},
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ 'update_pet' } = {
|
||||
summary => 'Update an existing pet',
|
||||
params => $params,
|
||||
__PACKAGE__->method_documentation->{'update_pet'} = {
|
||||
summary => 'Update an existing pet',
|
||||
params => $params,
|
||||
returns => undef,
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
# @return void
|
||||
#
|
||||
sub update_pet {
|
||||
my ($self, %args) = @_;
|
||||
my ( $self, %args ) = @_;
|
||||
|
||||
# verify the required parameter 'pet' is set
|
||||
unless (exists $args{'pet'}) {
|
||||
croak("Missing the required parameter 'pet' when calling update_pet");
|
||||
unless ( exists $args{'pet'} ) {
|
||||
croak("Missing the required parameter 'pet' when calling update_pet");
|
||||
}
|
||||
|
||||
# parse inputs
|
||||
my $_resource_path = '/pet';
|
||||
|
||||
my $_method = 'PUT';
|
||||
my $query_params = {};
|
||||
my $_method = 'PUT';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_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', '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'}) {
|
||||
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;
|
||||
}
|
||||
|
||||
@ -445,84 +486,92 @@ sub update_pet {
|
||||
# update_pet_with_form
|
||||
#
|
||||
# Updates a pet in the store with form data
|
||||
#
|
||||
#
|
||||
# @param int $pet_id ID of pet that needs to be updated (required)
|
||||
# @param string $name Updated name of the pet (optional)
|
||||
# @param string $status Updated status of the pet (optional)
|
||||
{
|
||||
my $params = {
|
||||
'pet_id' => {
|
||||
data_type => 'int',
|
||||
description => 'ID of pet that needs to be updated',
|
||||
required => '1',
|
||||
},
|
||||
'name' => {
|
||||
data_type => 'string',
|
||||
description => 'Updated name of the pet',
|
||||
required => '0',
|
||||
},
|
||||
'status' => {
|
||||
data_type => 'string',
|
||||
description => 'Updated status of the pet',
|
||||
required => '0',
|
||||
},
|
||||
'pet_id' => {
|
||||
data_type => 'int',
|
||||
description => 'ID of pet that needs to be updated',
|
||||
required => '1',
|
||||
},
|
||||
'name' => {
|
||||
data_type => 'string',
|
||||
description => 'Updated name of the pet',
|
||||
required => '0',
|
||||
},
|
||||
'status' => {
|
||||
data_type => 'string',
|
||||
description => 'Updated status of the pet',
|
||||
required => '0',
|
||||
},
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ 'update_pet_with_form' } = {
|
||||
summary => 'Updates a pet in the store with form data',
|
||||
params => $params,
|
||||
__PACKAGE__->method_documentation->{'update_pet_with_form'} = {
|
||||
summary => 'Updates a pet in the store with form data',
|
||||
params => $params,
|
||||
returns => undef,
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
# @return void
|
||||
#
|
||||
sub update_pet_with_form {
|
||||
my ($self, %args) = @_;
|
||||
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 update_pet_with_form");
|
||||
unless ( exists $args{'pet_id'} ) {
|
||||
croak(
|
||||
"Missing the required parameter 'pet_id' when calling update_pet_with_form"
|
||||
);
|
||||
}
|
||||
|
||||
# parse inputs
|
||||
my $_resource_path = '/pet/{petId}';
|
||||
|
||||
my $_method = 'POST';
|
||||
my $query_params = {};
|
||||
my $_method = 'POST';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_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/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'}) {
|
||||
if ( exists $args{'pet_id'} ) {
|
||||
my $_base_variable = "{" . "petId" . "}";
|
||||
my $_base_value = $self->{api_client}->to_path_value($args{'pet_id'});
|
||||
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{'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;
|
||||
}
|
||||
|
||||
@ -530,89 +579,204 @@ sub update_pet_with_form {
|
||||
# upload_file
|
||||
#
|
||||
# uploads an image
|
||||
#
|
||||
#
|
||||
# @param int $pet_id ID of pet to update (required)
|
||||
# @param string $additional_metadata Additional data to pass to server (optional)
|
||||
# @param string $file file to upload (optional)
|
||||
{
|
||||
my $params = {
|
||||
'pet_id' => {
|
||||
data_type => 'int',
|
||||
description => 'ID of pet to update',
|
||||
required => '1',
|
||||
},
|
||||
'additional_metadata' => {
|
||||
data_type => 'string',
|
||||
description => 'Additional data to pass to server',
|
||||
required => '0',
|
||||
},
|
||||
'file' => {
|
||||
data_type => 'string',
|
||||
description => 'file to upload',
|
||||
required => '0',
|
||||
},
|
||||
'pet_id' => {
|
||||
data_type => 'int',
|
||||
description => 'ID of pet to update',
|
||||
required => '1',
|
||||
},
|
||||
'additional_metadata' => {
|
||||
data_type => 'string',
|
||||
description => 'Additional data to pass to server',
|
||||
required => '0',
|
||||
},
|
||||
'file' => {
|
||||
data_type => 'string',
|
||||
description => 'file to upload',
|
||||
required => '0',
|
||||
},
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ 'upload_file' } = {
|
||||
summary => 'uploads an image',
|
||||
params => $params,
|
||||
__PACKAGE__->method_documentation->{'upload_file'} = {
|
||||
summary => 'uploads an image',
|
||||
params => $params,
|
||||
returns => 'ApiResponse',
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
# @return ApiResponse
|
||||
#
|
||||
sub upload_file {
|
||||
my ($self, %args) = @_;
|
||||
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");
|
||||
unless ( exists $args{'pet_id'} ) {
|
||||
croak(
|
||||
"Missing the required parameter 'pet_id' when calling upload_file");
|
||||
}
|
||||
|
||||
# parse inputs
|
||||
my $_resource_path = '/pet/{petId}/uploadImage';
|
||||
|
||||
my $_method = 'POST';
|
||||
my $query_params = {};
|
||||
my $_method = 'POST';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
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'}) {
|
||||
if ( exists $args{'pet_id'} ) {
|
||||
my $_base_variable = "{" . "petId" . "}";
|
||||
my $_base_value = $self->{api_client}->to_path_value($args{'pet_id'});
|
||||
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->{'additionalMetadata'} =
|
||||
$self->{api_client}->to_form_value( $args{'additional_metadata'} );
|
||||
}
|
||||
|
||||
|
||||
# form params
|
||||
if ( exists $args{'file'} ) {
|
||||
$form_params->{'file'} = [] unless defined $form_params->{'file'};
|
||||
push @{$form_params->{'file'}}, $args{'file'};
|
||||
}
|
||||
|
||||
push @{ $form_params->{'file'} }, $args{'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) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
=begin comment
|
||||
|
||||
OpenAPI Petstore
|
||||
@ -26,87 +27,108 @@ use Class::Inspector;
|
||||
use Log::Any qw($log);
|
||||
use WWW::OpenAPIClient::ApiFactory;
|
||||
|
||||
has base_url => ( is => 'ro',
|
||||
required => 0,
|
||||
isa => 'Str',
|
||||
documentation => 'Root of the server that requests are sent to',
|
||||
);
|
||||
has base_url => (
|
||||
is => 'ro',
|
||||
required => 0,
|
||||
isa => 'Str',
|
||||
documentation => 'Root of the server that requests are sent to',
|
||||
);
|
||||
|
||||
has api_factory => ( is => 'ro',
|
||||
isa => 'WWW::OpenAPIClient::ApiFactory',
|
||||
builder => '_build_af',
|
||||
lazy => 1,
|
||||
documentation => 'Builds an instance of the endpoint API class',
|
||||
);
|
||||
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',
|
||||
isa => 'HashRef',
|
||||
required => 0,
|
||||
default => sub { {} },
|
||||
documentation => 'The auth tokens required by the application - basic, OAuth and/or API key(s)',
|
||||
);
|
||||
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)',
|
||||
);
|
||||
|
||||
has _cfg => ( is => 'ro',
|
||||
isa => 'WWW::OpenAPIClient::Configuration',
|
||||
default => sub { WWW::OpenAPIClient::Configuration->new() },
|
||||
);
|
||||
has _cfg => (
|
||||
is => 'ro',
|
||||
isa => 'WWW::OpenAPIClient::Configuration',
|
||||
default => sub { WWW::OpenAPIClient::Configuration->new() },
|
||||
);
|
||||
|
||||
has version_info => ( is => 'ro',
|
||||
isa => 'HashRef',
|
||||
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'
|
||||
);
|
||||
has version_info => (
|
||||
is => 'ro',
|
||||
isa => 'HashRef',
|
||||
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'
|
||||
);
|
||||
|
||||
sub BUILD {
|
||||
my $self = shift;
|
||||
my $self = shift;
|
||||
|
||||
$self->_cfg->accept_tokens( $self->tokens ) if keys %{$self->tokens};
|
||||
$self->_cfg->accept_tokens( $self->tokens ) if keys %{ $self->tokens };
|
||||
|
||||
# ignore these symbols imported into API namespaces
|
||||
my %outsiders = map {$_ => 1} qw( croak );
|
||||
# ignore these symbols imported into API namespaces
|
||||
my %outsiders = map { $_ => 1 } qw( croak );
|
||||
|
||||
my %delegates;
|
||||
my %delegates;
|
||||
|
||||
# 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;
|
||||
}
|
||||
# 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;
|
||||
}
|
||||
|
||||
# remove clashes
|
||||
foreach my $method (keys %delegates) {
|
||||
if ( @{$delegates{$method}} > 1 ) {
|
||||
my ($apis) = delete $delegates{$method};
|
||||
}
|
||||
}
|
||||
# remove clashes
|
||||
foreach my $method ( keys %delegates ) {
|
||||
if ( @{ $delegates{$method} } > 1 ) {
|
||||
my ($apis) = delete $delegates{$method};
|
||||
}
|
||||
}
|
||||
|
||||
# build the flattened API
|
||||
foreach my $api_name ($self->api_factory->apis_available) {
|
||||
foreach my $api_name ( $self->api_factory->apis_available ) {
|
||||
my $att_name = sprintf "%s_api", lc($api_name);
|
||||
my $api_class = $self->api_factory->classname_for($api_name);
|
||||
my @delegated = grep { $delegates{$_}->[0]->{api_name} eq $api_name } keys %delegates;
|
||||
$log->debugf("Adding API: '%s' handles %s", $att_name, join ', ', @delegated);
|
||||
$self->meta->add_attribute( $att_name => (
|
||||
is => 'ro',
|
||||
isa => $api_class,
|
||||
default => sub {$self->api_factory->get_api($api_name)},
|
||||
lazy => 1,
|
||||
handles => \@delegated,
|
||||
) );
|
||||
my @delegated =
|
||||
grep { $delegates{$_}->[0]->{api_name} eq $api_name } keys %delegates;
|
||||
$log->debugf( "Adding API: '%s' handles %s",
|
||||
$att_name, join ', ', @delegated );
|
||||
$self->meta->add_attribute(
|
||||
$att_name => (
|
||||
is => 'ro',
|
||||
isa => $api_class,
|
||||
default => sub { $self->api_factory->get_api($api_name) },
|
||||
lazy => 1,
|
||||
handles => \@delegated,
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
sub _build_af {
|
||||
my $self = shift;
|
||||
my %args;
|
||||
$args{base_url} = $self->base_url if $self->base_url;
|
||||
return WWW::OpenAPIClient::ApiFactory->new(%args);
|
||||
my $self = shift;
|
||||
my %args;
|
||||
$args{base_url} = $self->base_url if $self->base_url;
|
||||
return WWW::OpenAPIClient::ApiFactory->new(%args);
|
||||
}
|
||||
|
||||
=head1 NAME
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
=begin comment
|
||||
|
||||
OpenAPI Petstore
|
||||
@ -23,56 +24,57 @@ use List::MoreUtils qw(uniq);
|
||||
use Moose::Role;
|
||||
|
||||
sub autodoc {
|
||||
my ($self, $how) = @_;
|
||||
|
||||
die "Unknown format '$how'" unless $how =~ /^(pod|wide|narrow)$/;
|
||||
|
||||
$self->_printisa($how);
|
||||
$self->_printmethods($how);
|
||||
$self->_printattrs($how);
|
||||
print "\n";
|
||||
my ( $self, $how ) = @_;
|
||||
|
||||
die "Unknown format '$how'" unless $how =~ /^(pod|wide|narrow)$/;
|
||||
|
||||
$self->_printisa($how);
|
||||
$self->_printmethods($how);
|
||||
$self->_printattrs($how);
|
||||
print "\n";
|
||||
}
|
||||
|
||||
sub _printisa {
|
||||
my ($self, $how) = @_;
|
||||
my $meta = $self->meta;
|
||||
|
||||
my $myclass = ref $self;
|
||||
|
||||
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 ( $self, $how ) = @_;
|
||||
my $meta = $self->meta;
|
||||
|
||||
my $isa = join ', ', grep {$_ ne $myclass} $meta->linearized_isa;
|
||||
my $sub = join ', ', $meta->subclasses;
|
||||
my $dsub = join ', ', $meta->direct_subclasses;
|
||||
|
||||
my $app_name = $self->version_info->{app_name};
|
||||
my $app_version = $self->version_info->{app_version};
|
||||
my $generated_date = $self->version_info->{generated_date};
|
||||
my $myclass = ref $self;
|
||||
|
||||
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;
|
||||
my $sub = join ', ', $meta->subclasses;
|
||||
my $dsub = join ', ', $meta->direct_subclasses;
|
||||
|
||||
my $app_name = $self->version_info->{app_name};
|
||||
my $app_version = $self->version_info->{app_version};
|
||||
my $generated_date = $self->version_info->{generated_date};
|
||||
my $generator_class = $self->version_info->{generator_class};
|
||||
|
||||
$~ = $how eq 'pod' ? 'INHERIT_POD' : 'INHERIT';
|
||||
write;
|
||||
|
||||
my ($rolepkg, $role_reqs);
|
||||
|
||||
foreach my $role (@roles) {
|
||||
$rolepkg = $role->{package} || next; # some are anonymous, or something
|
||||
next if $rolepkg eq 'WWW::OpenAPIClient::Role::AutoDoc';
|
||||
$role_reqs = join ', ', keys %{$role->{required_methods}};
|
||||
$role_reqs ||= '';
|
||||
$~ = $how eq 'pod' ? 'ROLES_POD' : 'ROLES';
|
||||
write;
|
||||
}
|
||||
|
||||
if ($how eq 'pod') {
|
||||
$~ = 'ROLES_POD_CLOSE';
|
||||
write;
|
||||
}
|
||||
|
||||
# ----- format specs -----
|
||||
format INHERIT =
|
||||
|
||||
my ( $rolepkg, $role_reqs );
|
||||
|
||||
foreach my $role (@roles) {
|
||||
$rolepkg = $role->{package} || next; # some are anonymous, or something
|
||||
next if $rolepkg eq 'WWW::OpenAPIClient::Role::AutoDoc';
|
||||
$role_reqs = join ', ', keys %{ $role->{required_methods} };
|
||||
$role_reqs ||= '';
|
||||
$~ = $how eq 'pod' ? 'ROLES_POD' : 'ROLES';
|
||||
write;
|
||||
}
|
||||
|
||||
if ( $how eq 'pod' ) {
|
||||
$~ = 'ROLES_POD_CLOSE';
|
||||
write;
|
||||
}
|
||||
|
||||
# ----- format specs -----
|
||||
format INHERIT =
|
||||
|
||||
@* -
|
||||
$myclass
|
||||
@ -91,7 +93,7 @@ $myclass
|
||||
$generator_class
|
||||
|
||||
.
|
||||
format ROLES =
|
||||
format ROLES =
|
||||
Composes: ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ~
|
||||
$rolepkg
|
||||
requires: ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ~
|
||||
@ -100,7 +102,7 @@ $myclass
|
||||
$role_reqs
|
||||
.
|
||||
|
||||
format INHERIT_POD =
|
||||
format INHERIT_POD =
|
||||
=head1 NAME
|
||||
|
||||
@*
|
||||
@ -151,7 +153,7 @@ $myclass
|
||||
|
||||
|
||||
.
|
||||
format ROLES_POD =
|
||||
format ROLES_POD =
|
||||
=head2 C<@*>
|
||||
$rolepkg
|
||||
|
||||
@ -161,104 +163,108 @@ Requires:
|
||||
$role_reqs
|
||||
|
||||
.
|
||||
format ROLES_POD_CLOSE =
|
||||
format ROLES_POD_CLOSE =
|
||||
|
||||
|
||||
.
|
||||
# ----- / format specs -----
|
||||
|
||||
# ----- / format specs -----
|
||||
}
|
||||
|
||||
sub _printmethods {
|
||||
my ($self, $how) = @_;
|
||||
|
||||
if ($how eq 'narrow') {
|
||||
print <<HEAD;
|
||||
my ( $self, $how ) = @_;
|
||||
|
||||
if ( $how eq 'narrow' ) {
|
||||
print <<HEAD;
|
||||
METHODS
|
||||
-------
|
||||
HEAD
|
||||
}
|
||||
elsif ($how eq 'wide') {
|
||||
$~ = 'METHODHEAD';
|
||||
write;
|
||||
}
|
||||
elsif ($how eq 'pod') {
|
||||
$~ = 'METHODHEAD_POD';
|
||||
write;
|
||||
}
|
||||
else {
|
||||
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,
|
||||
|
||||
if ($how eq 'pod') {
|
||||
$~ = 'METHOD_POD_CLOSE';
|
||||
write;
|
||||
}
|
||||
}
|
||||
elsif ( $how eq 'wide' ) {
|
||||
$~ = 'METHODHEAD';
|
||||
write;
|
||||
}
|
||||
elsif ( $how eq 'pod' ) {
|
||||
$~ = 'METHODHEAD_POD';
|
||||
write;
|
||||
}
|
||||
else {
|
||||
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,
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
return if $method->original_package_name eq __PACKAGE__;
|
||||
|
||||
my $delegate_to = '';
|
||||
my $via = '';
|
||||
my $on = '';
|
||||
my $doc = '';
|
||||
my $original_pkg = $method->original_package_name;
|
||||
if ($method->can('associated_attribute')) {
|
||||
$delegate_to = $method->delegate_to_method;
|
||||
my $aa = $method->associated_attribute;
|
||||
$on = $aa->{isa};
|
||||
$via = $aa->{name};
|
||||
$original_pkg = $on;
|
||||
$doc = $original_pkg->method_documentation->{$delegate_to}->{summary};
|
||||
}
|
||||
else {
|
||||
$doc = $method->documentation;
|
||||
}
|
||||
|
||||
if ($how eq 'narrow') {
|
||||
$~ = 'METHOD_NARROW';
|
||||
write;
|
||||
}
|
||||
elsif ($how eq 'pod' and $delegate_to) {
|
||||
$~ = 'METHOD_POD_DELEGATED';
|
||||
write;
|
||||
}
|
||||
elsif ($how eq 'pod') {
|
||||
$~ = 'METHOD_POD';
|
||||
write;
|
||||
}
|
||||
else {
|
||||
$~ = 'METHOD';
|
||||
write;
|
||||
}
|
||||
|
||||
# ----- format specs -----
|
||||
format METHODHEAD =
|
||||
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
|
||||
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
|
||||
|
||||
return if $method->original_package_name eq __PACKAGE__;
|
||||
|
||||
my $delegate_to = '';
|
||||
my $via = '';
|
||||
my $on = '';
|
||||
my $doc = '';
|
||||
my $original_pkg = $method->original_package_name;
|
||||
if ( $method->can('associated_attribute') ) {
|
||||
$delegate_to = $method->delegate_to_method;
|
||||
my $aa = $method->associated_attribute;
|
||||
$on = $aa->{isa};
|
||||
$via = $aa->{name};
|
||||
$original_pkg = $on;
|
||||
$doc = $original_pkg->method_documentation->{$delegate_to}->{summary};
|
||||
}
|
||||
else {
|
||||
$doc = $method->documentation;
|
||||
}
|
||||
|
||||
if ( $how eq 'narrow' ) {
|
||||
$~ = 'METHOD_NARROW';
|
||||
write;
|
||||
}
|
||||
elsif ( $how eq 'pod' and $delegate_to ) {
|
||||
$~ = 'METHOD_POD_DELEGATED';
|
||||
write;
|
||||
}
|
||||
elsif ( $how eq 'pod' ) {
|
||||
$~ = 'METHOD_POD';
|
||||
write;
|
||||
}
|
||||
else {
|
||||
$~ = 'METHOD';
|
||||
write;
|
||||
}
|
||||
|
||||
# ----- format specs -----
|
||||
format METHODHEAD =
|
||||
|
||||
METHODS
|
||||
-------
|
||||
Name delegates to on via
|
||||
===========================================================================================================================================================================
|
||||
.
|
||||
format METHOD =
|
||||
format METHOD =
|
||||
@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<... @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<... @<<<<<<<<<<<<<<<<...
|
||||
$methodname, $delegate_to, $on, $via
|
||||
.
|
||||
|
||||
format METHOD_NARROW =
|
||||
format METHOD_NARROW =
|
||||
@*
|
||||
$methodname
|
||||
original pkg: @*
|
||||
@ -272,13 +278,13 @@ $methodname
|
||||
|
||||
.
|
||||
|
||||
format METHODHEAD_POD =
|
||||
format METHODHEAD_POD =
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
.
|
||||
|
||||
format METHOD_POD =
|
||||
|
||||
format METHOD_POD =
|
||||
|
||||
=head2 C<@*()>
|
||||
$methodname
|
||||
@ -288,7 +294,7 @@ $methodname
|
||||
|
||||
|
||||
.
|
||||
format METHOD_POD_DELEGATED =
|
||||
format METHOD_POD_DELEGATED =
|
||||
|
||||
=head2 C<@*()>
|
||||
$methodname
|
||||
@ -307,90 +313,96 @@ $methodname
|
||||
$via, $delegate_to
|
||||
|
||||
.
|
||||
format METHOD_POD_CLOSE =
|
||||
format METHOD_POD_CLOSE =
|
||||
|
||||
.
|
||||
# ----- / format specs -----
|
||||
|
||||
# ----- / format specs -----
|
||||
}
|
||||
|
||||
sub _printattrs {
|
||||
my ($self, $how) = @_;
|
||||
|
||||
if ($how eq 'narrow') {
|
||||
print <<HEAD;
|
||||
my ( $self, $how ) = @_;
|
||||
|
||||
if ( $how eq 'narrow' ) {
|
||||
print <<HEAD;
|
||||
ATTRIBUTES
|
||||
----------
|
||||
HEAD
|
||||
}
|
||||
elsif ($how eq 'wide') {
|
||||
$~ = 'ATTRHEAD';
|
||||
write;
|
||||
}
|
||||
elsif ($how eq 'pod') {
|
||||
$~ = 'ATTRHEAD_POD';
|
||||
write;
|
||||
}
|
||||
else {
|
||||
die "Don't know how to print attributes '$how'";
|
||||
}
|
||||
|
||||
$self->_printattr($_, $how) for sort $self->meta->get_attribute_list;
|
||||
|
||||
if ($how eq 'pod') {
|
||||
$~ = 'ATTR_POD_CLOSE';
|
||||
write;
|
||||
}
|
||||
}
|
||||
elsif ( $how eq 'wide' ) {
|
||||
$~ = 'ATTRHEAD';
|
||||
write;
|
||||
}
|
||||
elsif ( $how eq 'pod' ) {
|
||||
$~ = 'ATTRHEAD_POD';
|
||||
write;
|
||||
}
|
||||
else {
|
||||
die "Don't know how to print attributes '$how'";
|
||||
}
|
||||
|
||||
$self->_printattr( $_, $how ) for sort $self->meta->get_attribute_list;
|
||||
|
||||
if ( $how eq 'pod' ) {
|
||||
$~ = 'ATTR_POD_CLOSE';
|
||||
write;
|
||||
}
|
||||
}
|
||||
|
||||
sub _printattr {
|
||||
my ($self, $attrname, $how) = @_;
|
||||
return if $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;
|
||||
$is = 'ro' if $attr->get_read_method && ! $attr->get_write_method;
|
||||
$is = 'wo' if $attr->get_write_method && ! $attr->get_read_method;
|
||||
$is = '--' if ! $attr->get_write_method && ! $attr->get_read_method;
|
||||
$is or die "No \$is for $attrname";
|
||||
|
||||
my $tc = $attr->type_constraint || '';
|
||||
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 $doc = $attr->documentation || '';
|
||||
my $handles = join ', ', sort @{$attr->handles || []};
|
||||
$handles ||= '';
|
||||
|
||||
if ($how eq 'narrow') {
|
||||
$~ = 'ATTR_NARROW';
|
||||
}
|
||||
elsif ($how eq 'pod') {
|
||||
$~ = 'ATTR_POD';
|
||||
}
|
||||
else {
|
||||
$~ = 'ATTR';
|
||||
}
|
||||
my ( $self, $attrname, $how ) = @_;
|
||||
return if $attrname =~ /^_/;
|
||||
my $attr = $self->meta->get_attribute($attrname)
|
||||
or die "No attr for $attrname";
|
||||
|
||||
write;
|
||||
my $is;
|
||||
$is = 'rw' if $attr->get_read_method && $attr->get_write_method;
|
||||
$is = 'ro' if $attr->get_read_method && !$attr->get_write_method;
|
||||
$is = 'wo' if $attr->get_write_method && !$attr->get_read_method;
|
||||
$is = '--' if !$attr->get_write_method && !$attr->get_read_method;
|
||||
$is or die "No \$is for $attrname";
|
||||
|
||||
# ----- format specs -----
|
||||
format ATTRHEAD =
|
||||
my $tc = $attr->type_constraint || '';
|
||||
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 $doc = $attr->documentation || '';
|
||||
my $handles = join ', ', sort @{ $attr->handles || [] };
|
||||
$handles ||= '';
|
||||
|
||||
if ( $how eq 'narrow' ) {
|
||||
$~ = 'ATTR_NARROW';
|
||||
}
|
||||
elsif ( $how eq 'pod' ) {
|
||||
$~ = 'ATTR_POD';
|
||||
}
|
||||
else {
|
||||
$~ = 'ATTR';
|
||||
}
|
||||
|
||||
write;
|
||||
|
||||
# ----- format specs -----
|
||||
format ATTRHEAD =
|
||||
|
||||
ATTRIBUTES
|
||||
----------
|
||||
Name is isa reqd lazy doc handles
|
||||
==============================================================================================================
|
||||
.
|
||||
format ATTR =
|
||||
format ATTR =
|
||||
@<<<<<<<<<<<<<<<<< @< @<<<<<<<<<<<<<<<<<<<<<<<< @<<< @<<< @<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
||||
$attrname, $is, $tc, $reqd, $lazy, $has_doc, $handles
|
||||
^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ~~
|
||||
$handles
|
||||
.
|
||||
|
||||
format ATTR_NARROW =
|
||||
format ATTR_NARROW =
|
||||
@*
|
||||
$attrname
|
||||
is: @*
|
||||
@ -409,11 +421,11 @@ $attrname
|
||||
$handles
|
||||
|
||||
.
|
||||
format ATTRHEAD_POD =
|
||||
format ATTRHEAD_POD =
|
||||
=head1 ATTRIBUTES
|
||||
|
||||
.
|
||||
format ATTR_POD =
|
||||
format ATTR_POD =
|
||||
|
||||
=head2 C<@*>
|
||||
$attrname
|
||||
@ -434,13 +446,12 @@ $attrname
|
||||
$handles
|
||||
|
||||
.
|
||||
format ATTR_POD_CLOSE =
|
||||
format ATTR_POD_CLOSE =
|
||||
|
||||
|
||||
.
|
||||
# ----- / format specs -----
|
||||
|
||||
# ----- / format specs -----
|
||||
}
|
||||
|
||||
|
||||
|
||||
1;
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
=begin comment
|
||||
|
||||
OpenAPI Petstore
|
||||
@ -22,7 +23,7 @@ package WWW::OpenAPIClient::StoreApi;
|
||||
require 5.6.0;
|
||||
use strict;
|
||||
use warnings;
|
||||
use utf8;
|
||||
use utf8;
|
||||
use Exporter;
|
||||
use Carp qw( croak );
|
||||
use Log::Any qw($log);
|
||||
@ -31,15 +32,16 @@ use WWW::OpenAPIClient::ApiClient;
|
||||
|
||||
use base "Class::Data::Inheritable";
|
||||
|
||||
__PACKAGE__->mk_classdata('method_documentation' => {});
|
||||
__PACKAGE__->mk_classdata( 'method_documentation' => {} );
|
||||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
my $api_client;
|
||||
|
||||
if ($_[0] && ref $_[0] && ref $_[0] eq 'WWW::OpenAPIClient::ApiClient' ) {
|
||||
if ( $_[0] && ref $_[0] && ref $_[0] eq 'WWW::OpenAPIClient::ApiClient' ) {
|
||||
$api_client = $_[0];
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$api_client = WWW::OpenAPIClient::ApiClient->new(@_);
|
||||
}
|
||||
|
||||
@ -47,67 +49,73 @@ sub new {
|
||||
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# delete_order
|
||||
#
|
||||
# Delete purchase order by ID
|
||||
#
|
||||
#
|
||||
# @param string $order_id ID of the order that needs to be deleted (required)
|
||||
{
|
||||
my $params = {
|
||||
'order_id' => {
|
||||
data_type => 'string',
|
||||
description => 'ID of the order that needs to be deleted',
|
||||
required => '1',
|
||||
},
|
||||
'order_id' => {
|
||||
data_type => 'string',
|
||||
description => 'ID of the order that needs to be deleted',
|
||||
required => '1',
|
||||
},
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ 'delete_order' } = {
|
||||
summary => 'Delete purchase order by ID',
|
||||
params => $params,
|
||||
__PACKAGE__->method_documentation->{'delete_order'} = {
|
||||
summary => 'Delete purchase order by ID',
|
||||
params => $params,
|
||||
returns => undef,
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
# @return void
|
||||
#
|
||||
sub delete_order {
|
||||
my ($self, %args) = @_;
|
||||
my ( $self, %args ) = @_;
|
||||
|
||||
# verify the required parameter 'order_id' is set
|
||||
unless (exists $args{'order_id'}) {
|
||||
croak("Missing the required parameter 'order_id' when calling delete_order");
|
||||
unless ( exists $args{'order_id'} ) {
|
||||
croak(
|
||||
"Missing the required parameter 'order_id' when calling delete_order"
|
||||
);
|
||||
}
|
||||
|
||||
# parse inputs
|
||||
my $_resource_path = '/store/order/{order_id}';
|
||||
|
||||
my $_method = 'DELETE';
|
||||
my $query_params = {};
|
||||
my $_method = 'DELETE';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_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();
|
||||
$header_params->{'Content-Type'} =
|
||||
$self->{api_client}->select_header_content_type();
|
||||
|
||||
# path params
|
||||
if ( exists $args{'order_id'}) {
|
||||
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;
|
||||
}
|
||||
|
||||
@ -115,48 +123,53 @@ sub delete_order {
|
||||
# get_inventory
|
||||
#
|
||||
# Returns pet inventories by status
|
||||
#
|
||||
#
|
||||
{
|
||||
my $params = {
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ 'get_inventory' } = {
|
||||
summary => 'Returns pet inventories by status',
|
||||
params => $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 {
|
||||
my ($self, %args) = @_;
|
||||
my ( $self, %args ) = @_;
|
||||
|
||||
# parse inputs
|
||||
my $_resource_path = '/store/inventory';
|
||||
|
||||
my $_method = 'GET';
|
||||
my $query_params = {};
|
||||
my $_method = 'GET';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
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);
|
||||
if (!$response) {
|
||||
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;
|
||||
}
|
||||
|
||||
@ -164,66 +177,75 @@ sub get_inventory {
|
||||
# get_order_by_id
|
||||
#
|
||||
# Find purchase order by ID
|
||||
#
|
||||
#
|
||||
# @param int $order_id ID of pet that needs to be fetched (required)
|
||||
{
|
||||
my $params = {
|
||||
'order_id' => {
|
||||
data_type => 'int',
|
||||
description => 'ID of pet that needs to be fetched',
|
||||
required => '1',
|
||||
},
|
||||
'order_id' => {
|
||||
data_type => 'int',
|
||||
description => 'ID of pet that needs to be fetched',
|
||||
required => '1',
|
||||
},
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ 'get_order_by_id' } = {
|
||||
summary => 'Find purchase order by ID',
|
||||
params => $params,
|
||||
__PACKAGE__->method_documentation->{'get_order_by_id'} = {
|
||||
summary => 'Find purchase order by ID',
|
||||
params => $params,
|
||||
returns => 'Order',
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
# @return Order
|
||||
#
|
||||
sub get_order_by_id {
|
||||
my ($self, %args) = @_;
|
||||
my ( $self, %args ) = @_;
|
||||
|
||||
# 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");
|
||||
unless ( exists $args{'order_id'} ) {
|
||||
croak(
|
||||
"Missing the required parameter 'order_id' when calling get_order_by_id"
|
||||
);
|
||||
}
|
||||
|
||||
# parse inputs
|
||||
my $_resource_path = '/store/order/{order_id}';
|
||||
|
||||
my $_method = 'GET';
|
||||
my $query_params = {};
|
||||
my $_method = 'GET';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
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'}) {
|
||||
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);
|
||||
if (!$response) {
|
||||
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;
|
||||
}
|
||||
|
||||
@ -231,50 +253,55 @@ sub get_order_by_id {
|
||||
# place_order
|
||||
#
|
||||
# Place an order for a pet
|
||||
#
|
||||
#
|
||||
# @param Order $order order placed for purchasing the pet (required)
|
||||
{
|
||||
my $params = {
|
||||
'order' => {
|
||||
data_type => 'Order',
|
||||
description => 'order placed for purchasing the pet',
|
||||
required => '1',
|
||||
},
|
||||
'order' => {
|
||||
data_type => 'Order',
|
||||
description => 'order placed for purchasing the pet',
|
||||
required => '1',
|
||||
},
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ 'place_order' } = {
|
||||
summary => 'Place an order for a pet',
|
||||
params => $params,
|
||||
__PACKAGE__->method_documentation->{'place_order'} = {
|
||||
summary => 'Place an order for a pet',
|
||||
params => $params,
|
||||
returns => 'Order',
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
# @return Order
|
||||
#
|
||||
sub place_order {
|
||||
my ($self, %args) = @_;
|
||||
my ( $self, %args ) = @_;
|
||||
|
||||
# verify the required parameter 'order' is set
|
||||
unless (exists $args{'order'}) {
|
||||
croak("Missing the required parameter 'order' when calling place_order");
|
||||
unless ( exists $args{'order'} ) {
|
||||
croak(
|
||||
"Missing the required parameter 'order' when calling place_order");
|
||||
}
|
||||
|
||||
# parse inputs
|
||||
my $_resource_path = '/store/order';
|
||||
|
||||
my $_method = 'POST';
|
||||
my $query_params = {};
|
||||
my $_method = 'POST';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
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'}) {
|
||||
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);
|
||||
if (!$response) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
=begin comment
|
||||
|
||||
OpenAPI Petstore
|
||||
@ -22,7 +23,7 @@ package WWW::OpenAPIClient::UserApi;
|
||||
require 5.6.0;
|
||||
use strict;
|
||||
use warnings;
|
||||
use utf8;
|
||||
use utf8;
|
||||
use Exporter;
|
||||
use Carp qw( croak );
|
||||
use Log::Any qw($log);
|
||||
@ -31,15 +32,16 @@ use WWW::OpenAPIClient::ApiClient;
|
||||
|
||||
use base "Class::Data::Inheritable";
|
||||
|
||||
__PACKAGE__->mk_classdata('method_documentation' => {});
|
||||
__PACKAGE__->mk_classdata( 'method_documentation' => {} );
|
||||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
my $api_client;
|
||||
|
||||
if ($_[0] && ref $_[0] && ref $_[0] eq 'WWW::OpenAPIClient::ApiClient' ) {
|
||||
if ( $_[0] && ref $_[0] && ref $_[0] eq 'WWW::OpenAPIClient::ApiClient' ) {
|
||||
$api_client = $_[0];
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$api_client = WWW::OpenAPIClient::ApiClient->new(@_);
|
||||
}
|
||||
|
||||
@ -47,55 +49,57 @@ sub new {
|
||||
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# create_user
|
||||
#
|
||||
# Create user
|
||||
#
|
||||
#
|
||||
# @param User $user Created user object (required)
|
||||
{
|
||||
my $params = {
|
||||
'user' => {
|
||||
data_type => 'User',
|
||||
description => 'Created user object',
|
||||
required => '1',
|
||||
},
|
||||
'user' => {
|
||||
data_type => 'User',
|
||||
description => 'Created user object',
|
||||
required => '1',
|
||||
},
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ 'create_user' } = {
|
||||
summary => 'Create user',
|
||||
params => $params,
|
||||
__PACKAGE__->method_documentation->{'create_user'} = {
|
||||
summary => 'Create user',
|
||||
params => $params,
|
||||
returns => undef,
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
# @return void
|
||||
#
|
||||
sub create_user {
|
||||
my ($self, %args) = @_;
|
||||
my ( $self, %args ) = @_;
|
||||
|
||||
# verify the required parameter 'user' is set
|
||||
unless (exists $args{'user'}) {
|
||||
croak("Missing the required parameter 'user' when calling create_user");
|
||||
unless ( exists $args{'user'} ) {
|
||||
croak("Missing the required parameter 'user' when calling create_user");
|
||||
}
|
||||
|
||||
# parse inputs
|
||||
my $_resource_path = '/user';
|
||||
|
||||
my $_method = 'POST';
|
||||
my $query_params = {};
|
||||
my $_method = 'POST';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_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();
|
||||
$header_params->{'Content-Type'} =
|
||||
$self->{api_client}->select_header_content_type();
|
||||
|
||||
my $_body_data;
|
||||
|
||||
# body params
|
||||
if ( exists $args{'user'}) {
|
||||
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;
|
||||
}
|
||||
|
||||
@ -113,50 +118,55 @@ sub create_user {
|
||||
# create_users_with_array_input
|
||||
#
|
||||
# Creates list of users with given input array
|
||||
#
|
||||
#
|
||||
# @param ARRAY[User] $user List of user object (required)
|
||||
{
|
||||
my $params = {
|
||||
'user' => {
|
||||
data_type => 'ARRAY[User]',
|
||||
description => 'List of user object',
|
||||
required => '1',
|
||||
},
|
||||
'user' => {
|
||||
data_type => 'ARRAY[User]',
|
||||
description => 'List of user object',
|
||||
required => '1',
|
||||
},
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ 'create_users_with_array_input' } = {
|
||||
summary => 'Creates list of users with given input array',
|
||||
params => $params,
|
||||
__PACKAGE__->method_documentation->{'create_users_with_array_input'} = {
|
||||
summary => 'Creates list of users with given input array',
|
||||
params => $params,
|
||||
returns => undef,
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
# @return void
|
||||
#
|
||||
sub create_users_with_array_input {
|
||||
my ($self, %args) = @_;
|
||||
my ( $self, %args ) = @_;
|
||||
|
||||
# verify the required parameter 'user' is set
|
||||
unless (exists $args{'user'}) {
|
||||
croak("Missing the required parameter 'user' when calling create_users_with_array_input");
|
||||
unless ( exists $args{'user'} ) {
|
||||
croak(
|
||||
"Missing the required parameter 'user' when calling create_users_with_array_input"
|
||||
);
|
||||
}
|
||||
|
||||
# parse inputs
|
||||
my $_resource_path = '/user/createWithArray';
|
||||
|
||||
my $_method = 'POST';
|
||||
my $query_params = {};
|
||||
my $_method = 'POST';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_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();
|
||||
$header_params->{'Content-Type'} =
|
||||
$self->{api_client}->select_header_content_type();
|
||||
|
||||
my $_body_data;
|
||||
|
||||
# body params
|
||||
if ( exists $args{'user'}) {
|
||||
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;
|
||||
}
|
||||
|
||||
@ -174,50 +185,55 @@ sub create_users_with_array_input {
|
||||
# create_users_with_list_input
|
||||
#
|
||||
# Creates list of users with given input array
|
||||
#
|
||||
#
|
||||
# @param ARRAY[User] $user List of user object (required)
|
||||
{
|
||||
my $params = {
|
||||
'user' => {
|
||||
data_type => 'ARRAY[User]',
|
||||
description => 'List of user object',
|
||||
required => '1',
|
||||
},
|
||||
'user' => {
|
||||
data_type => 'ARRAY[User]',
|
||||
description => 'List of user object',
|
||||
required => '1',
|
||||
},
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ 'create_users_with_list_input' } = {
|
||||
summary => 'Creates list of users with given input array',
|
||||
params => $params,
|
||||
__PACKAGE__->method_documentation->{'create_users_with_list_input'} = {
|
||||
summary => 'Creates list of users with given input array',
|
||||
params => $params,
|
||||
returns => undef,
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
# @return void
|
||||
#
|
||||
sub create_users_with_list_input {
|
||||
my ($self, %args) = @_;
|
||||
my ( $self, %args ) = @_;
|
||||
|
||||
# verify the required parameter 'user' is set
|
||||
unless (exists $args{'user'}) {
|
||||
croak("Missing the required parameter 'user' when calling create_users_with_list_input");
|
||||
unless ( exists $args{'user'} ) {
|
||||
croak(
|
||||
"Missing the required parameter 'user' when calling create_users_with_list_input"
|
||||
);
|
||||
}
|
||||
|
||||
# parse inputs
|
||||
my $_resource_path = '/user/createWithList';
|
||||
|
||||
my $_method = 'POST';
|
||||
my $query_params = {};
|
||||
my $_method = 'POST';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_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();
|
||||
$header_params->{'Content-Type'} =
|
||||
$self->{api_client}->select_header_content_type();
|
||||
|
||||
my $_body_data;
|
||||
|
||||
# body params
|
||||
if ( exists $args{'user'}) {
|
||||
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;
|
||||
}
|
||||
|
||||
@ -235,62 +252,69 @@ sub create_users_with_list_input {
|
||||
# delete_user
|
||||
#
|
||||
# Delete user
|
||||
#
|
||||
#
|
||||
# @param string $username The name that needs to be deleted (required)
|
||||
{
|
||||
my $params = {
|
||||
'username' => {
|
||||
data_type => 'string',
|
||||
description => 'The name that needs to be deleted',
|
||||
required => '1',
|
||||
},
|
||||
'username' => {
|
||||
data_type => 'string',
|
||||
description => 'The name that needs to be deleted',
|
||||
required => '1',
|
||||
},
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ 'delete_user' } = {
|
||||
summary => 'Delete user',
|
||||
params => $params,
|
||||
__PACKAGE__->method_documentation->{'delete_user'} = {
|
||||
summary => 'Delete user',
|
||||
params => $params,
|
||||
returns => undef,
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
# @return void
|
||||
#
|
||||
sub delete_user {
|
||||
my ($self, %args) = @_;
|
||||
my ( $self, %args ) = @_;
|
||||
|
||||
# verify the required parameter 'username' is set
|
||||
unless (exists $args{'username'}) {
|
||||
croak("Missing the required parameter 'username' when calling delete_user");
|
||||
unless ( exists $args{'username'} ) {
|
||||
croak(
|
||||
"Missing the required parameter 'username' when calling delete_user"
|
||||
);
|
||||
}
|
||||
|
||||
# parse inputs
|
||||
my $_resource_path = '/user/{username}';
|
||||
|
||||
my $_method = 'DELETE';
|
||||
my $query_params = {};
|
||||
my $_method = 'DELETE';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_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();
|
||||
$header_params->{'Content-Type'} =
|
||||
$self->{api_client}->select_header_content_type();
|
||||
|
||||
# path params
|
||||
if ( exists $args{'username'}) {
|
||||
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;
|
||||
}
|
||||
|
||||
@ -298,66 +322,76 @@ sub delete_user {
|
||||
# get_user_by_name
|
||||
#
|
||||
# Get user by user name
|
||||
#
|
||||
#
|
||||
# @param string $username The name that needs to be fetched. Use user1 for testing. (required)
|
||||
{
|
||||
my $params = {
|
||||
'username' => {
|
||||
data_type => 'string',
|
||||
description => 'The name that needs to be fetched. Use user1 for testing.',
|
||||
required => '1',
|
||||
},
|
||||
'username' => {
|
||||
data_type => 'string',
|
||||
description =>
|
||||
'The name that needs to be fetched. Use user1 for testing.',
|
||||
required => '1',
|
||||
},
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ 'get_user_by_name' } = {
|
||||
summary => 'Get user by user name',
|
||||
params => $params,
|
||||
__PACKAGE__->method_documentation->{'get_user_by_name'} = {
|
||||
summary => 'Get user by user name',
|
||||
params => $params,
|
||||
returns => 'User',
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
# @return User
|
||||
#
|
||||
sub get_user_by_name {
|
||||
my ($self, %args) = @_;
|
||||
my ( $self, %args ) = @_;
|
||||
|
||||
# verify the required parameter 'username' is set
|
||||
unless (exists $args{'username'}) {
|
||||
croak("Missing the required parameter 'username' when calling get_user_by_name");
|
||||
unless ( exists $args{'username'} ) {
|
||||
croak(
|
||||
"Missing the required parameter 'username' when calling get_user_by_name"
|
||||
);
|
||||
}
|
||||
|
||||
# parse inputs
|
||||
my $_resource_path = '/user/{username}';
|
||||
|
||||
my $_method = 'GET';
|
||||
my $query_params = {};
|
||||
my $_method = 'GET';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
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'}) {
|
||||
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);
|
||||
if (!$response) {
|
||||
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;
|
||||
}
|
||||
|
||||
@ -365,80 +399,92 @@ sub get_user_by_name {
|
||||
# login_user
|
||||
#
|
||||
# Logs user into the system
|
||||
#
|
||||
#
|
||||
# @param string $username The user name for login (required)
|
||||
# @param string $password The password for login in clear text (required)
|
||||
{
|
||||
my $params = {
|
||||
'username' => {
|
||||
data_type => 'string',
|
||||
description => 'The user name for login',
|
||||
required => '1',
|
||||
},
|
||||
'password' => {
|
||||
data_type => 'string',
|
||||
description => 'The password for login in clear text',
|
||||
required => '1',
|
||||
},
|
||||
'username' => {
|
||||
data_type => 'string',
|
||||
description => 'The user name for login',
|
||||
required => '1',
|
||||
},
|
||||
'password' => {
|
||||
data_type => 'string',
|
||||
description => 'The password for login in clear text',
|
||||
required => '1',
|
||||
},
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ 'login_user' } = {
|
||||
summary => 'Logs user into the system',
|
||||
params => $params,
|
||||
__PACKAGE__->method_documentation->{'login_user'} = {
|
||||
summary => 'Logs user into the system',
|
||||
params => $params,
|
||||
returns => 'string',
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
# @return string
|
||||
#
|
||||
sub login_user {
|
||||
my ($self, %args) = @_;
|
||||
my ( $self, %args ) = @_;
|
||||
|
||||
# verify the required parameter 'username' is set
|
||||
unless (exists $args{'username'}) {
|
||||
croak("Missing the required parameter 'username' when calling login_user");
|
||||
unless ( exists $args{'username'} ) {
|
||||
croak(
|
||||
"Missing the required parameter 'username' when calling login_user"
|
||||
);
|
||||
}
|
||||
|
||||
# verify the required parameter 'password' is set
|
||||
unless (exists $args{'password'}) {
|
||||
croak("Missing the required parameter 'password' when calling login_user");
|
||||
unless ( exists $args{'password'} ) {
|
||||
croak(
|
||||
"Missing the required parameter 'password' when calling login_user"
|
||||
);
|
||||
}
|
||||
|
||||
# parse inputs
|
||||
my $_resource_path = '/user/login';
|
||||
|
||||
my $_method = 'GET';
|
||||
my $query_params = {};
|
||||
my $_method = 'GET';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_params = {};
|
||||
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'});
|
||||
if ( exists $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'});
|
||||
if ( exists $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);
|
||||
if (!$response) {
|
||||
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;
|
||||
}
|
||||
|
||||
@ -446,44 +492,47 @@ sub login_user {
|
||||
# logout_user
|
||||
#
|
||||
# Logs out current logged in user session
|
||||
#
|
||||
#
|
||||
{
|
||||
my $params = {
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ 'logout_user' } = {
|
||||
summary => 'Logs out current logged in user session',
|
||||
params => $params,
|
||||
my $params = {};
|
||||
__PACKAGE__->method_documentation->{'logout_user'} = {
|
||||
summary => 'Logs out current logged in user session',
|
||||
params => $params,
|
||||
returns => undef,
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
# @return void
|
||||
#
|
||||
sub logout_user {
|
||||
my ($self, %args) = @_;
|
||||
my ( $self, %args ) = @_;
|
||||
|
||||
# parse inputs
|
||||
my $_resource_path = '/user/logout';
|
||||
|
||||
my $_method = 'GET';
|
||||
my $query_params = {};
|
||||
my $_method = 'GET';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_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();
|
||||
$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;
|
||||
}
|
||||
|
||||
@ -491,68 +540,74 @@ sub logout_user {
|
||||
# update_user
|
||||
#
|
||||
# Updated user
|
||||
#
|
||||
#
|
||||
# @param string $username name that need to be deleted (required)
|
||||
# @param User $user Updated user object (required)
|
||||
{
|
||||
my $params = {
|
||||
'username' => {
|
||||
data_type => 'string',
|
||||
description => 'name that need to be deleted',
|
||||
required => '1',
|
||||
},
|
||||
'user' => {
|
||||
data_type => 'User',
|
||||
description => 'Updated user object',
|
||||
required => '1',
|
||||
},
|
||||
'username' => {
|
||||
data_type => 'string',
|
||||
description => 'name that need to be deleted',
|
||||
required => '1',
|
||||
},
|
||||
'user' => {
|
||||
data_type => 'User',
|
||||
description => 'Updated user object',
|
||||
required => '1',
|
||||
},
|
||||
};
|
||||
__PACKAGE__->method_documentation->{ 'update_user' } = {
|
||||
summary => 'Updated user',
|
||||
params => $params,
|
||||
__PACKAGE__->method_documentation->{'update_user'} = {
|
||||
summary => 'Updated user',
|
||||
params => $params,
|
||||
returns => undef,
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
# @return void
|
||||
#
|
||||
sub update_user {
|
||||
my ($self, %args) = @_;
|
||||
my ( $self, %args ) = @_;
|
||||
|
||||
# verify the required parameter 'username' is set
|
||||
unless (exists $args{'username'}) {
|
||||
croak("Missing the required parameter 'username' when calling update_user");
|
||||
unless ( exists $args{'username'} ) {
|
||||
croak(
|
||||
"Missing the required parameter 'username' when calling update_user"
|
||||
);
|
||||
}
|
||||
|
||||
# verify the required parameter 'user' is set
|
||||
unless (exists $args{'user'}) {
|
||||
croak("Missing the required parameter 'user' when calling update_user");
|
||||
unless ( exists $args{'user'} ) {
|
||||
croak("Missing the required parameter 'user' when calling update_user");
|
||||
}
|
||||
|
||||
# parse inputs
|
||||
my $_resource_path = '/user/{username}';
|
||||
|
||||
my $_method = 'PUT';
|
||||
my $query_params = {};
|
||||
my $_method = 'PUT';
|
||||
my $query_params = {};
|
||||
my $header_params = {};
|
||||
my $form_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();
|
||||
$header_params->{'Content-Type'} =
|
||||
$self->{api_client}->select_header_content_type();
|
||||
|
||||
# path params
|
||||
if ( exists $args{'username'}) {
|
||||
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'}) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
33
samples/client/petstore/perl/t/FileSchemaTestClassTest.t
Normal file
33
samples/client/petstore/perl/t/FileSchemaTestClassTest.t
Normal 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');
|
||||
|
33
samples/client/petstore/perl/t/FileTest.t
Normal file
33
samples/client/petstore/perl/t/FileTest.t
Normal 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');
|
||||
|
33
samples/client/petstore/perl/t/StringBooleanMapTest.t
Normal file
33
samples/client/petstore/perl/t/StringBooleanMapTest.t
Normal 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');
|
||||
|
@ -17,8 +17,8 @@ use DateTime;
|
||||
|
||||
my $api = WWW::OpenAPIClient::PetApi->new(
|
||||
http_user_agent => 'Perl-Swagger-Test',
|
||||
api_key => { api_key => 'ZZZZZZZZZZZZZZ' },
|
||||
api_key_prefix => { api_key => 'Bearer' },
|
||||
api_key => { api_key => 'ZZZZZZZZZZZZZZ' },
|
||||
api_key_prefix => { api_key => 'Bearer' },
|
||||
|
||||
username => 'username',
|
||||
password => 'password',
|
||||
@ -34,27 +34,45 @@ 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;
|
||||
print "\npet(object)=" . Dumper $pet;
|
||||
my $json = JSON->new->convert_blessed;
|
||||
|
||||
my $new_pet = WWW::OpenAPIClient::Object::Pet->new();
|
||||
$new_pet = $new_pet->from_hash($pet->to_hash);
|
||||
print "new_pet(hash):".Dumper($new_pet->to_hash);
|
||||
$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 "\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 "\ndelete_pet:".Dumper $api->delete_pet(pet_id => $pet_id);
|
||||
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 "\ndelete_pet:" . Dumper $api->delete_pet( pet_id => $pet_id );
|
||||
|
||||
my $store_api = WWW::OpenAPIClient::StoreApi->new();
|
||||
print "\nget_inventory:".Dumper $store_api->get_inventory();
|
||||
print "\nget_inventory:" . Dumper $store_api->get_inventory();
|
||||
|
||||
my $pet_json = <<JSON;
|
||||
{
|
||||
@ -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 ) );
|
||||
|
@ -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';
|
||||
|
Loading…
Reference in New Issue
Block a user