forked from loafle/openapi-generator-original
Add multiple inheritance support to Perl client (#1681)
* add multiple inheritance support to perl client * remove allof test from fake petstore
This commit is contained in:
@@ -28,6 +28,6 @@ fi
|
|||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||||
# complex module name used for testing
|
# complex module name used for testing
|
||||||
ags="generate -i modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml -g perl -o samples/client/petstore/perl -DhideGenerationTimestamp=true $@"
|
ags="generate -t modules/openapi-generator/src/main/resources/perl -i modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml -g perl -o samples/client/petstore/perl -DhideGenerationTimestamp=true $@"
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
java $JAVA_OPTS -jar $executable $ags
|
||||||
|
|||||||
@@ -53,6 +53,9 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
public PerlClientCodegen() {
|
public PerlClientCodegen() {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
// add multiple inheritance support (beta)
|
||||||
|
supportsMultipleInheritance = true;
|
||||||
|
|
||||||
// clear import mapping (from default generator) as perl does not use it
|
// clear import mapping (from default generator) as perl does not use it
|
||||||
// at the moment
|
// at the moment
|
||||||
importMapping.clear();
|
importMapping.clear();
|
||||||
|
|||||||
@@ -9,23 +9,44 @@ __PACKAGE__->mk_classdata('openapi_types' => {});
|
|||||||
__PACKAGE__->mk_classdata('method_documentation' => {});
|
__PACKAGE__->mk_classdata('method_documentation' => {});
|
||||||
__PACKAGE__->mk_classdata('class_documentation' => {});
|
__PACKAGE__->mk_classdata('class_documentation' => {});
|
||||||
|
|
||||||
# new object
|
# new plain object
|
||||||
sub new {
|
sub new {
|
||||||
my ($class, %args) = @_;
|
my ($class, %args) = @_;
|
||||||
|
|
||||||
my $self = bless {}, $class;
|
my $self = bless {}, $class;
|
||||||
|
|
||||||
foreach my $attribute (keys %{$class->attribute_map}) {
|
$self->init(%args);
|
||||||
my $args_key = $class->attribute_map->{$attribute};
|
|
||||||
$self->$attribute( $args{ $args_key } );
|
|
||||||
}
|
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# initialize the object
|
||||||
|
sub init
|
||||||
|
{
|
||||||
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
|
foreach my $attribute (keys %{$self->attribute_map}) {
|
||||||
|
my $args_key = $self->attribute_map->{$attribute};
|
||||||
|
$self->$attribute( $args{ $args_key } );
|
||||||
|
}
|
||||||
|
{{#allParents}}
|
||||||
|
|
||||||
|
# initialize parent object {{{.}}}
|
||||||
|
$self->{{moduleName}}::Object::{{{.}}}::init(%args);
|
||||||
|
{{/allParents}}
|
||||||
|
}
|
||||||
|
|
||||||
# return perl hash
|
# return perl hash
|
||||||
sub to_hash {
|
sub to_hash {
|
||||||
return decode_json(JSON->new->convert_blessed->encode( shift ));
|
my $self = shift;
|
||||||
|
my $_hash = decode_json(JSON->new->convert_blessed->encode($self));
|
||||||
|
{{#allParents}}
|
||||||
|
|
||||||
|
# call {{{.}}} to_hash and then combine hash
|
||||||
|
$_hash = { %$_hash, %$self->{{moduleName}}::Object::{{{.}}}::to_hash };
|
||||||
|
{{/allParents}}
|
||||||
|
|
||||||
|
return $_hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
# used by JSON for serialization
|
# used by JSON for serialization
|
||||||
@@ -37,6 +58,12 @@ sub TO_JSON {
|
|||||||
$_data->{$self->attribute_map->{$_key}} = $self->{$_key};
|
$_data->{$self->attribute_map->{$_key}} = $self->{$_key};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
{{#allParents}}
|
||||||
|
|
||||||
|
# combine parent ({{{.}}}) TO_JSON
|
||||||
|
$_data = { %$_data, %$self->{{moduleName}}::Object::{{{.}}}::TO_JSON };
|
||||||
|
{{/allParents}}
|
||||||
|
|
||||||
return $_data;
|
return $_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,6 +87,11 @@ sub from_hash {
|
|||||||
$log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
|
$log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
{{#allParents}}
|
||||||
|
|
||||||
|
# call parent ({{{.}}}) from_hash
|
||||||
|
$self->{{moduleName}}::Object::{{{.}}}::from_hash($hash);
|
||||||
|
{{/allParents}}
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,8 +23,7 @@ use DateTime;
|
|||||||
use {{moduleName}}::Object::{{.}};
|
use {{moduleName}}::Object::{{.}};
|
||||||
{{/imports}}
|
{{/imports}}
|
||||||
|
|
||||||
use base ("Class::Accessor", "Class::Data::Inheritable");
|
use base ("Class::Accessor", "Class::Data::Inheritable"{{#allParents}}, "{{moduleName}}::Object::{{{.}}}"{{/allParents}});
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
#{{description}}
|
#{{description}}
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
3.3.0-SNAPSHOT
|
4.0.0-SNAPSHOT
|
||||||
@@ -234,7 +234,6 @@ To load the models:
|
|||||||
```perl
|
```perl
|
||||||
use WWW::OpenAPIClient::Object::AdditionalPropertiesClass;
|
use WWW::OpenAPIClient::Object::AdditionalPropertiesClass;
|
||||||
use WWW::OpenAPIClient::Object::Animal;
|
use WWW::OpenAPIClient::Object::Animal;
|
||||||
use WWW::OpenAPIClient::Object::AnimalFarm;
|
|
||||||
use WWW::OpenAPIClient::Object::ApiResponse;
|
use WWW::OpenAPIClient::Object::ApiResponse;
|
||||||
use WWW::OpenAPIClient::Object::ArrayOfArrayOfNumberOnly;
|
use WWW::OpenAPIClient::Object::ArrayOfArrayOfNumberOnly;
|
||||||
use WWW::OpenAPIClient::Object::ArrayOfNumberOnly;
|
use WWW::OpenAPIClient::Object::ArrayOfNumberOnly;
|
||||||
@@ -265,7 +264,6 @@ use WWW::OpenAPIClient::Object::OuterEnum;
|
|||||||
use WWW::OpenAPIClient::Object::Pet;
|
use WWW::OpenAPIClient::Object::Pet;
|
||||||
use WWW::OpenAPIClient::Object::ReadOnlyFirst;
|
use WWW::OpenAPIClient::Object::ReadOnlyFirst;
|
||||||
use WWW::OpenAPIClient::Object::SpecialModelName;
|
use WWW::OpenAPIClient::Object::SpecialModelName;
|
||||||
use WWW::OpenAPIClient::Object::StringBooleanMap;
|
|
||||||
use WWW::OpenAPIClient::Object::Tag;
|
use WWW::OpenAPIClient::Object::Tag;
|
||||||
use WWW::OpenAPIClient::Object::User;
|
use WWW::OpenAPIClient::Object::User;
|
||||||
|
|
||||||
@@ -289,7 +287,6 @@ use WWW::OpenAPIClient::UserApi;
|
|||||||
# load the models
|
# load the models
|
||||||
use WWW::OpenAPIClient::Object::AdditionalPropertiesClass;
|
use WWW::OpenAPIClient::Object::AdditionalPropertiesClass;
|
||||||
use WWW::OpenAPIClient::Object::Animal;
|
use WWW::OpenAPIClient::Object::Animal;
|
||||||
use WWW::OpenAPIClient::Object::AnimalFarm;
|
|
||||||
use WWW::OpenAPIClient::Object::ApiResponse;
|
use WWW::OpenAPIClient::Object::ApiResponse;
|
||||||
use WWW::OpenAPIClient::Object::ArrayOfArrayOfNumberOnly;
|
use WWW::OpenAPIClient::Object::ArrayOfArrayOfNumberOnly;
|
||||||
use WWW::OpenAPIClient::Object::ArrayOfNumberOnly;
|
use WWW::OpenAPIClient::Object::ArrayOfNumberOnly;
|
||||||
@@ -320,7 +317,6 @@ use WWW::OpenAPIClient::Object::OuterEnum;
|
|||||||
use WWW::OpenAPIClient::Object::Pet;
|
use WWW::OpenAPIClient::Object::Pet;
|
||||||
use WWW::OpenAPIClient::Object::ReadOnlyFirst;
|
use WWW::OpenAPIClient::Object::ReadOnlyFirst;
|
||||||
use WWW::OpenAPIClient::Object::SpecialModelName;
|
use WWW::OpenAPIClient::Object::SpecialModelName;
|
||||||
use WWW::OpenAPIClient::Object::StringBooleanMap;
|
|
||||||
use WWW::OpenAPIClient::Object::Tag;
|
use WWW::OpenAPIClient::Object::Tag;
|
||||||
use WWW::OpenAPIClient::Object::User;
|
use WWW::OpenAPIClient::Object::User;
|
||||||
|
|
||||||
@@ -359,6 +355,7 @@ Class | Method | HTTP request | Description
|
|||||||
*FakeApi* | [**test_client_model**](docs/FakeApi.md#test_client_model) | **PATCH** /fake | To test \"client\" model
|
*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 假端點 偽のエンドポイント 가짜 엔드 포인트
|
*FakeApi* | [**test_endpoint_parameters**](docs/FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||||
*FakeApi* | [**test_enum_parameters**](docs/FakeApi.md#test_enum_parameters) | **GET** /fake | To test enum parameters
|
*FakeApi* | [**test_enum_parameters**](docs/FakeApi.md#test_enum_parameters) | **GET** /fake | To test enum parameters
|
||||||
|
*FakeApi* | [**test_group_parameters**](docs/FakeApi.md#test_group_parameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional)
|
||||||
*FakeApi* | [**test_inline_additional_properties**](docs/FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties
|
*FakeApi* | [**test_inline_additional_properties**](docs/FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties
|
||||||
*FakeApi* | [**test_json_form_data**](docs/FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data
|
*FakeApi* | [**test_json_form_data**](docs/FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data
|
||||||
*FakeClassnameTags123Api* | [**test_classname**](docs/FakeClassnameTags123Api.md#test_classname) | **PATCH** /fake_classname_test | To test class name in snake case
|
*FakeClassnameTags123Api* | [**test_classname**](docs/FakeClassnameTags123Api.md#test_classname) | **PATCH** /fake_classname_test | To test class name in snake case
|
||||||
@@ -388,7 +385,6 @@ Class | Method | HTTP request | Description
|
|||||||
# DOCUMENTATION FOR MODELS
|
# DOCUMENTATION FOR MODELS
|
||||||
- [WWW::OpenAPIClient::Object::AdditionalPropertiesClass](docs/AdditionalPropertiesClass.md)
|
- [WWW::OpenAPIClient::Object::AdditionalPropertiesClass](docs/AdditionalPropertiesClass.md)
|
||||||
- [WWW::OpenAPIClient::Object::Animal](docs/Animal.md)
|
- [WWW::OpenAPIClient::Object::Animal](docs/Animal.md)
|
||||||
- [WWW::OpenAPIClient::Object::AnimalFarm](docs/AnimalFarm.md)
|
|
||||||
- [WWW::OpenAPIClient::Object::ApiResponse](docs/ApiResponse.md)
|
- [WWW::OpenAPIClient::Object::ApiResponse](docs/ApiResponse.md)
|
||||||
- [WWW::OpenAPIClient::Object::ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md)
|
- [WWW::OpenAPIClient::Object::ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md)
|
||||||
- [WWW::OpenAPIClient::Object::ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md)
|
- [WWW::OpenAPIClient::Object::ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md)
|
||||||
@@ -419,7 +415,6 @@ Class | Method | HTTP request | Description
|
|||||||
- [WWW::OpenAPIClient::Object::Pet](docs/Pet.md)
|
- [WWW::OpenAPIClient::Object::Pet](docs/Pet.md)
|
||||||
- [WWW::OpenAPIClient::Object::ReadOnlyFirst](docs/ReadOnlyFirst.md)
|
- [WWW::OpenAPIClient::Object::ReadOnlyFirst](docs/ReadOnlyFirst.md)
|
||||||
- [WWW::OpenAPIClient::Object::SpecialModelName](docs/SpecialModelName.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::Tag](docs/Tag.md)
|
||||||
- [WWW::OpenAPIClient::Object::User](docs/User.md)
|
- [WWW::OpenAPIClient::Object::User](docs/User.md)
|
||||||
|
|
||||||
|
|||||||
18
samples/client/petstore/perl/docs/Adult.md
Normal file
18
samples/client/petstore/perl/docs/Adult.md
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# WWW::OpenAPIClient::Object::Adult
|
||||||
|
|
||||||
|
## Load the model package
|
||||||
|
```perl
|
||||||
|
use WWW::OpenAPIClient::Object::Adult;
|
||||||
|
```
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
**duplicated_optional** | **int** | | [optional]
|
||||||
|
**duplicated_required** | **int** | |
|
||||||
|
**children** | [**ARRAY[Child]**](Child.md) | | [optional]
|
||||||
|
**adult_required** | **boolean** | | [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)
|
||||||
|
|
||||||
|
|
||||||
@@ -8,8 +8,6 @@ use WWW::OpenAPIClient::Object::Cat;
|
|||||||
## Properties
|
## Properties
|
||||||
Name | Type | Description | Notes
|
Name | Type | Description | Notes
|
||||||
------------ | ------------- | ------------- | -------------
|
------------ | ------------- | ------------- | -------------
|
||||||
**class_name** | **string** | |
|
|
||||||
**color** | **string** | | [optional] [default to 'red']
|
|
||||||
**declawed** | **boolean** | | [optional]
|
**declawed** | **boolean** | | [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)
|
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ use WWW::OpenAPIClient::Object::Category;
|
|||||||
Name | Type | Description | Notes
|
Name | Type | Description | Notes
|
||||||
------------ | ------------- | ------------- | -------------
|
------------ | ------------- | ------------- | -------------
|
||||||
**id** | **int** | | [optional]
|
**id** | **int** | | [optional]
|
||||||
**name** | **string** | | [optional]
|
**name** | **string** | | [default to 'default-name']
|
||||||
|
|
||||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
[[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/Child.md
Normal file
16
samples/client/petstore/perl/docs/Child.md
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
# WWW::OpenAPIClient::Object::Child
|
||||||
|
|
||||||
|
## Load the model package
|
||||||
|
```perl
|
||||||
|
use WWW::OpenAPIClient::Object::Child;
|
||||||
|
```
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
**age** | **int** | | [optional]
|
||||||
|
**first_name** | **string** | | [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)
|
||||||
|
|
||||||
|
|
||||||
54
samples/client/petstore/perl/docs/DefaultApi.md
Normal file
54
samples/client/petstore/perl/docs/DefaultApi.md
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
# WWW::OpenAPIClient::DefaultApi
|
||||||
|
|
||||||
|
## Load the API package
|
||||||
|
```perl
|
||||||
|
use WWW::OpenAPIClient::Object::DefaultApi;
|
||||||
|
```
|
||||||
|
|
||||||
|
All URIs are relative to *http://petstore.swagger.io:80/v2*
|
||||||
|
|
||||||
|
Method | HTTP request | Description
|
||||||
|
------------- | ------------- | -------------
|
||||||
|
[**foo_get**](DefaultApi.md#foo_get) | **GET** /foo |
|
||||||
|
|
||||||
|
|
||||||
|
# **foo_get**
|
||||||
|
> InlineResponseDefault foo_get()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Example
|
||||||
|
```perl
|
||||||
|
use Data::Dumper;
|
||||||
|
use WWW::OpenAPIClient::DefaultApi;
|
||||||
|
my $api_instance = WWW::OpenAPIClient::DefaultApi->new(
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
eval {
|
||||||
|
my $result = $api_instance->foo_get();
|
||||||
|
print Dumper($result);
|
||||||
|
};
|
||||||
|
if ($@) {
|
||||||
|
warn "Exception when calling DefaultApi->foo_get: $@\n";
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
This endpoint does not need any parameter.
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
[**InlineResponseDefault**](InlineResponseDefault.md)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
No authorization required
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **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)
|
||||||
|
|
||||||
@@ -8,8 +8,6 @@ use WWW::OpenAPIClient::Object::Dog;
|
|||||||
## Properties
|
## Properties
|
||||||
Name | Type | Description | Notes
|
Name | Type | Description | Notes
|
||||||
------------ | ------------- | ------------- | -------------
|
------------ | ------------- | ------------- | -------------
|
||||||
**class_name** | **string** | |
|
|
||||||
**color** | **string** | | [optional] [default to 'red']
|
|
||||||
**breed** | **string** | | [optional]
|
**breed** | **string** | | [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)
|
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ Method | HTTP request | Description
|
|||||||
[**test_client_model**](FakeApi.md#test_client_model) | **PATCH** /fake | To test \"client\" model
|
[**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 假端點 偽のエンドポイント 가짜 엔드 포인트
|
[**test_endpoint_parameters**](FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||||
[**test_enum_parameters**](FakeApi.md#test_enum_parameters) | **GET** /fake | To test enum parameters
|
[**test_enum_parameters**](FakeApi.md#test_enum_parameters) | **GET** /fake | To test enum parameters
|
||||||
|
[**test_group_parameters**](FakeApi.md#test_group_parameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional)
|
||||||
[**test_inline_additional_properties**](FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties
|
[**test_inline_additional_properties**](FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties
|
||||||
[**test_json_form_data**](FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data
|
[**test_json_form_data**](FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data
|
||||||
|
|
||||||
@@ -476,6 +477,61 @@ 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)
|
[[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_group_parameters**
|
||||||
|
> test_group_parameters(required_string_group => $required_string_group, required_boolean_group => $required_boolean_group, required_int64_group => $required_int64_group, string_group => $string_group, boolean_group => $boolean_group, int64_group => $int64_group)
|
||||||
|
|
||||||
|
Fake endpoint to test group parameters (optional)
|
||||||
|
|
||||||
|
Fake endpoint to test group parameters (optional)
|
||||||
|
|
||||||
|
### Example
|
||||||
|
```perl
|
||||||
|
use Data::Dumper;
|
||||||
|
use WWW::OpenAPIClient::FakeApi;
|
||||||
|
my $api_instance = WWW::OpenAPIClient::FakeApi->new(
|
||||||
|
);
|
||||||
|
|
||||||
|
my $required_string_group = 56; # int | Required String in group parameters
|
||||||
|
my $required_boolean_group = null; # boolean | Required Boolean in group parameters
|
||||||
|
my $required_int64_group = 789; # int | Required Integer in group parameters
|
||||||
|
my $string_group = 56; # int | String in group parameters
|
||||||
|
my $boolean_group = null; # boolean | Boolean in group parameters
|
||||||
|
my $int64_group = 789; # int | Integer in group parameters
|
||||||
|
|
||||||
|
eval {
|
||||||
|
$api_instance->test_group_parameters(required_string_group => $required_string_group, required_boolean_group => $required_boolean_group, required_int64_group => $required_int64_group, string_group => $string_group, boolean_group => $boolean_group, int64_group => $int64_group);
|
||||||
|
};
|
||||||
|
if ($@) {
|
||||||
|
warn "Exception when calling FakeApi->test_group_parameters: $@\n";
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**required_string_group** | **int**| Required String in group parameters |
|
||||||
|
**required_boolean_group** | **boolean**| Required Boolean in group parameters |
|
||||||
|
**required_int64_group** | **int**| Required Integer in group parameters |
|
||||||
|
**string_group** | **int**| String in group parameters | [optional]
|
||||||
|
**boolean_group** | **boolean**| Boolean in group parameters | [optional]
|
||||||
|
**int64_group** | **int**| Integer in group parameters | [optional]
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
void (empty response body)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
No authorization required
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **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_inline_additional_properties**
|
# **test_inline_additional_properties**
|
||||||
> test_inline_additional_properties(request_body => $request_body)
|
> test_inline_additional_properties(request_body => $request_body)
|
||||||
|
|
||||||
|
|||||||
15
samples/client/petstore/perl/docs/Foo.md
Normal file
15
samples/client/petstore/perl/docs/Foo.md
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
# WWW::OpenAPIClient::Object::Foo
|
||||||
|
|
||||||
|
## Load the model package
|
||||||
|
```perl
|
||||||
|
use WWW::OpenAPIClient::Object::Foo;
|
||||||
|
```
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
**bar** | **string** | | [optional] [default to 'bar']
|
||||||
|
|
||||||
|
[[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/Human.md
Normal file
16
samples/client/petstore/perl/docs/Human.md
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
# WWW::OpenAPIClient::Object::Human
|
||||||
|
|
||||||
|
## Load the model package
|
||||||
|
```perl
|
||||||
|
use WWW::OpenAPIClient::Object::Human;
|
||||||
|
```
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
**___type** | **string** | | [optional]
|
||||||
|
**body** | **string** | |
|
||||||
|
|
||||||
|
[[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/InlineObject.md
Normal file
16
samples/client/petstore/perl/docs/InlineObject.md
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
# WWW::OpenAPIClient::Object::InlineObject
|
||||||
|
|
||||||
|
## Load the model package
|
||||||
|
```perl
|
||||||
|
use WWW::OpenAPIClient::Object::InlineObject;
|
||||||
|
```
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
**name** | **string** | Updated name of the pet | [optional]
|
||||||
|
**status** | **string** | Updated status of the pet | [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/InlineObject1.md
Normal file
16
samples/client/petstore/perl/docs/InlineObject1.md
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
# WWW::OpenAPIClient::Object::InlineObject1
|
||||||
|
|
||||||
|
## Load the model package
|
||||||
|
```perl
|
||||||
|
use WWW::OpenAPIClient::Object::InlineObject1;
|
||||||
|
```
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
**additional_metadata** | **string** | Additional data to pass to server | [optional]
|
||||||
|
**file** | **string** | file to upload | [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/InlineObject2.md
Normal file
16
samples/client/petstore/perl/docs/InlineObject2.md
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
# WWW::OpenAPIClient::Object::InlineObject2
|
||||||
|
|
||||||
|
## Load the model package
|
||||||
|
```perl
|
||||||
|
use WWW::OpenAPIClient::Object::InlineObject2;
|
||||||
|
```
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
**enum_form_string_array** | **ARRAY[string]** | Form parameter enum test (string array) | [optional]
|
||||||
|
**enum_form_string** | **string** | Form parameter enum test (string) | [optional] [default to '-efg']
|
||||||
|
|
||||||
|
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
|
||||||
28
samples/client/petstore/perl/docs/InlineObject3.md
Normal file
28
samples/client/petstore/perl/docs/InlineObject3.md
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
# WWW::OpenAPIClient::Object::InlineObject3
|
||||||
|
|
||||||
|
## Load the model package
|
||||||
|
```perl
|
||||||
|
use WWW::OpenAPIClient::Object::InlineObject3;
|
||||||
|
```
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
**integer** | **int** | None | [optional]
|
||||||
|
**int32** | **int** | None | [optional]
|
||||||
|
**int64** | **int** | None | [optional]
|
||||||
|
**number** | **double** | None |
|
||||||
|
**float** | **double** | None | [optional]
|
||||||
|
**double** | **double** | None |
|
||||||
|
**string** | **string** | None | [optional]
|
||||||
|
**pattern_without_delimiter** | **string** | None |
|
||||||
|
**byte** | **string** | None |
|
||||||
|
**binary** | **string** | None | [optional]
|
||||||
|
**date** | **DateTime** | None | [optional]
|
||||||
|
**date_time** | **DateTime** | None | [optional]
|
||||||
|
**password** | **string** | None | [optional]
|
||||||
|
**callback** | **string** | None | [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/InlineObject4.md
Normal file
16
samples/client/petstore/perl/docs/InlineObject4.md
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
# WWW::OpenAPIClient::Object::InlineObject4
|
||||||
|
|
||||||
|
## Load the model package
|
||||||
|
```perl
|
||||||
|
use WWW::OpenAPIClient::Object::InlineObject4;
|
||||||
|
```
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
**param** | **string** | field1 |
|
||||||
|
**param2** | **string** | field2 |
|
||||||
|
|
||||||
|
[[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/InlineObject5.md
Normal file
16
samples/client/petstore/perl/docs/InlineObject5.md
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
# WWW::OpenAPIClient::Object::InlineObject5
|
||||||
|
|
||||||
|
## Load the model package
|
||||||
|
```perl
|
||||||
|
use WWW::OpenAPIClient::Object::InlineObject5;
|
||||||
|
```
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
**additional_metadata** | **string** | Additional data to pass to server | [optional]
|
||||||
|
**required_file** | **string** | file to upload |
|
||||||
|
|
||||||
|
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
|
||||||
15
samples/client/petstore/perl/docs/InlineResponseDefault.md
Normal file
15
samples/client/petstore/perl/docs/InlineResponseDefault.md
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
# WWW::OpenAPIClient::Object::InlineResponseDefault
|
||||||
|
|
||||||
|
## Load the model package
|
||||||
|
```perl
|
||||||
|
use WWW::OpenAPIClient::Object::InlineResponseDefault;
|
||||||
|
```
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
**string** | [**Foo**](Foo.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)
|
||||||
|
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@ Name | Type | Description | Notes
|
|||||||
**map_map_of_string** | **HASH[string,HASH[string,string]]** | | [optional]
|
**map_map_of_string** | **HASH[string,HASH[string,string]]** | | [optional]
|
||||||
**map_of_enum_string** | **HASH[string,string]** | | [optional]
|
**map_of_enum_string** | **HASH[string,string]** | | [optional]
|
||||||
**direct_map** | **HASH[string,boolean]** | | [optional]
|
**direct_map** | **HASH[string,boolean]** | | [optional]
|
||||||
**indirect_map** | [**StringBooleanMap**](StringBooleanMap.md) | | [optional]
|
**indirect_map** | **HASH[string,boolean]** | | [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)
|
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
|||||||
20
samples/client/petstore/perl/docs/Person.md
Normal file
20
samples/client/petstore/perl/docs/Person.md
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
# WWW::OpenAPIClient::Object::Person
|
||||||
|
|
||||||
|
## Load the model package
|
||||||
|
```perl
|
||||||
|
use WWW::OpenAPIClient::Object::Person;
|
||||||
|
```
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
**___type** | **string** | | [optional]
|
||||||
|
**last_name** | **string** | | [optional]
|
||||||
|
**first_name** | **string** | | [optional]
|
||||||
|
**duplicated_optional** | **string** | | [optional]
|
||||||
|
**duplicated_required** | **string** | |
|
||||||
|
**person_required** | **DateTime** | |
|
||||||
|
|
||||||
|
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
|
||||||
@@ -180,7 +180,7 @@ my $api_instance = WWW::OpenAPIClient::PetApi->new(
|
|||||||
access_token => 'YOUR_ACCESS_TOKEN',
|
access_token => 'YOUR_ACCESS_TOKEN',
|
||||||
);
|
);
|
||||||
|
|
||||||
my $tags = [("inner_example")]; # ARRAY[string] | Tags to filter by
|
my $tags = [("null")]; # ARRAY[string] | Tags to filter by
|
||||||
|
|
||||||
eval {
|
eval {
|
||||||
my $result = $api_instance->find_pets_by_tags(tags => $tags);
|
my $result = $api_instance->find_pets_by_tags(tags => $tags);
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
=begin comment
|
=begin comment
|
||||||
|
|
||||||
OpenAPI Petstore
|
OpenAPI Petstore
|
||||||
@@ -23,7 +22,7 @@ package WWW::OpenAPIClient::AnotherFakeApi;
|
|||||||
require 5.6.0;
|
require 5.6.0;
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use utf8;
|
use utf8;
|
||||||
use Exporter;
|
use Exporter;
|
||||||
use Carp qw( croak );
|
use Carp qw( croak );
|
||||||
use Log::Any qw($log);
|
use Log::Any qw($log);
|
||||||
@@ -32,16 +31,15 @@ use WWW::OpenAPIClient::ApiClient;
|
|||||||
|
|
||||||
use base "Class::Data::Inheritable";
|
use base "Class::Data::Inheritable";
|
||||||
|
|
||||||
__PACKAGE__->mk_classdata( 'method_documentation' => {} );
|
__PACKAGE__->mk_classdata('method_documentation' => {});
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my $class = shift;
|
my $class = shift;
|
||||||
my $api_client;
|
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];
|
$api_client = $_[0];
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$api_client = WWW::OpenAPIClient::ApiClient->new(@_);
|
$api_client = WWW::OpenAPIClient::ApiClient->new(@_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,60 +47,55 @@ sub new {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# call_123_test_special_tags
|
# call_123_test_special_tags
|
||||||
#
|
#
|
||||||
# To test special tags
|
# To test special tags
|
||||||
#
|
#
|
||||||
# @param Client $client client model (required)
|
# @param Client $client client model (required)
|
||||||
{
|
{
|
||||||
my $params = {
|
my $params = {
|
||||||
'client' => {
|
'client' => {
|
||||||
data_type => 'Client',
|
data_type => 'Client',
|
||||||
description => 'client model',
|
description => 'client model',
|
||||||
required => '1',
|
required => '1',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
__PACKAGE__->method_documentation->{'call_123_test_special_tags'} = {
|
__PACKAGE__->method_documentation->{ 'call_123_test_special_tags' } = {
|
||||||
summary => 'To test special tags',
|
summary => 'To test special tags',
|
||||||
params => $params,
|
params => $params,
|
||||||
returns => 'Client',
|
returns => 'Client',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
# @return Client
|
# @return Client
|
||||||
#
|
#
|
||||||
sub call_123_test_special_tags {
|
sub call_123_test_special_tags {
|
||||||
my ( $self, %args ) = @_;
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
# verify the required parameter 'client' is set
|
# verify the required parameter 'client' is set
|
||||||
unless ( exists $args{'client'} ) {
|
unless (exists $args{'client'}) {
|
||||||
croak(
|
croak("Missing the required parameter 'client' when calling call_123_test_special_tags");
|
||||||
"Missing the required parameter 'client' when calling call_123_test_special_tags"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# parse inputs
|
# parse inputs
|
||||||
my $_resource_path = '/another-fake/dummy';
|
my $_resource_path = '/another-fake/dummy';
|
||||||
|
|
||||||
my $_method = 'PATCH';
|
my $_method = 'PATCH';
|
||||||
my $query_params = {};
|
my $query_params = {};
|
||||||
my $header_params = {};
|
my $header_params = {};
|
||||||
my $form_params = {};
|
my $form_params = {};
|
||||||
|
|
||||||
# 'Accept' and 'Content-Type' header
|
# 'Accept' and 'Content-Type' header
|
||||||
my $_header_accept =
|
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
|
||||||
$self->{api_client}->select_header_accept('application/json');
|
|
||||||
if ($_header_accept) {
|
if ($_header_accept) {
|
||||||
$header_params->{'Accept'} = $_header_accept;
|
$header_params->{'Accept'} = $_header_accept;
|
||||||
}
|
}
|
||||||
$header_params->{'Content-Type'} =
|
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/json');
|
||||||
$self->{api_client}->select_header_content_type('application/json');
|
|
||||||
|
|
||||||
my $_body_data;
|
my $_body_data;
|
||||||
|
|
||||||
# body params
|
# body params
|
||||||
if ( exists $args{'client'} ) {
|
if ( exists $args{'client'}) {
|
||||||
$_body_data = $args{'client'};
|
$_body_data = $args{'client'};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,15 +103,13 @@ sub call_123_test_special_tags {
|
|||||||
my $auth_settings = [qw()];
|
my $auth_settings = [qw()];
|
||||||
|
|
||||||
# make the API Call
|
# make the API Call
|
||||||
my $response = $self->{api_client}->call_api(
|
my $response = $self->{api_client}->call_api($_resource_path, $_method,
|
||||||
$_resource_path, $_method, $query_params, $form_params,
|
$query_params, $form_params,
|
||||||
$header_params, $_body_data, $auth_settings
|
$header_params, $_body_data, $auth_settings);
|
||||||
);
|
if (!$response) {
|
||||||
if ( !$response ) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
my $_response_object =
|
my $_response_object = $self->{api_client}->deserialize('Client', $response);
|
||||||
$self->{api_client}->deserialize( 'Client', $response );
|
|
||||||
return $_response_object;
|
return $_response_object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
=begin comment
|
=begin comment
|
||||||
|
|
||||||
OpenAPI Petstore
|
OpenAPI Petstore
|
||||||
@@ -40,25 +39,22 @@ use Module::Runtime qw(use_module);
|
|||||||
|
|
||||||
use WWW::OpenAPIClient::Configuration;
|
use WWW::OpenAPIClient::Configuration;
|
||||||
|
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my $class = shift;
|
my $class = shift;
|
||||||
|
|
||||||
my $config;
|
my $config;
|
||||||
if ( $_[0]
|
if ( $_[0] && ref $_[0] && ref $_[0] eq 'WWW::OpenAPIClient::Configuration' ) {
|
||||||
&& ref $_[0]
|
|
||||||
&& ref $_[0] eq 'WWW::OpenAPIClient::Configuration' )
|
|
||||||
{
|
|
||||||
$config = $_[0];
|
$config = $_[0];
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$config = WWW::OpenAPIClient::Configuration->new(@_);
|
$config = WWW::OpenAPIClient::Configuration->new(@_);
|
||||||
}
|
}
|
||||||
|
|
||||||
my (%args) = (
|
my (%args) = (
|
||||||
'ua' => LWP::UserAgent->new,
|
'ua' => LWP::UserAgent->new,
|
||||||
'config' => $config,
|
'config' => $config,
|
||||||
);
|
);
|
||||||
|
|
||||||
return bless \%args, $class;
|
return bless \%args, $class;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,17 +63,17 @@ sub new {
|
|||||||
# @param string $user_agent The user agent of the API client
|
# @param string $user_agent The user agent of the API client
|
||||||
#
|
#
|
||||||
sub set_user_agent {
|
sub set_user_agent {
|
||||||
my ( $self, $user_agent ) = @_;
|
my ($self, $user_agent) = @_;
|
||||||
$self->{http_user_agent} = $user_agent;
|
$self->{http_user_agent}= $user_agent;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Set timeout
|
# Set timeout
|
||||||
#
|
#
|
||||||
# @param integer $seconds Number of seconds before timing out [set to 0 for no timeout]
|
# @param integer $seconds Number of seconds before timing out [set to 0 for no timeout]
|
||||||
#
|
#
|
||||||
sub set_timeout {
|
sub set_timeout {
|
||||||
my ( $self, $seconds ) = @_;
|
my ($self, $seconds) = @_;
|
||||||
if ( !looks_like_number($seconds) ) {
|
if (!looks_like_number($seconds)) {
|
||||||
croak('Timeout variable must be numeric.');
|
croak('Timeout variable must be numeric.');
|
||||||
}
|
}
|
||||||
$self->{http_timeout} = $seconds;
|
$self->{http_timeout} = $seconds;
|
||||||
@@ -92,86 +88,72 @@ sub set_timeout {
|
|||||||
# @return mixed
|
# @return mixed
|
||||||
sub call_api {
|
sub call_api {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my (
|
my ($resource_path, $method, $query_params, $post_params, $header_params, $body_data, $auth_settings) = @_;
|
||||||
$resource_path, $method, $query_params, $post_params,
|
|
||||||
$header_params, $body_data, $auth_settings
|
|
||||||
) = @_;
|
|
||||||
|
|
||||||
# update parameters based on authentication settings
|
# update parameters based on authentication settings
|
||||||
$self->update_params_for_auth( $header_params, $query_params,
|
$self->update_params_for_auth($header_params, $query_params, $auth_settings);
|
||||||
$auth_settings );
|
|
||||||
|
|
||||||
my $_url = $self->{config}{base_url} . $resource_path;
|
my $_url = $self->{config}{base_url} . $resource_path;
|
||||||
|
|
||||||
# build query
|
# build query
|
||||||
if (%$query_params) {
|
if (%$query_params) {
|
||||||
$_url =
|
$_url = ($_url . '?' . eval { URI::Query->new($query_params)->stringify });
|
||||||
( $_url . '?' . eval { URI::Query->new($query_params)->stringify } );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# body data
|
# body data
|
||||||
$body_data = to_json( $body_data->to_hash )
|
$body_data = to_json($body_data->to_hash) if defined $body_data && $body_data->can('to_hash'); # model to json string
|
||||||
if defined $body_data
|
|
||||||
&& $body_data->can('to_hash'); # model to json string
|
|
||||||
my $_body_data = %$post_params ? $post_params : $body_data;
|
my $_body_data = %$post_params ? $post_params : $body_data;
|
||||||
|
|
||||||
# Make the HTTP request
|
# Make the HTTP request
|
||||||
my $_request;
|
my $_request;
|
||||||
if ( $method eq 'POST' ) {
|
if ($method eq 'POST') {
|
||||||
|
|
||||||
# multipart
|
# multipart
|
||||||
$header_params->{'Content-Type'} =
|
$header_params->{'Content-Type'} = lc $header_params->{'Content-Type'} eq 'multipart/form' ?
|
||||||
lc $header_params->{'Content-Type'} eq 'multipart/form'
|
'form-data' : $header_params->{'Content-Type'};
|
||||||
? 'form-data'
|
|
||||||
: $header_params->{'Content-Type'};
|
$_request = POST($_url, %$header_params, Content => $_body_data);
|
||||||
|
|
||||||
$_request = POST( $_url, %$header_params, Content => $_body_data );
|
|
||||||
|
|
||||||
}
|
}
|
||||||
elsif ( $method eq 'PUT' ) {
|
elsif ($method eq 'PUT') {
|
||||||
|
|
||||||
# multipart
|
# multipart
|
||||||
$header_params->{'Content-Type'} =
|
$header_params->{'Content-Type'} = lc $header_params->{'Content-Type'} eq 'multipart/form' ?
|
||||||
lc $header_params->{'Content-Type'} eq 'multipart/form'
|
'form-data' : $header_params->{'Content-Type'};
|
||||||
? 'form-data'
|
|
||||||
: $header_params->{'Content-Type'};
|
$_request = PUT($_url, %$header_params, Content => $_body_data);
|
||||||
|
|
||||||
$_request = PUT( $_url, %$header_params, Content => $_body_data );
|
|
||||||
|
|
||||||
}
|
}
|
||||||
elsif ( $method eq 'GET' ) {
|
elsif ($method eq 'GET') {
|
||||||
my $headers = HTTP::Headers->new(%$header_params);
|
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);
|
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);
|
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 {
|
else {
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{ua}
|
$self->{ua}->timeout($self->{http_timeout} || $self->{config}{http_timeout});
|
||||||
->timeout( $self->{http_timeout} || $self->{config}{http_timeout} );
|
$self->{ua}->agent($self->{http_user_agent} || $self->{config}{http_user_agent});
|
||||||
$self->{ua}
|
|
||||||
->agent( $self->{http_user_agent} || $self->{config}{http_user_agent} );
|
$log->debugf("REQUEST: %s", $_request->as_string);
|
||||||
|
|
||||||
$log->debugf( "REQUEST: %s", $_request->as_string );
|
|
||||||
my $_response = $self->{ua}->request($_request);
|
my $_response = $self->{ua}->request($_request);
|
||||||
$log->debugf( "RESPONSE: %s", $_response->as_string );
|
$log->debugf("RESPONSE: %s", $_response->as_string);
|
||||||
|
|
||||||
unless ( $_response->is_success ) {
|
unless ($_response->is_success) {
|
||||||
croak( sprintf "API Exception(%s): %s\n%s",
|
croak(sprintf "API Exception(%s): %s\n%s", $_response->code, $_response->message, $_response->content);
|
||||||
$_response->code, $_response->message, $_response->content );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $_response->content;
|
return $_response->content;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Take value and turn it into a string suitable for inclusion in
|
# Take value and turn it into a string suitable for inclusion in
|
||||||
@@ -179,10 +161,11 @@ sub call_api {
|
|||||||
# @param string $value a string which will be part of the path
|
# @param string $value a string which will be part of the path
|
||||||
# @return string the serialized object
|
# @return string the serialized object
|
||||||
sub to_path_value {
|
sub to_path_value {
|
||||||
my ( $self, $value ) = @_;
|
my ($self, $value) = @_;
|
||||||
return uri_escape( $self->to_string($value) );
|
return uri_escape($self->to_string($value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Take value and turn it into a string suitable for inclusion in
|
# Take value and turn it into a string suitable for inclusion in
|
||||||
# the query, by imploding comma-separated if it's an object.
|
# the query, by imploding comma-separated if it's an object.
|
||||||
# If it's a string, pass through unchanged. It will be url-encoded
|
# If it's a string, pass through unchanged. It will be url-encoded
|
||||||
@@ -190,22 +173,22 @@ sub to_path_value {
|
|||||||
# @param object $object an object to be serialized to a string
|
# @param object $object an object to be serialized to a string
|
||||||
# @return string the serialized object
|
# @return string the serialized object
|
||||||
sub to_query_value {
|
sub to_query_value {
|
||||||
my ( $self, $object ) = @_;
|
my ($self, $object) = @_;
|
||||||
if ( ref($object) eq 'ARRAY' ) {
|
if (ref($object) eq 'ARRAY') {
|
||||||
return join( ',', @$object );
|
return join(',', @$object);
|
||||||
}
|
} else {
|
||||||
else {
|
return $self->to_string($object);
|
||||||
return $self->to_string($object);
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Take value and turn it into a string suitable for inclusion in
|
# Take value and turn it into a string suitable for inclusion in
|
||||||
# the header. If it's a string, pass through unchanged
|
# the header. If it's a string, pass through unchanged
|
||||||
# If it's a datetime object, format it in ISO8601
|
# If it's a datetime object, format it in ISO8601
|
||||||
# @param string $value a string which will be part of the header
|
# @param string $value a string which will be part of the header
|
||||||
# @return string the header string
|
# @return string the header string
|
||||||
sub to_header_value {
|
sub to_header_value {
|
||||||
my ( $self, $value ) = @_;
|
my ($self, $value) = @_;
|
||||||
return $self->to_string($value);
|
return $self->to_string($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -215,7 +198,7 @@ sub to_header_value {
|
|||||||
# @param string $value the value of the form parameter
|
# @param string $value the value of the form parameter
|
||||||
# @return string the form string
|
# @return string the form string
|
||||||
sub to_form_value {
|
sub to_form_value {
|
||||||
my ( $self, $value ) = @_;
|
my ($self, $value) = @_;
|
||||||
return $self->to_string($value);
|
return $self->to_string($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -225,8 +208,8 @@ sub to_form_value {
|
|||||||
# @param string $value the value of the parameter
|
# @param string $value the value of the parameter
|
||||||
# @return string the header string
|
# @return string the header string
|
||||||
sub to_string {
|
sub to_string {
|
||||||
my ( $self, $value ) = @_;
|
my ($self, $value) = @_;
|
||||||
if ( ref($value) eq "DateTime" ) { # datetime in ISO8601 format
|
if (ref($value) eq "DateTime") { # datetime in ISO8601 format
|
||||||
return $value->datetime();
|
return $value->datetime();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -235,216 +218,197 @@ sub to_string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Deserialize a JSON string into an object
|
# Deserialize a JSON string into an object
|
||||||
#
|
#
|
||||||
# @param string $class class name is passed as a string
|
# @param string $class class name is passed as a string
|
||||||
# @param string $data data of the body
|
# @param string $data data of the body
|
||||||
# @return object an instance of $class
|
# @return object an instance of $class
|
||||||
sub deserialize {
|
sub deserialize
|
||||||
my ( $self, $class, $data ) = @_;
|
{
|
||||||
$log->debugf( "deserializing %s for %s", $data, $class );
|
my ($self, $class, $data) = @_;
|
||||||
|
$log->debugf("deserializing %s for %s", $data, $class);
|
||||||
if ( not defined $data ) {
|
|
||||||
|
if (not defined $data) {
|
||||||
return undef;
|
return undef;
|
||||||
}
|
} elsif ( (substr($class, 0, 5)) eq 'HASH[') { #hash
|
||||||
elsif ( ( substr( $class, 0, 5 ) ) eq 'HASH[' ) { #hash
|
if ($class =~ /^HASH\[(.*),(.*)\]$/) {
|
||||||
if ( $class =~ /^HASH\[(.*),(.*)\]$/ ) {
|
my ($key_type, $type) = ($1, $2);
|
||||||
my ( $key_type, $type ) = ( $1, $2 );
|
|
||||||
my %hash;
|
my %hash;
|
||||||
my $decoded_data = decode_json $data;
|
my $decoded_data = decode_json $data;
|
||||||
foreach my $key ( keys %$decoded_data ) {
|
foreach my $key (keys %$decoded_data) {
|
||||||
if ( ref $decoded_data->{$key} eq 'HASH' ) {
|
if (ref $decoded_data->{$key} eq 'HASH') {
|
||||||
$hash{$key} = $self->deserialize( $type,
|
$hash{$key} = $self->deserialize($type, encode_json $decoded_data->{$key});
|
||||||
encode_json $decoded_data->{$key} );
|
} else {
|
||||||
}
|
$hash{$key} = $self->deserialize($type, $decoded_data->{$key});
|
||||||
else {
|
|
||||||
$hash{$key} =
|
|
||||||
$self->deserialize( $type, $decoded_data->{$key} );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return \%hash;
|
return \%hash;
|
||||||
|
} else {
|
||||||
|
#TODO log error
|
||||||
}
|
}
|
||||||
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);
|
||||||
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 $_json_data = decode_json $data;
|
||||||
my @_values = ();
|
my @_values = ();
|
||||||
foreach my $_value (@$_json_data) {
|
foreach my $_value (@$_json_data) {
|
||||||
if ( ref $_value eq 'ARRAY' ) {
|
if (ref $_value eq 'ARRAY') {
|
||||||
push @_values,
|
push @_values, $self->deserialize($_sub_class, encode_json $_value);
|
||||||
$self->deserialize( $_sub_class, encode_json $_value);
|
} else {
|
||||||
}
|
push @_values, $self->deserialize($_sub_class, $_value);
|
||||||
else {
|
|
||||||
push @_values, $self->deserialize( $_sub_class, $_value );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return \@_values;
|
return \@_values;
|
||||||
}
|
} elsif ($class eq 'DateTime') {
|
||||||
elsif ( $class eq 'DateTime' ) {
|
return DateTime->from_epoch(epoch => str2time($data));
|
||||||
return DateTime->from_epoch( epoch => str2time($data) );
|
} elsif (grep /^$class$/, ('string', 'int', 'float', 'bool', 'object')) {
|
||||||
}
|
|
||||||
elsif ( grep /^$class$/, ( 'string', 'int', 'float', 'bool', 'object' ) ) {
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
} else { # model
|
||||||
else { # model
|
|
||||||
my $_instance = use_module("WWW::OpenAPIClient::Object::$class")->new;
|
my $_instance = use_module("WWW::OpenAPIClient::Object::$class")->new;
|
||||||
if ( ref $data eq "HASH" ) {
|
if (ref $data eq "HASH") {
|
||||||
return $_instance->from_hash($data);
|
return $_instance->from_hash($data);
|
||||||
}
|
} else { # string, need to json decode first
|
||||||
else { # string, need to json decode first
|
return $_instance->from_hash(decode_json $data);
|
||||||
return $_instance->from_hash( decode_json $data);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# return 'Accept' based on an array of accept provided
|
# return 'Accept' based on an array of accept provided
|
||||||
# @param [Array] header_accept_array Array fo 'Accept'
|
# @param [Array] header_accept_array Array fo 'Accept'
|
||||||
# @return String Accept (e.g. application/json)
|
# @return String Accept (e.g. application/json)
|
||||||
sub select_header_accept {
|
sub select_header_accept
|
||||||
my ( $self, @header ) = @_;
|
{
|
||||||
|
my ($self, @header) = @_;
|
||||||
if ( @header == 0 || ( @header == 1 && $header[0] eq '' ) ) {
|
|
||||||
|
if (@header == 0 || (@header == 1 && $header[0] eq '')) {
|
||||||
return undef;
|
return undef;
|
||||||
}
|
} elsif (grep(/^application\/json$/i, @header)) {
|
||||||
elsif ( grep( /^application\/json$/i, @header ) ) {
|
|
||||||
return 'application/json';
|
return 'application/json';
|
||||||
|
} else {
|
||||||
|
return join(',', @header);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
return join( ',', @header );
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# return the content type based on an array of content-type provided
|
# return the content type based on an array of content-type provided
|
||||||
# @param [Array] content_type_array Array fo content-type
|
# @param [Array] content_type_array Array fo content-type
|
||||||
# @return String Content-Type (e.g. application/json)
|
# @return String Content-Type (e.g. application/json)
|
||||||
sub select_header_content_type {
|
sub select_header_content_type
|
||||||
my ( $self, @header ) = @_;
|
{
|
||||||
|
my ($self, @header) = @_;
|
||||||
if ( @header == 0 || ( @header == 1 && $header[0] eq '' ) ) {
|
|
||||||
return 'application/json'; # default to application/json
|
if (@header == 0 || (@header == 1 && $header[0] eq '')) {
|
||||||
}
|
return 'application/json'; # default to application/json
|
||||||
elsif ( grep( /^application\/json$/i, @header ) ) {
|
} elsif (grep(/^application\/json$/i, @header)) {
|
||||||
return 'application/json';
|
return 'application/json';
|
||||||
|
} else {
|
||||||
|
return join(',', @header);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
return join( ',', @header );
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get API key (with prefix if set)
|
# Get API key (with prefix if set)
|
||||||
# @param string key name
|
# @param string key name
|
||||||
# @return string API key with the prefix
|
# @return string API key with the prefix
|
||||||
sub get_api_key_with_prefix {
|
sub get_api_key_with_prefix
|
||||||
my ( $self, $key_name ) = @_;
|
{
|
||||||
|
my ($self, $key_name) = @_;
|
||||||
|
|
||||||
my $api_key = $self->{config}{api_key}{$key_name};
|
my $api_key = $self->{config}{api_key}{$key_name};
|
||||||
|
|
||||||
return unless $api_key;
|
return unless $api_key;
|
||||||
|
|
||||||
my $prefix = $self->{config}{api_key_prefix}{$key_name};
|
my $prefix = $self->{config}{api_key_prefix}{$key_name};
|
||||||
return $prefix ? "$prefix $api_key" : $api_key;
|
return $prefix ? "$prefix $api_key" : $api_key;
|
||||||
}
|
}
|
||||||
|
|
||||||
# update header and query param based on authentication setting
|
# update header and query param based on authentication setting
|
||||||
#
|
#
|
||||||
# @param array $headerParams header parameters (by ref)
|
# @param array $headerParams header parameters (by ref)
|
||||||
# @param array $queryParams query parameters (by ref)
|
# @param array $queryParams query parameters (by ref)
|
||||||
# @param array $authSettings array of authentication scheme (e.g ['api_key'])
|
# @param array $authSettings array of authentication scheme (e.g ['api_key'])
|
||||||
sub update_params_for_auth {
|
sub update_params_for_auth {
|
||||||
my ( $self, $header_params, $query_params, $auth_settings ) = @_;
|
my ($self, $header_params, $query_params, $auth_settings) = @_;
|
||||||
|
|
||||||
return $self->_global_auth_setup( $header_params, $query_params )
|
return $self->_global_auth_setup($header_params, $query_params)
|
||||||
unless $auth_settings && @$auth_settings;
|
unless $auth_settings && @$auth_settings;
|
||||||
|
|
||||||
# one endpoint can have more than 1 auth settings
|
# one endpoint can have more than 1 auth settings
|
||||||
foreach my $auth (@$auth_settings) {
|
foreach my $auth (@$auth_settings) {
|
||||||
|
|
||||||
# determine which one to use
|
# determine which one to use
|
||||||
if ( !defined($auth) ) {
|
if (!defined($auth)) {
|
||||||
|
|
||||||
# TODO show warning about auth setting not defined
|
# 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');
|
my $api_key = $self->get_api_key_with_prefix('api_key');
|
||||||
if ($api_key) {
|
if ($api_key) {
|
||||||
$header_params->{'api_key'} = $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');
|
my $api_key = $self->get_api_key_with_prefix('api_key_query');
|
||||||
if ($api_key) {
|
if ($api_key) {
|
||||||
$query_params->{'api_key_query'} = $api_key;
|
$query_params->{'api_key_query'} = $api_key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elsif ( $auth eq 'http_basic_test' ) {
|
elsif ($auth eq 'http_basic_test') {
|
||||||
|
|
||||||
if ( $self->{config}{username} || $self->{config}{password} ) {
|
if ($self->{config}{username} || $self->{config}{password}) {
|
||||||
$header_params->{'Authorization'} =
|
$header_params->{'Authorization'} = 'Basic ' . encode_base64($self->{config}{username} . ":" . $self->{config}{password});
|
||||||
'Basic '
|
|
||||||
. encode_base64( $self->{config}{username} . ":"
|
|
||||||
. $self->{config}{password} );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elsif ( $auth eq 'petstore_auth' ) {
|
elsif ($auth eq 'petstore_auth') {
|
||||||
|
|
||||||
if ( $self->{config}{access_token} ) {
|
if ($self->{config}{access_token}) {
|
||||||
$header_params->{'Authorization'} =
|
$header_params->{'Authorization'} = 'Bearer ' . $self->{config}{access_token};
|
||||||
'Bearer ' . $self->{config}{access_token};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
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,
|
# 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
|
# 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
|
# 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;
|
# auth tokens and if we find any, we use them for all endpoints;
|
||||||
sub _global_auth_setup {
|
sub _global_auth_setup {
|
||||||
my ( $self, $header_params, $query_params ) = @_;
|
my ($self, $header_params, $query_params) = @_;
|
||||||
|
|
||||||
my $tokens = $self->{config}->get_tokens;
|
my $tokens = $self->{config}->get_tokens;
|
||||||
return unless keys %$tokens;
|
return unless keys %$tokens;
|
||||||
|
|
||||||
# basic
|
# basic
|
||||||
if ( my $uname = delete $tokens->{username} ) {
|
if (my $uname = delete $tokens->{username}) {
|
||||||
my $pword = delete $tokens->{password};
|
my $pword = delete $tokens->{password};
|
||||||
$header_params->{'Authorization'} =
|
$header_params->{'Authorization'} = 'Basic '.encode_base64($uname.":".$pword);
|
||||||
'Basic ' . encode_base64( $uname . ":" . $pword );
|
}
|
||||||
}
|
|
||||||
|
# oauth
|
||||||
# oauth
|
if (my $access_token = delete $tokens->{access_token}) {
|
||||||
if ( my $access_token = delete $tokens->{access_token} ) {
|
$header_params->{'Authorization'} = 'Bearer ' . $access_token;
|
||||||
$header_params->{'Authorization'} = 'Bearer ' . $access_token;
|
}
|
||||||
}
|
|
||||||
|
# other keys
|
||||||
# other keys
|
foreach my $token_name (keys %$tokens) {
|
||||||
foreach my $token_name ( keys %$tokens ) {
|
my $in = $tokens->{$token_name}->{in};
|
||||||
my $in = $tokens->{$token_name}->{in};
|
my $token = $self->get_api_key_with_prefix($token_name);
|
||||||
my $token = $self->get_api_key_with_prefix($token_name);
|
if ($in eq 'head') {
|
||||||
if ( $in eq 'head' ) {
|
$header_params->{$token_name} = $token;
|
||||||
$header_params->{$token_name} = $token;
|
}
|
||||||
}
|
elsif ($in eq 'query') {
|
||||||
elsif ( $in eq 'query' ) {
|
$query_params->{$token_name} = $token;
|
||||||
$query_params->{$token_name} = $token;
|
}
|
||||||
}
|
else {
|
||||||
else {
|
die "Don't know where to put token '$token_name' ('$in' is not 'head' or 'query')";
|
||||||
die
|
}
|
||||||
"Don't know where to put token '$token_name' ('$in' is not 'head' or 'query')";
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
=begin comment
|
=begin comment
|
||||||
|
|
||||||
OpenAPI Petstore
|
OpenAPI Petstore
|
||||||
@@ -59,8 +58,9 @@ use WWW::OpenAPIClient::ApiClient;
|
|||||||
=cut
|
=cut
|
||||||
|
|
||||||
# Load all the API classes and construct a lookup table at startup time
|
# Load all the API classes and construct a lookup table at startup time
|
||||||
my %_apis = map { $_ =~ /^WWW::OpenAPIClient::(.*)$/; $1 => $_ }
|
my %_apis = map { $_ =~ /^WWW::OpenAPIClient::(.*)$/; $1 => $_ }
|
||||||
grep { $_ =~ /Api$/ } usesub 'WWW::OpenAPIClient';
|
grep {$_ =~ /Api$/}
|
||||||
|
usesub 'WWW::OpenAPIClient';
|
||||||
|
|
||||||
=head1 new($api_client)
|
=head1 new($api_client)
|
||||||
|
|
||||||
@@ -78,10 +78,9 @@ sub new {
|
|||||||
my ($class) = shift;
|
my ($class) = shift;
|
||||||
|
|
||||||
my $api_client;
|
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];
|
$api_client = $_[0];
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$api_client = WWW::OpenAPIClient::ApiClient->new(@_);
|
$api_client = WWW::OpenAPIClient::ApiClient->new(@_);
|
||||||
}
|
}
|
||||||
bless { api_client => $api_client }, $class;
|
bless { api_client => $api_client }, $class;
|
||||||
@@ -98,10 +97,10 @@ sub new {
|
|||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub get_api {
|
sub get_api {
|
||||||
my ( $self, $which ) = @_;
|
my ($self, $which) = @_;
|
||||||
croak "API not specified" unless $which;
|
croak "API not specified" unless $which;
|
||||||
my $api_class = $_apis{"${which}Api"} || croak "No known API for '$which'";
|
my $api_class = $_apis{"${which}Api"} || croak "No known API for '$which'";
|
||||||
return $api_class->new( $self->api_client );
|
return $api_class->new($self->api_client);
|
||||||
}
|
}
|
||||||
|
|
||||||
=head1 api_client()
|
=head1 api_client()
|
||||||
@@ -115,16 +114,15 @@ sub api_client { $_[0]->{api_client} }
|
|||||||
=head1 apis_available()
|
=head1 apis_available()
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub apis_available {
|
sub apis_available { return map { $_ =~ s/Api$//; $_ } sort keys %_apis }
|
||||||
return map { $_ =~ s/Api$//; $_ } sort keys %_apis;
|
|
||||||
}
|
|
||||||
|
|
||||||
=head1 classname_for()
|
=head1 classname_for()
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub classname_for {
|
sub classname_for {
|
||||||
my ( $self, $api_name ) = @_;
|
my ($self, $api_name) = @_;
|
||||||
return $_apis{"${api_name}Api"};
|
return $_apis{"${api_name}Api"};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
=begin comment
|
=begin comment
|
||||||
|
|
||||||
OpenAPI Petstore
|
OpenAPI Petstore
|
||||||
@@ -92,81 +91,80 @@ default: http://petstore.swagger.io:80/v2
|
|||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my ( $self, %p ) = ( shift, @_ );
|
my ($self, %p) = (shift,@_);
|
||||||
|
|
||||||
# class/static variables
|
# class/static variables
|
||||||
$p{http_timeout} //= 180;
|
$p{http_timeout} //= 180;
|
||||||
$p{http_user_agent} //= 'OpenAPI-Generator/1.0.0/perl';
|
$p{http_user_agent} //= 'OpenAPI-Generator/1.0.0/perl';
|
||||||
|
|
||||||
# authentication setting
|
# authentication setting
|
||||||
$p{api_key} //= {};
|
$p{api_key} //= {};
|
||||||
$p{api_key_prefix} //= {};
|
$p{api_key_prefix} //= {};
|
||||||
$p{api_key_in} //= {};
|
$p{api_key_in} //= {};
|
||||||
|
|
||||||
# username and password for HTTP basic authentication
|
# username and password for HTTP basic authentication
|
||||||
$p{username} //= '';
|
$p{username} //= '';
|
||||||
$p{password} //= '';
|
$p{password} //= '';
|
||||||
|
|
||||||
# access token for OAuth
|
# access token for OAuth
|
||||||
$p{access_token} //= '';
|
$p{access_token} //= '';
|
||||||
|
|
||||||
# base_url
|
# base_url
|
||||||
$p{base_url} //= 'http://petstore.swagger.io:80/v2';
|
$p{base_url} //= 'http://petstore.swagger.io:80/v2';
|
||||||
|
|
||||||
return bless \%p => $self;
|
return bless \%p => $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sub get_tokens {
|
sub get_tokens {
|
||||||
my $self = shift;
|
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 $tokens = {};
|
return $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 {
|
sub clear_tokens {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my %tokens = %{ $self->get_tokens }; # copy
|
my %tokens = %{$self->get_tokens}; # copy
|
||||||
|
|
||||||
|
$self->{username} = '';
|
||||||
|
$self->{password} = '';
|
||||||
|
$self->{access_token} = '';
|
||||||
|
|
||||||
$self->{username} = '';
|
$self->{api_key} = {};
|
||||||
$self->{password} = '';
|
$self->{api_key_prefix} = {};
|
||||||
$self->{access_token} = '';
|
$self->{api_key_in} = {};
|
||||||
|
|
||||||
$self->{api_key} = {};
|
return \%tokens;
|
||||||
$self->{api_key_prefix} = {};
|
|
||||||
$self->{api_key_in} = {};
|
|
||||||
|
|
||||||
return \%tokens;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub accept_tokens {
|
sub accept_tokens {
|
||||||
my ( $self, $tokens ) = @_;
|
my ($self, $tokens) = @_;
|
||||||
|
|
||||||
foreach my $known_name (qw(username password access_token)) {
|
foreach my $known_name (qw(username password access_token)) {
|
||||||
next unless $tokens->{$known_name};
|
next unless $tokens->{$known_name};
|
||||||
$self->{$known_name} = delete $tokens->{$known_name};
|
$self->{$known_name} = delete $tokens->{$known_name};
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach my $token_name ( keys %$tokens ) {
|
foreach my $token_name (keys %$tokens) {
|
||||||
$self->{api_key}{$token_name} = $tokens->{$token_name}{token};
|
$self->{api_key}{$token_name} = $tokens->{$token_name}{token};
|
||||||
if ( $tokens->{$token_name}{prefix} ) {
|
if ($tokens->{$token_name}{prefix}) {
|
||||||
$self->{api_key_prefix}{$token_name} =
|
$self->{api_key_prefix}{$token_name} = $tokens->{$token_name}{prefix};
|
||||||
$tokens->{$token_name}{prefix};
|
}
|
||||||
}
|
my $in = $tokens->{$token_name}->{in} || 'head';
|
||||||
my $in = $tokens->{$token_name}->{in} || 'head';
|
croak "Tokens can only go in 'head' or 'query' (not in '$in')" unless $in =~ /^(?:head|query)$/;
|
||||||
croak "Tokens can only go in 'head' or 'query' (not in '$in')"
|
$self->{api_key_in}{$token_name} = $in;
|
||||||
unless $in =~ /^(?:head|query)$/;
|
}
|
||||||
$self->{api_key_in}{$token_name} = $in;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|||||||
100
samples/client/petstore/perl/lib/WWW/OpenAPIClient/DefaultApi.pm
Normal file
100
samples/client/petstore/perl/lib/WWW/OpenAPIClient/DefaultApi.pm
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
=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::DefaultApi;
|
||||||
|
|
||||||
|
require 5.6.0;
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use utf8;
|
||||||
|
use Exporter;
|
||||||
|
use Carp qw( croak );
|
||||||
|
use Log::Any qw($log);
|
||||||
|
|
||||||
|
use WWW::OpenAPIClient::ApiClient;
|
||||||
|
|
||||||
|
use base "Class::Data::Inheritable";
|
||||||
|
|
||||||
|
__PACKAGE__->mk_classdata('method_documentation' => {});
|
||||||
|
|
||||||
|
sub new {
|
||||||
|
my $class = shift;
|
||||||
|
my $api_client;
|
||||||
|
|
||||||
|
if ($_[0] && ref $_[0] && ref $_[0] eq 'WWW::OpenAPIClient::ApiClient' ) {
|
||||||
|
$api_client = $_[0];
|
||||||
|
} else {
|
||||||
|
$api_client = WWW::OpenAPIClient::ApiClient->new(@_);
|
||||||
|
}
|
||||||
|
|
||||||
|
bless { api_client => $api_client }, $class;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# foo_get
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#
|
||||||
|
{
|
||||||
|
my $params = {
|
||||||
|
};
|
||||||
|
__PACKAGE__->method_documentation->{ 'foo_get' } = {
|
||||||
|
summary => '',
|
||||||
|
params => $params,
|
||||||
|
returns => 'InlineResponseDefault',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
# @return InlineResponseDefault
|
||||||
|
#
|
||||||
|
sub foo_get {
|
||||||
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
|
# parse inputs
|
||||||
|
my $_resource_path = '/foo';
|
||||||
|
|
||||||
|
my $_method = 'GET';
|
||||||
|
my $query_params = {};
|
||||||
|
my $header_params = {};
|
||||||
|
my $form_params = {};
|
||||||
|
|
||||||
|
# 'Accept' and 'Content-Type' header
|
||||||
|
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
|
||||||
|
if ($_header_accept) {
|
||||||
|
$header_params->{'Accept'} = $_header_accept;
|
||||||
|
}
|
||||||
|
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||||
|
|
||||||
|
my $_body_data;
|
||||||
|
# authentication setting, if any
|
||||||
|
my $auth_settings = [qw()];
|
||||||
|
|
||||||
|
# make the API Call
|
||||||
|
my $response = $self->{api_client}->call_api($_resource_path, $_method,
|
||||||
|
$query_params, $form_params,
|
||||||
|
$header_params, $_body_data, $auth_settings);
|
||||||
|
if (!$response) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
my $_response_object = $self->{api_client}->deserialize('InlineResponseDefault', $response);
|
||||||
|
return $_response_object;
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
=begin comment
|
=begin comment
|
||||||
|
|
||||||
OpenAPI Petstore
|
OpenAPI Petstore
|
||||||
@@ -23,7 +22,7 @@ package WWW::OpenAPIClient::FakeClassnameTags123Api;
|
|||||||
require 5.6.0;
|
require 5.6.0;
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use utf8;
|
use utf8;
|
||||||
use Exporter;
|
use Exporter;
|
||||||
use Carp qw( croak );
|
use Carp qw( croak );
|
||||||
use Log::Any qw($log);
|
use Log::Any qw($log);
|
||||||
@@ -32,16 +31,15 @@ use WWW::OpenAPIClient::ApiClient;
|
|||||||
|
|
||||||
use base "Class::Data::Inheritable";
|
use base "Class::Data::Inheritable";
|
||||||
|
|
||||||
__PACKAGE__->mk_classdata( 'method_documentation' => {} );
|
__PACKAGE__->mk_classdata('method_documentation' => {});
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my $class = shift;
|
my $class = shift;
|
||||||
my $api_client;
|
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];
|
$api_client = $_[0];
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$api_client = WWW::OpenAPIClient::ApiClient->new(@_);
|
$api_client = WWW::OpenAPIClient::ApiClient->new(@_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,60 +47,55 @@ sub new {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# test_classname
|
# test_classname
|
||||||
#
|
#
|
||||||
# To test class name in snake case
|
# To test class name in snake case
|
||||||
#
|
#
|
||||||
# @param Client $client client model (required)
|
# @param Client $client client model (required)
|
||||||
{
|
{
|
||||||
my $params = {
|
my $params = {
|
||||||
'client' => {
|
'client' => {
|
||||||
data_type => 'Client',
|
data_type => 'Client',
|
||||||
description => 'client model',
|
description => 'client model',
|
||||||
required => '1',
|
required => '1',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
__PACKAGE__->method_documentation->{'test_classname'} = {
|
__PACKAGE__->method_documentation->{ 'test_classname' } = {
|
||||||
summary => 'To test class name in snake case',
|
summary => 'To test class name in snake case',
|
||||||
params => $params,
|
params => $params,
|
||||||
returns => 'Client',
|
returns => 'Client',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
# @return Client
|
# @return Client
|
||||||
#
|
#
|
||||||
sub test_classname {
|
sub test_classname {
|
||||||
my ( $self, %args ) = @_;
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
# verify the required parameter 'client' is set
|
# verify the required parameter 'client' is set
|
||||||
unless ( exists $args{'client'} ) {
|
unless (exists $args{'client'}) {
|
||||||
croak(
|
croak("Missing the required parameter 'client' when calling test_classname");
|
||||||
"Missing the required parameter 'client' when calling test_classname"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# parse inputs
|
# parse inputs
|
||||||
my $_resource_path = '/fake_classname_test';
|
my $_resource_path = '/fake_classname_test';
|
||||||
|
|
||||||
my $_method = 'PATCH';
|
my $_method = 'PATCH';
|
||||||
my $query_params = {};
|
my $query_params = {};
|
||||||
my $header_params = {};
|
my $header_params = {};
|
||||||
my $form_params = {};
|
my $form_params = {};
|
||||||
|
|
||||||
# 'Accept' and 'Content-Type' header
|
# 'Accept' and 'Content-Type' header
|
||||||
my $_header_accept =
|
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
|
||||||
$self->{api_client}->select_header_accept('application/json');
|
|
||||||
if ($_header_accept) {
|
if ($_header_accept) {
|
||||||
$header_params->{'Accept'} = $_header_accept;
|
$header_params->{'Accept'} = $_header_accept;
|
||||||
}
|
}
|
||||||
$header_params->{'Content-Type'} =
|
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/json');
|
||||||
$self->{api_client}->select_header_content_type('application/json');
|
|
||||||
|
|
||||||
my $_body_data;
|
my $_body_data;
|
||||||
|
|
||||||
# body params
|
# body params
|
||||||
if ( exists $args{'client'} ) {
|
if ( exists $args{'client'}) {
|
||||||
$_body_data = $args{'client'};
|
$_body_data = $args{'client'};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,15 +103,13 @@ sub test_classname {
|
|||||||
my $auth_settings = [qw(api_key_query )];
|
my $auth_settings = [qw(api_key_query )];
|
||||||
|
|
||||||
# make the API Call
|
# make the API Call
|
||||||
my $response = $self->{api_client}->call_api(
|
my $response = $self->{api_client}->call_api($_resource_path, $_method,
|
||||||
$_resource_path, $_method, $query_params, $form_params,
|
$query_params, $form_params,
|
||||||
$header_params, $_body_data, $auth_settings
|
$header_params, $_body_data, $auth_settings);
|
||||||
);
|
if (!$response) {
|
||||||
if ( !$response ) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
my $_response_object =
|
my $_response_object = $self->{api_client}->deserialize('Client', $response);
|
||||||
$self->{api_client}->deserialize( 'Client', $response );
|
|
||||||
return $_response_object;
|
return $_response_object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
=begin comment
|
=begin comment
|
||||||
|
|
||||||
OpenAPI Petstore
|
OpenAPI Petstore
|
||||||
@@ -31,7 +30,8 @@ use Log::Any qw($log);
|
|||||||
use Date::Parse;
|
use Date::Parse;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
|
||||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
|
||||||
|
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||||
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
@@ -59,129 +59,128 @@ Generated by: https://openapi-generator.tech
|
|||||||
# Do not edit the class manually.
|
# Do not edit the class manually.
|
||||||
# Ref: https://openapi-generator.tech
|
# Ref: https://openapi-generator.tech
|
||||||
#
|
#
|
||||||
__PACKAGE__->mk_classdata( 'attribute_map' => {} );
|
__PACKAGE__->mk_classdata('attribute_map' => {});
|
||||||
__PACKAGE__->mk_classdata( 'openapi_types' => {} );
|
__PACKAGE__->mk_classdata('openapi_types' => {});
|
||||||
__PACKAGE__->mk_classdata( 'method_documentation' => {} );
|
__PACKAGE__->mk_classdata('method_documentation' => {});
|
||||||
__PACKAGE__->mk_classdata( 'class_documentation' => {} );
|
__PACKAGE__->mk_classdata('class_documentation' => {});
|
||||||
|
|
||||||
# new object
|
# new plain object
|
||||||
sub new {
|
sub new {
|
||||||
my ( $class, %args ) = @_;
|
my ($class, %args) = @_;
|
||||||
|
|
||||||
my $self = bless {}, $class;
|
my $self = bless {}, $class;
|
||||||
|
|
||||||
foreach my $attribute ( keys %{ $class->attribute_map } ) {
|
$self->init(%args);
|
||||||
my $args_key = $class->attribute_map->{$attribute};
|
|
||||||
$self->$attribute( $args{$args_key} );
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
# initialize the object
|
||||||
|
sub init
|
||||||
|
{
|
||||||
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
|
foreach my $attribute (keys %{$self->attribute_map}) {
|
||||||
|
my $args_key = $self->attribute_map->{$attribute};
|
||||||
|
$self->$attribute( $args{ $args_key } );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# return perl hash
|
# return perl hash
|
||||||
sub to_hash {
|
sub to_hash {
|
||||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
my $self = shift;
|
||||||
|
my $_hash = decode_json(JSON->new->convert_blessed->encode($self));
|
||||||
|
|
||||||
|
return $_hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
# used by JSON for serialization
|
# used by JSON for serialization
|
||||||
sub TO_JSON {
|
sub TO_JSON {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $_data = {};
|
my $_data = {};
|
||||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
foreach my $_key (keys %{$self->attribute_map}) {
|
||||||
if ( defined $self->{$_key} ) {
|
if (defined $self->{$_key}) {
|
||||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
$_data->{$self->attribute_map->{$_key}} = $self->{$_key};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $_data;
|
return $_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
# from Perl hashref
|
# from Perl hashref
|
||||||
sub from_hash {
|
sub from_hash {
|
||||||
my ( $self, $hash ) = @_;
|
my ($self, $hash) = @_;
|
||||||
|
|
||||||
# loop through attributes and use openapi_types to deserialize the data
|
# loop through attributes and use openapi_types to deserialize the data
|
||||||
while ( my ( $_key, $_type ) = each %{ $self->openapi_types } ) {
|
while ( my ($_key, $_type) = each %{$self->openapi_types} ) {
|
||||||
my $_json_attribute = $self->attribute_map->{$_key};
|
my $_json_attribute = $self->attribute_map->{$_key};
|
||||||
if ( $_type =~ /^array\[/i ) { # array
|
if ($_type =~ /^array\[/i) { # array
|
||||||
my $_subclass = substr( $_type, 6, -1 );
|
my $_subclass = substr($_type, 6, -1);
|
||||||
my @_array = ();
|
my @_array = ();
|
||||||
foreach my $_element ( @{ $hash->{$_json_attribute} } ) {
|
foreach my $_element (@{$hash->{$_json_attribute}}) {
|
||||||
push @_array, $self->_deserialize( $_subclass, $_element );
|
push @_array, $self->_deserialize($_subclass, $_element);
|
||||||
}
|
}
|
||||||
$self->{$_key} = \@_array;
|
$self->{$_key} = \@_array;
|
||||||
}
|
} elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
|
||||||
elsif ( exists $hash->{$_json_attribute} )
|
$self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute});
|
||||||
{ #hash(model), primitive, datetime
|
} else {
|
||||||
$self->{$_key} =
|
$log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
|
||||||
$self->_deserialize( $_type, $hash->{$_json_attribute} );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$log->debugf( "Warning: %s (%s) does not exist in input hash\n",
|
|
||||||
$_key, $_json_attribute );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
# deserialize non-array data
|
# deserialize non-array data
|
||||||
sub _deserialize {
|
sub _deserialize {
|
||||||
my ( $self, $type, $data ) = @_;
|
my ($self, $type, $data) = @_;
|
||||||
$log->debugf( "deserializing %s with %s", Dumper($data), $type );
|
$log->debugf("deserializing %s with %s",Dumper($data), $type);
|
||||||
|
|
||||||
if ( $type eq 'DateTime' ) {
|
if ($type eq 'DateTime') {
|
||||||
return DateTime->from_epoch( epoch => str2time($data) );
|
return DateTime->from_epoch(epoch => str2time($data));
|
||||||
}
|
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
|
||||||
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
} else { # hash(model)
|
||||||
else { # hash(model)
|
|
||||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||||
return $_instance->from_hash($data);
|
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__->openapi_types(
|
__PACKAGE__->class_documentation({description => '',
|
||||||
{
|
class => 'AdditionalPropertiesClass',
|
||||||
'map_property' => 'HASH[string,string]',
|
required => [], # TODO
|
||||||
'map_of_map_property' => 'HASH[string,HASH[string,string]]'
|
} );
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
__PACKAGE__->attribute_map(
|
__PACKAGE__->method_documentation({
|
||||||
{
|
'map_property' => {
|
||||||
'map_property' => 'map_property',
|
datatype => 'HASH[string,string]',
|
||||||
'map_of_map_property' => 'map_of_map_property'
|
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__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|||||||
@@ -0,0 +1,231 @@
|
|||||||
|
=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::Adult;
|
||||||
|
|
||||||
|
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::Child;
|
||||||
|
use WWW::OpenAPIClient::Object::Human;
|
||||||
|
use WWW::OpenAPIClient::Object::Person;
|
||||||
|
|
||||||
|
use base ("Class::Accessor", "Class::Data::Inheritable", "WWW::OpenAPIClient::Object::Person", "WWW::OpenAPIClient::Object::Human");
|
||||||
|
|
||||||
|
#
|
||||||
|
#A representation of an adult
|
||||||
|
#
|
||||||
|
# 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 plain object
|
||||||
|
sub new {
|
||||||
|
my ($class, %args) = @_;
|
||||||
|
|
||||||
|
my $self = bless {}, $class;
|
||||||
|
|
||||||
|
$self->init(%args);
|
||||||
|
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
# initialize the object
|
||||||
|
sub init
|
||||||
|
{
|
||||||
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
|
foreach my $attribute (keys %{$self->attribute_map}) {
|
||||||
|
my $args_key = $self->attribute_map->{$attribute};
|
||||||
|
$self->$attribute( $args{ $args_key } );
|
||||||
|
}
|
||||||
|
|
||||||
|
# initialize parent object Person
|
||||||
|
$self->WWW::OpenAPIClient::Object::Person::init(%args);
|
||||||
|
|
||||||
|
# initialize parent object Human
|
||||||
|
$self->WWW::OpenAPIClient::Object::Human::init(%args);
|
||||||
|
}
|
||||||
|
|
||||||
|
# return perl hash
|
||||||
|
sub to_hash {
|
||||||
|
my $self = shift;
|
||||||
|
my $_hash = decode_json(JSON->new->convert_blessed->encode($self));
|
||||||
|
|
||||||
|
# call Person to_hash and then combine hash
|
||||||
|
$_hash = { %$_hash, %$self->WWW::OpenAPIClient::Object::Person::to_hash };
|
||||||
|
|
||||||
|
# call Human to_hash and then combine hash
|
||||||
|
$_hash = { %$_hash, %$self->WWW::OpenAPIClient::Object::Human::to_hash };
|
||||||
|
|
||||||
|
return $_hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
# 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};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# combine parent (Person) TO_JSON
|
||||||
|
$_data = { %$_data, %$self->WWW::OpenAPIClient::Object::Person::TO_JSON };
|
||||||
|
|
||||||
|
# combine parent (Human) TO_JSON
|
||||||
|
$_data = { %$_data, %$self->WWW::OpenAPIClient::Object::Human::TO_JSON };
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# call parent (Person) from_hash
|
||||||
|
$self->WWW::OpenAPIClient::Object::Person::from_hash($hash);
|
||||||
|
|
||||||
|
# call parent (Human) from_hash
|
||||||
|
$self->WWW::OpenAPIClient::Object::Human::from_hash($hash);
|
||||||
|
|
||||||
|
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 => 'A representation of an adult',
|
||||||
|
class => 'Adult',
|
||||||
|
required => [], # TODO
|
||||||
|
} );
|
||||||
|
|
||||||
|
__PACKAGE__->method_documentation({
|
||||||
|
'duplicated_optional' => {
|
||||||
|
datatype => 'int',
|
||||||
|
base_name => 'duplicated_optional',
|
||||||
|
description => '',
|
||||||
|
format => '',
|
||||||
|
read_only => '',
|
||||||
|
},
|
||||||
|
'duplicated_required' => {
|
||||||
|
datatype => 'int',
|
||||||
|
base_name => 'duplicated_required',
|
||||||
|
description => '',
|
||||||
|
format => '',
|
||||||
|
read_only => '',
|
||||||
|
},
|
||||||
|
'children' => {
|
||||||
|
datatype => 'ARRAY[Child]',
|
||||||
|
base_name => 'children',
|
||||||
|
description => '',
|
||||||
|
format => '',
|
||||||
|
read_only => '',
|
||||||
|
},
|
||||||
|
'adult_required' => {
|
||||||
|
datatype => 'boolean',
|
||||||
|
base_name => 'adult_required',
|
||||||
|
description => '',
|
||||||
|
format => '',
|
||||||
|
read_only => '',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
__PACKAGE__->openapi_types( {
|
||||||
|
'duplicated_optional' => 'int',
|
||||||
|
'duplicated_required' => 'int',
|
||||||
|
'children' => 'ARRAY[Child]',
|
||||||
|
'adult_required' => 'boolean'
|
||||||
|
} );
|
||||||
|
|
||||||
|
__PACKAGE__->attribute_map( {
|
||||||
|
'duplicated_optional' => 'duplicated_optional',
|
||||||
|
'duplicated_required' => 'duplicated_required',
|
||||||
|
'children' => 'children',
|
||||||
|
'adult_required' => 'adult_required'
|
||||||
|
} );
|
||||||
|
|
||||||
|
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
||||||
|
|
||||||
|
|
||||||
|
1;
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
=begin comment
|
=begin comment
|
||||||
|
|
||||||
OpenAPI Petstore
|
OpenAPI Petstore
|
||||||
@@ -31,7 +30,8 @@ use Log::Any qw($log);
|
|||||||
use Date::Parse;
|
use Date::Parse;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
|
||||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
|
||||||
|
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||||
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
@@ -59,129 +59,128 @@ Generated by: https://openapi-generator.tech
|
|||||||
# Do not edit the class manually.
|
# Do not edit the class manually.
|
||||||
# Ref: https://openapi-generator.tech
|
# Ref: https://openapi-generator.tech
|
||||||
#
|
#
|
||||||
__PACKAGE__->mk_classdata( 'attribute_map' => {} );
|
__PACKAGE__->mk_classdata('attribute_map' => {});
|
||||||
__PACKAGE__->mk_classdata( 'openapi_types' => {} );
|
__PACKAGE__->mk_classdata('openapi_types' => {});
|
||||||
__PACKAGE__->mk_classdata( 'method_documentation' => {} );
|
__PACKAGE__->mk_classdata('method_documentation' => {});
|
||||||
__PACKAGE__->mk_classdata( 'class_documentation' => {} );
|
__PACKAGE__->mk_classdata('class_documentation' => {});
|
||||||
|
|
||||||
# new object
|
# new plain object
|
||||||
sub new {
|
sub new {
|
||||||
my ( $class, %args ) = @_;
|
my ($class, %args) = @_;
|
||||||
|
|
||||||
my $self = bless {}, $class;
|
my $self = bless {}, $class;
|
||||||
|
|
||||||
foreach my $attribute ( keys %{ $class->attribute_map } ) {
|
$self->init(%args);
|
||||||
my $args_key = $class->attribute_map->{$attribute};
|
|
||||||
$self->$attribute( $args{$args_key} );
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
# initialize the object
|
||||||
|
sub init
|
||||||
|
{
|
||||||
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
|
foreach my $attribute (keys %{$self->attribute_map}) {
|
||||||
|
my $args_key = $self->attribute_map->{$attribute};
|
||||||
|
$self->$attribute( $args{ $args_key } );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# return perl hash
|
# return perl hash
|
||||||
sub to_hash {
|
sub to_hash {
|
||||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
my $self = shift;
|
||||||
|
my $_hash = decode_json(JSON->new->convert_blessed->encode($self));
|
||||||
|
|
||||||
|
return $_hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
# used by JSON for serialization
|
# used by JSON for serialization
|
||||||
sub TO_JSON {
|
sub TO_JSON {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $_data = {};
|
my $_data = {};
|
||||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
foreach my $_key (keys %{$self->attribute_map}) {
|
||||||
if ( defined $self->{$_key} ) {
|
if (defined $self->{$_key}) {
|
||||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
$_data->{$self->attribute_map->{$_key}} = $self->{$_key};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $_data;
|
return $_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
# from Perl hashref
|
# from Perl hashref
|
||||||
sub from_hash {
|
sub from_hash {
|
||||||
my ( $self, $hash ) = @_;
|
my ($self, $hash) = @_;
|
||||||
|
|
||||||
# loop through attributes and use openapi_types to deserialize the data
|
# loop through attributes and use openapi_types to deserialize the data
|
||||||
while ( my ( $_key, $_type ) = each %{ $self->openapi_types } ) {
|
while ( my ($_key, $_type) = each %{$self->openapi_types} ) {
|
||||||
my $_json_attribute = $self->attribute_map->{$_key};
|
my $_json_attribute = $self->attribute_map->{$_key};
|
||||||
if ( $_type =~ /^array\[/i ) { # array
|
if ($_type =~ /^array\[/i) { # array
|
||||||
my $_subclass = substr( $_type, 6, -1 );
|
my $_subclass = substr($_type, 6, -1);
|
||||||
my @_array = ();
|
my @_array = ();
|
||||||
foreach my $_element ( @{ $hash->{$_json_attribute} } ) {
|
foreach my $_element (@{$hash->{$_json_attribute}}) {
|
||||||
push @_array, $self->_deserialize( $_subclass, $_element );
|
push @_array, $self->_deserialize($_subclass, $_element);
|
||||||
}
|
}
|
||||||
$self->{$_key} = \@_array;
|
$self->{$_key} = \@_array;
|
||||||
}
|
} elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
|
||||||
elsif ( exists $hash->{$_json_attribute} )
|
$self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute});
|
||||||
{ #hash(model), primitive, datetime
|
} else {
|
||||||
$self->{$_key} =
|
$log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
|
||||||
$self->_deserialize( $_type, $hash->{$_json_attribute} );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$log->debugf( "Warning: %s (%s) does not exist in input hash\n",
|
|
||||||
$_key, $_json_attribute );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
# deserialize non-array data
|
# deserialize non-array data
|
||||||
sub _deserialize {
|
sub _deserialize {
|
||||||
my ( $self, $type, $data ) = @_;
|
my ($self, $type, $data) = @_;
|
||||||
$log->debugf( "deserializing %s with %s", Dumper($data), $type );
|
$log->debugf("deserializing %s with %s",Dumper($data), $type);
|
||||||
|
|
||||||
if ( $type eq 'DateTime' ) {
|
if ($type eq 'DateTime') {
|
||||||
return DateTime->from_epoch( epoch => str2time($data) );
|
return DateTime->from_epoch(epoch => str2time($data));
|
||||||
}
|
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
|
||||||
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
} else { # hash(model)
|
||||||
else { # hash(model)
|
|
||||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||||
return $_instance->from_hash($data);
|
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__->openapi_types(
|
__PACKAGE__->class_documentation({description => '',
|
||||||
{
|
class => 'Animal',
|
||||||
'class_name' => 'string',
|
required => [], # TODO
|
||||||
'color' => 'string'
|
} );
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
__PACKAGE__->attribute_map(
|
__PACKAGE__->method_documentation({
|
||||||
{
|
'class_name' => {
|
||||||
'class_name' => 'className',
|
datatype => 'string',
|
||||||
'color' => 'color'
|
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__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
=begin comment
|
=begin comment
|
||||||
|
|
||||||
OpenAPI Petstore
|
OpenAPI Petstore
|
||||||
@@ -31,7 +30,8 @@ use Log::Any qw($log);
|
|||||||
use Date::Parse;
|
use Date::Parse;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
|
||||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
|
||||||
|
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||||
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
@@ -59,138 +59,137 @@ Generated by: https://openapi-generator.tech
|
|||||||
# Do not edit the class manually.
|
# Do not edit the class manually.
|
||||||
# Ref: https://openapi-generator.tech
|
# Ref: https://openapi-generator.tech
|
||||||
#
|
#
|
||||||
__PACKAGE__->mk_classdata( 'attribute_map' => {} );
|
__PACKAGE__->mk_classdata('attribute_map' => {});
|
||||||
__PACKAGE__->mk_classdata( 'openapi_types' => {} );
|
__PACKAGE__->mk_classdata('openapi_types' => {});
|
||||||
__PACKAGE__->mk_classdata( 'method_documentation' => {} );
|
__PACKAGE__->mk_classdata('method_documentation' => {});
|
||||||
__PACKAGE__->mk_classdata( 'class_documentation' => {} );
|
__PACKAGE__->mk_classdata('class_documentation' => {});
|
||||||
|
|
||||||
# new object
|
# new plain object
|
||||||
sub new {
|
sub new {
|
||||||
my ( $class, %args ) = @_;
|
my ($class, %args) = @_;
|
||||||
|
|
||||||
my $self = bless {}, $class;
|
my $self = bless {}, $class;
|
||||||
|
|
||||||
foreach my $attribute ( keys %{ $class->attribute_map } ) {
|
$self->init(%args);
|
||||||
my $args_key = $class->attribute_map->{$attribute};
|
|
||||||
$self->$attribute( $args{$args_key} );
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
# initialize the object
|
||||||
|
sub init
|
||||||
|
{
|
||||||
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
|
foreach my $attribute (keys %{$self->attribute_map}) {
|
||||||
|
my $args_key = $self->attribute_map->{$attribute};
|
||||||
|
$self->$attribute( $args{ $args_key } );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# return perl hash
|
# return perl hash
|
||||||
sub to_hash {
|
sub to_hash {
|
||||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
my $self = shift;
|
||||||
|
my $_hash = decode_json(JSON->new->convert_blessed->encode($self));
|
||||||
|
|
||||||
|
return $_hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
# used by JSON for serialization
|
# used by JSON for serialization
|
||||||
sub TO_JSON {
|
sub TO_JSON {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $_data = {};
|
my $_data = {};
|
||||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
foreach my $_key (keys %{$self->attribute_map}) {
|
||||||
if ( defined $self->{$_key} ) {
|
if (defined $self->{$_key}) {
|
||||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
$_data->{$self->attribute_map->{$_key}} = $self->{$_key};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $_data;
|
return $_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
# from Perl hashref
|
# from Perl hashref
|
||||||
sub from_hash {
|
sub from_hash {
|
||||||
my ( $self, $hash ) = @_;
|
my ($self, $hash) = @_;
|
||||||
|
|
||||||
# loop through attributes and use openapi_types to deserialize the data
|
# loop through attributes and use openapi_types to deserialize the data
|
||||||
while ( my ( $_key, $_type ) = each %{ $self->openapi_types } ) {
|
while ( my ($_key, $_type) = each %{$self->openapi_types} ) {
|
||||||
my $_json_attribute = $self->attribute_map->{$_key};
|
my $_json_attribute = $self->attribute_map->{$_key};
|
||||||
if ( $_type =~ /^array\[/i ) { # array
|
if ($_type =~ /^array\[/i) { # array
|
||||||
my $_subclass = substr( $_type, 6, -1 );
|
my $_subclass = substr($_type, 6, -1);
|
||||||
my @_array = ();
|
my @_array = ();
|
||||||
foreach my $_element ( @{ $hash->{$_json_attribute} } ) {
|
foreach my $_element (@{$hash->{$_json_attribute}}) {
|
||||||
push @_array, $self->_deserialize( $_subclass, $_element );
|
push @_array, $self->_deserialize($_subclass, $_element);
|
||||||
}
|
}
|
||||||
$self->{$_key} = \@_array;
|
$self->{$_key} = \@_array;
|
||||||
}
|
} elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
|
||||||
elsif ( exists $hash->{$_json_attribute} )
|
$self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute});
|
||||||
{ #hash(model), primitive, datetime
|
} else {
|
||||||
$self->{$_key} =
|
$log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
|
||||||
$self->_deserialize( $_type, $hash->{$_json_attribute} );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$log->debugf( "Warning: %s (%s) does not exist in input hash\n",
|
|
||||||
$_key, $_json_attribute );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
# deserialize non-array data
|
# deserialize non-array data
|
||||||
sub _deserialize {
|
sub _deserialize {
|
||||||
my ( $self, $type, $data ) = @_;
|
my ($self, $type, $data) = @_;
|
||||||
$log->debugf( "deserializing %s with %s", Dumper($data), $type );
|
$log->debugf("deserializing %s with %s",Dumper($data), $type);
|
||||||
|
|
||||||
if ( $type eq 'DateTime' ) {
|
if ($type eq 'DateTime') {
|
||||||
return DateTime->from_epoch( epoch => str2time($data) );
|
return DateTime->from_epoch(epoch => str2time($data));
|
||||||
}
|
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
|
||||||
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
} else { # hash(model)
|
||||||
else { # hash(model)
|
|
||||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||||
return $_instance->from_hash($data);
|
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__->openapi_types(
|
__PACKAGE__->class_documentation({description => '',
|
||||||
{
|
class => 'ApiResponse',
|
||||||
'code' => 'int',
|
required => [], # TODO
|
||||||
'type' => 'string',
|
} );
|
||||||
'message' => 'string'
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
__PACKAGE__->attribute_map(
|
__PACKAGE__->method_documentation({
|
||||||
{
|
'code' => {
|
||||||
'code' => 'code',
|
datatype => 'int',
|
||||||
'type' => 'type',
|
base_name => 'code',
|
||||||
'message' => 'message'
|
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__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
=begin comment
|
=begin comment
|
||||||
|
|
||||||
OpenAPI Petstore
|
OpenAPI Petstore
|
||||||
@@ -31,7 +30,8 @@ use Log::Any qw($log);
|
|||||||
use Date::Parse;
|
use Date::Parse;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
|
||||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
|
||||||
|
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||||
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
@@ -59,120 +59,119 @@ Generated by: https://openapi-generator.tech
|
|||||||
# Do not edit the class manually.
|
# Do not edit the class manually.
|
||||||
# Ref: https://openapi-generator.tech
|
# Ref: https://openapi-generator.tech
|
||||||
#
|
#
|
||||||
__PACKAGE__->mk_classdata( 'attribute_map' => {} );
|
__PACKAGE__->mk_classdata('attribute_map' => {});
|
||||||
__PACKAGE__->mk_classdata( 'openapi_types' => {} );
|
__PACKAGE__->mk_classdata('openapi_types' => {});
|
||||||
__PACKAGE__->mk_classdata( 'method_documentation' => {} );
|
__PACKAGE__->mk_classdata('method_documentation' => {});
|
||||||
__PACKAGE__->mk_classdata( 'class_documentation' => {} );
|
__PACKAGE__->mk_classdata('class_documentation' => {});
|
||||||
|
|
||||||
# new object
|
# new plain object
|
||||||
sub new {
|
sub new {
|
||||||
my ( $class, %args ) = @_;
|
my ($class, %args) = @_;
|
||||||
|
|
||||||
my $self = bless {}, $class;
|
my $self = bless {}, $class;
|
||||||
|
|
||||||
foreach my $attribute ( keys %{ $class->attribute_map } ) {
|
$self->init(%args);
|
||||||
my $args_key = $class->attribute_map->{$attribute};
|
|
||||||
$self->$attribute( $args{$args_key} );
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
# initialize the object
|
||||||
|
sub init
|
||||||
|
{
|
||||||
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
|
foreach my $attribute (keys %{$self->attribute_map}) {
|
||||||
|
my $args_key = $self->attribute_map->{$attribute};
|
||||||
|
$self->$attribute( $args{ $args_key } );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# return perl hash
|
# return perl hash
|
||||||
sub to_hash {
|
sub to_hash {
|
||||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
my $self = shift;
|
||||||
|
my $_hash = decode_json(JSON->new->convert_blessed->encode($self));
|
||||||
|
|
||||||
|
return $_hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
# used by JSON for serialization
|
# used by JSON for serialization
|
||||||
sub TO_JSON {
|
sub TO_JSON {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $_data = {};
|
my $_data = {};
|
||||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
foreach my $_key (keys %{$self->attribute_map}) {
|
||||||
if ( defined $self->{$_key} ) {
|
if (defined $self->{$_key}) {
|
||||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
$_data->{$self->attribute_map->{$_key}} = $self->{$_key};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $_data;
|
return $_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
# from Perl hashref
|
# from Perl hashref
|
||||||
sub from_hash {
|
sub from_hash {
|
||||||
my ( $self, $hash ) = @_;
|
my ($self, $hash) = @_;
|
||||||
|
|
||||||
# loop through attributes and use openapi_types to deserialize the data
|
# loop through attributes and use openapi_types to deserialize the data
|
||||||
while ( my ( $_key, $_type ) = each %{ $self->openapi_types } ) {
|
while ( my ($_key, $_type) = each %{$self->openapi_types} ) {
|
||||||
my $_json_attribute = $self->attribute_map->{$_key};
|
my $_json_attribute = $self->attribute_map->{$_key};
|
||||||
if ( $_type =~ /^array\[/i ) { # array
|
if ($_type =~ /^array\[/i) { # array
|
||||||
my $_subclass = substr( $_type, 6, -1 );
|
my $_subclass = substr($_type, 6, -1);
|
||||||
my @_array = ();
|
my @_array = ();
|
||||||
foreach my $_element ( @{ $hash->{$_json_attribute} } ) {
|
foreach my $_element (@{$hash->{$_json_attribute}}) {
|
||||||
push @_array, $self->_deserialize( $_subclass, $_element );
|
push @_array, $self->_deserialize($_subclass, $_element);
|
||||||
}
|
}
|
||||||
$self->{$_key} = \@_array;
|
$self->{$_key} = \@_array;
|
||||||
}
|
} elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
|
||||||
elsif ( exists $hash->{$_json_attribute} )
|
$self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute});
|
||||||
{ #hash(model), primitive, datetime
|
} else {
|
||||||
$self->{$_key} =
|
$log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
|
||||||
$self->_deserialize( $_type, $hash->{$_json_attribute} );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$log->debugf( "Warning: %s (%s) does not exist in input hash\n",
|
|
||||||
$_key, $_json_attribute );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
# deserialize non-array data
|
# deserialize non-array data
|
||||||
sub _deserialize {
|
sub _deserialize {
|
||||||
my ( $self, $type, $data ) = @_;
|
my ($self, $type, $data) = @_;
|
||||||
$log->debugf( "deserializing %s with %s", Dumper($data), $type );
|
$log->debugf("deserializing %s with %s",Dumper($data), $type);
|
||||||
|
|
||||||
if ( $type eq 'DateTime' ) {
|
if ($type eq 'DateTime') {
|
||||||
return DateTime->from_epoch( epoch => str2time($data) );
|
return DateTime->from_epoch(epoch => str2time($data));
|
||||||
}
|
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
|
||||||
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
} else { # hash(model)
|
||||||
else { # hash(model)
|
|
||||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||||
return $_instance->from_hash($data);
|
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__->openapi_types(
|
__PACKAGE__->class_documentation({description => '',
|
||||||
{
|
class => 'ArrayOfArrayOfNumberOnly',
|
||||||
'array_array_number' => 'ARRAY[ARRAY[double]]'
|
required => [], # TODO
|
||||||
}
|
} );
|
||||||
);
|
|
||||||
|
|
||||||
__PACKAGE__->attribute_map(
|
__PACKAGE__->method_documentation({
|
||||||
{
|
'array_array_number' => {
|
||||||
'array_array_number' => 'ArrayArrayNumber'
|
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__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
=begin comment
|
=begin comment
|
||||||
|
|
||||||
OpenAPI Petstore
|
OpenAPI Petstore
|
||||||
@@ -31,7 +30,8 @@ use Log::Any qw($log);
|
|||||||
use Date::Parse;
|
use Date::Parse;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
|
||||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
|
||||||
|
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||||
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
@@ -59,120 +59,119 @@ Generated by: https://openapi-generator.tech
|
|||||||
# Do not edit the class manually.
|
# Do not edit the class manually.
|
||||||
# Ref: https://openapi-generator.tech
|
# Ref: https://openapi-generator.tech
|
||||||
#
|
#
|
||||||
__PACKAGE__->mk_classdata( 'attribute_map' => {} );
|
__PACKAGE__->mk_classdata('attribute_map' => {});
|
||||||
__PACKAGE__->mk_classdata( 'openapi_types' => {} );
|
__PACKAGE__->mk_classdata('openapi_types' => {});
|
||||||
__PACKAGE__->mk_classdata( 'method_documentation' => {} );
|
__PACKAGE__->mk_classdata('method_documentation' => {});
|
||||||
__PACKAGE__->mk_classdata( 'class_documentation' => {} );
|
__PACKAGE__->mk_classdata('class_documentation' => {});
|
||||||
|
|
||||||
# new object
|
# new plain object
|
||||||
sub new {
|
sub new {
|
||||||
my ( $class, %args ) = @_;
|
my ($class, %args) = @_;
|
||||||
|
|
||||||
my $self = bless {}, $class;
|
my $self = bless {}, $class;
|
||||||
|
|
||||||
foreach my $attribute ( keys %{ $class->attribute_map } ) {
|
$self->init(%args);
|
||||||
my $args_key = $class->attribute_map->{$attribute};
|
|
||||||
$self->$attribute( $args{$args_key} );
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
# initialize the object
|
||||||
|
sub init
|
||||||
|
{
|
||||||
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
|
foreach my $attribute (keys %{$self->attribute_map}) {
|
||||||
|
my $args_key = $self->attribute_map->{$attribute};
|
||||||
|
$self->$attribute( $args{ $args_key } );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# return perl hash
|
# return perl hash
|
||||||
sub to_hash {
|
sub to_hash {
|
||||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
my $self = shift;
|
||||||
|
my $_hash = decode_json(JSON->new->convert_blessed->encode($self));
|
||||||
|
|
||||||
|
return $_hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
# used by JSON for serialization
|
# used by JSON for serialization
|
||||||
sub TO_JSON {
|
sub TO_JSON {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $_data = {};
|
my $_data = {};
|
||||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
foreach my $_key (keys %{$self->attribute_map}) {
|
||||||
if ( defined $self->{$_key} ) {
|
if (defined $self->{$_key}) {
|
||||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
$_data->{$self->attribute_map->{$_key}} = $self->{$_key};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $_data;
|
return $_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
# from Perl hashref
|
# from Perl hashref
|
||||||
sub from_hash {
|
sub from_hash {
|
||||||
my ( $self, $hash ) = @_;
|
my ($self, $hash) = @_;
|
||||||
|
|
||||||
# loop through attributes and use openapi_types to deserialize the data
|
# loop through attributes and use openapi_types to deserialize the data
|
||||||
while ( my ( $_key, $_type ) = each %{ $self->openapi_types } ) {
|
while ( my ($_key, $_type) = each %{$self->openapi_types} ) {
|
||||||
my $_json_attribute = $self->attribute_map->{$_key};
|
my $_json_attribute = $self->attribute_map->{$_key};
|
||||||
if ( $_type =~ /^array\[/i ) { # array
|
if ($_type =~ /^array\[/i) { # array
|
||||||
my $_subclass = substr( $_type, 6, -1 );
|
my $_subclass = substr($_type, 6, -1);
|
||||||
my @_array = ();
|
my @_array = ();
|
||||||
foreach my $_element ( @{ $hash->{$_json_attribute} } ) {
|
foreach my $_element (@{$hash->{$_json_attribute}}) {
|
||||||
push @_array, $self->_deserialize( $_subclass, $_element );
|
push @_array, $self->_deserialize($_subclass, $_element);
|
||||||
}
|
}
|
||||||
$self->{$_key} = \@_array;
|
$self->{$_key} = \@_array;
|
||||||
}
|
} elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
|
||||||
elsif ( exists $hash->{$_json_attribute} )
|
$self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute});
|
||||||
{ #hash(model), primitive, datetime
|
} else {
|
||||||
$self->{$_key} =
|
$log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
|
||||||
$self->_deserialize( $_type, $hash->{$_json_attribute} );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$log->debugf( "Warning: %s (%s) does not exist in input hash\n",
|
|
||||||
$_key, $_json_attribute );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
# deserialize non-array data
|
# deserialize non-array data
|
||||||
sub _deserialize {
|
sub _deserialize {
|
||||||
my ( $self, $type, $data ) = @_;
|
my ($self, $type, $data) = @_;
|
||||||
$log->debugf( "deserializing %s with %s", Dumper($data), $type );
|
$log->debugf("deserializing %s with %s",Dumper($data), $type);
|
||||||
|
|
||||||
if ( $type eq 'DateTime' ) {
|
if ($type eq 'DateTime') {
|
||||||
return DateTime->from_epoch( epoch => str2time($data) );
|
return DateTime->from_epoch(epoch => str2time($data));
|
||||||
}
|
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
|
||||||
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
} else { # hash(model)
|
||||||
else { # hash(model)
|
|
||||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||||
return $_instance->from_hash($data);
|
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__->openapi_types(
|
__PACKAGE__->class_documentation({description => '',
|
||||||
{
|
class => 'ArrayOfNumberOnly',
|
||||||
'array_number' => 'ARRAY[double]'
|
required => [], # TODO
|
||||||
}
|
} );
|
||||||
);
|
|
||||||
|
|
||||||
__PACKAGE__->attribute_map(
|
__PACKAGE__->method_documentation({
|
||||||
{
|
'array_number' => {
|
||||||
'array_number' => 'ArrayNumber'
|
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__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
=begin comment
|
=begin comment
|
||||||
|
|
||||||
OpenAPI Petstore
|
OpenAPI Petstore
|
||||||
@@ -33,7 +32,7 @@ use DateTime;
|
|||||||
|
|
||||||
use WWW::OpenAPIClient::Object::ReadOnlyFirst;
|
use WWW::OpenAPIClient::Object::ReadOnlyFirst;
|
||||||
|
|
||||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||||
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
@@ -61,138 +60,137 @@ Generated by: https://openapi-generator.tech
|
|||||||
# Do not edit the class manually.
|
# Do not edit the class manually.
|
||||||
# Ref: https://openapi-generator.tech
|
# Ref: https://openapi-generator.tech
|
||||||
#
|
#
|
||||||
__PACKAGE__->mk_classdata( 'attribute_map' => {} );
|
__PACKAGE__->mk_classdata('attribute_map' => {});
|
||||||
__PACKAGE__->mk_classdata( 'openapi_types' => {} );
|
__PACKAGE__->mk_classdata('openapi_types' => {});
|
||||||
__PACKAGE__->mk_classdata( 'method_documentation' => {} );
|
__PACKAGE__->mk_classdata('method_documentation' => {});
|
||||||
__PACKAGE__->mk_classdata( 'class_documentation' => {} );
|
__PACKAGE__->mk_classdata('class_documentation' => {});
|
||||||
|
|
||||||
# new object
|
# new plain object
|
||||||
sub new {
|
sub new {
|
||||||
my ( $class, %args ) = @_;
|
my ($class, %args) = @_;
|
||||||
|
|
||||||
my $self = bless {}, $class;
|
my $self = bless {}, $class;
|
||||||
|
|
||||||
foreach my $attribute ( keys %{ $class->attribute_map } ) {
|
$self->init(%args);
|
||||||
my $args_key = $class->attribute_map->{$attribute};
|
|
||||||
$self->$attribute( $args{$args_key} );
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
# initialize the object
|
||||||
|
sub init
|
||||||
|
{
|
||||||
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
|
foreach my $attribute (keys %{$self->attribute_map}) {
|
||||||
|
my $args_key = $self->attribute_map->{$attribute};
|
||||||
|
$self->$attribute( $args{ $args_key } );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# return perl hash
|
# return perl hash
|
||||||
sub to_hash {
|
sub to_hash {
|
||||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
my $self = shift;
|
||||||
|
my $_hash = decode_json(JSON->new->convert_blessed->encode($self));
|
||||||
|
|
||||||
|
return $_hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
# used by JSON for serialization
|
# used by JSON for serialization
|
||||||
sub TO_JSON {
|
sub TO_JSON {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $_data = {};
|
my $_data = {};
|
||||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
foreach my $_key (keys %{$self->attribute_map}) {
|
||||||
if ( defined $self->{$_key} ) {
|
if (defined $self->{$_key}) {
|
||||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
$_data->{$self->attribute_map->{$_key}} = $self->{$_key};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $_data;
|
return $_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
# from Perl hashref
|
# from Perl hashref
|
||||||
sub from_hash {
|
sub from_hash {
|
||||||
my ( $self, $hash ) = @_;
|
my ($self, $hash) = @_;
|
||||||
|
|
||||||
# loop through attributes and use openapi_types to deserialize the data
|
# loop through attributes and use openapi_types to deserialize the data
|
||||||
while ( my ( $_key, $_type ) = each %{ $self->openapi_types } ) {
|
while ( my ($_key, $_type) = each %{$self->openapi_types} ) {
|
||||||
my $_json_attribute = $self->attribute_map->{$_key};
|
my $_json_attribute = $self->attribute_map->{$_key};
|
||||||
if ( $_type =~ /^array\[/i ) { # array
|
if ($_type =~ /^array\[/i) { # array
|
||||||
my $_subclass = substr( $_type, 6, -1 );
|
my $_subclass = substr($_type, 6, -1);
|
||||||
my @_array = ();
|
my @_array = ();
|
||||||
foreach my $_element ( @{ $hash->{$_json_attribute} } ) {
|
foreach my $_element (@{$hash->{$_json_attribute}}) {
|
||||||
push @_array, $self->_deserialize( $_subclass, $_element );
|
push @_array, $self->_deserialize($_subclass, $_element);
|
||||||
}
|
}
|
||||||
$self->{$_key} = \@_array;
|
$self->{$_key} = \@_array;
|
||||||
}
|
} elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
|
||||||
elsif ( exists $hash->{$_json_attribute} )
|
$self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute});
|
||||||
{ #hash(model), primitive, datetime
|
} else {
|
||||||
$self->{$_key} =
|
$log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
|
||||||
$self->_deserialize( $_type, $hash->{$_json_attribute} );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$log->debugf( "Warning: %s (%s) does not exist in input hash\n",
|
|
||||||
$_key, $_json_attribute );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
# deserialize non-array data
|
# deserialize non-array data
|
||||||
sub _deserialize {
|
sub _deserialize {
|
||||||
my ( $self, $type, $data ) = @_;
|
my ($self, $type, $data) = @_;
|
||||||
$log->debugf( "deserializing %s with %s", Dumper($data), $type );
|
$log->debugf("deserializing %s with %s",Dumper($data), $type);
|
||||||
|
|
||||||
if ( $type eq 'DateTime' ) {
|
if ($type eq 'DateTime') {
|
||||||
return DateTime->from_epoch( epoch => str2time($data) );
|
return DateTime->from_epoch(epoch => str2time($data));
|
||||||
}
|
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
|
||||||
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
} else { # hash(model)
|
||||||
else { # hash(model)
|
|
||||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||||
return $_instance->from_hash($data);
|
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__->openapi_types(
|
__PACKAGE__->class_documentation({description => '',
|
||||||
{
|
class => 'ArrayTest',
|
||||||
'array_of_string' => 'ARRAY[string]',
|
required => [], # TODO
|
||||||
'array_array_of_integer' => 'ARRAY[ARRAY[int]]',
|
} );
|
||||||
'array_array_of_model' => 'ARRAY[ARRAY[ReadOnlyFirst]]'
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
__PACKAGE__->attribute_map(
|
__PACKAGE__->method_documentation({
|
||||||
{
|
'array_of_string' => {
|
||||||
'array_of_string' => 'array_of_string',
|
datatype => 'ARRAY[string]',
|
||||||
'array_array_of_integer' => 'array_array_of_integer',
|
base_name => 'array_of_string',
|
||||||
'array_array_of_model' => 'array_array_of_model'
|
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__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
=begin comment
|
=begin comment
|
||||||
|
|
||||||
OpenAPI Petstore
|
OpenAPI Petstore
|
||||||
@@ -31,7 +30,8 @@ use Log::Any qw($log);
|
|||||||
use Date::Parse;
|
use Date::Parse;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
|
||||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
|
||||||
|
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||||
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
@@ -59,165 +59,164 @@ Generated by: https://openapi-generator.tech
|
|||||||
# Do not edit the class manually.
|
# Do not edit the class manually.
|
||||||
# Ref: https://openapi-generator.tech
|
# Ref: https://openapi-generator.tech
|
||||||
#
|
#
|
||||||
__PACKAGE__->mk_classdata( 'attribute_map' => {} );
|
__PACKAGE__->mk_classdata('attribute_map' => {});
|
||||||
__PACKAGE__->mk_classdata( 'openapi_types' => {} );
|
__PACKAGE__->mk_classdata('openapi_types' => {});
|
||||||
__PACKAGE__->mk_classdata( 'method_documentation' => {} );
|
__PACKAGE__->mk_classdata('method_documentation' => {});
|
||||||
__PACKAGE__->mk_classdata( 'class_documentation' => {} );
|
__PACKAGE__->mk_classdata('class_documentation' => {});
|
||||||
|
|
||||||
# new object
|
# new plain object
|
||||||
sub new {
|
sub new {
|
||||||
my ( $class, %args ) = @_;
|
my ($class, %args) = @_;
|
||||||
|
|
||||||
my $self = bless {}, $class;
|
my $self = bless {}, $class;
|
||||||
|
|
||||||
foreach my $attribute ( keys %{ $class->attribute_map } ) {
|
$self->init(%args);
|
||||||
my $args_key = $class->attribute_map->{$attribute};
|
|
||||||
$self->$attribute( $args{$args_key} );
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
# initialize the object
|
||||||
|
sub init
|
||||||
|
{
|
||||||
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
|
foreach my $attribute (keys %{$self->attribute_map}) {
|
||||||
|
my $args_key = $self->attribute_map->{$attribute};
|
||||||
|
$self->$attribute( $args{ $args_key } );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# return perl hash
|
# return perl hash
|
||||||
sub to_hash {
|
sub to_hash {
|
||||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
my $self = shift;
|
||||||
|
my $_hash = decode_json(JSON->new->convert_blessed->encode($self));
|
||||||
|
|
||||||
|
return $_hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
# used by JSON for serialization
|
# used by JSON for serialization
|
||||||
sub TO_JSON {
|
sub TO_JSON {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $_data = {};
|
my $_data = {};
|
||||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
foreach my $_key (keys %{$self->attribute_map}) {
|
||||||
if ( defined $self->{$_key} ) {
|
if (defined $self->{$_key}) {
|
||||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
$_data->{$self->attribute_map->{$_key}} = $self->{$_key};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $_data;
|
return $_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
# from Perl hashref
|
# from Perl hashref
|
||||||
sub from_hash {
|
sub from_hash {
|
||||||
my ( $self, $hash ) = @_;
|
my ($self, $hash) = @_;
|
||||||
|
|
||||||
# loop through attributes and use openapi_types to deserialize the data
|
# loop through attributes and use openapi_types to deserialize the data
|
||||||
while ( my ( $_key, $_type ) = each %{ $self->openapi_types } ) {
|
while ( my ($_key, $_type) = each %{$self->openapi_types} ) {
|
||||||
my $_json_attribute = $self->attribute_map->{$_key};
|
my $_json_attribute = $self->attribute_map->{$_key};
|
||||||
if ( $_type =~ /^array\[/i ) { # array
|
if ($_type =~ /^array\[/i) { # array
|
||||||
my $_subclass = substr( $_type, 6, -1 );
|
my $_subclass = substr($_type, 6, -1);
|
||||||
my @_array = ();
|
my @_array = ();
|
||||||
foreach my $_element ( @{ $hash->{$_json_attribute} } ) {
|
foreach my $_element (@{$hash->{$_json_attribute}}) {
|
||||||
push @_array, $self->_deserialize( $_subclass, $_element );
|
push @_array, $self->_deserialize($_subclass, $_element);
|
||||||
}
|
}
|
||||||
$self->{$_key} = \@_array;
|
$self->{$_key} = \@_array;
|
||||||
}
|
} elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
|
||||||
elsif ( exists $hash->{$_json_attribute} )
|
$self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute});
|
||||||
{ #hash(model), primitive, datetime
|
} else {
|
||||||
$self->{$_key} =
|
$log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
|
||||||
$self->_deserialize( $_type, $hash->{$_json_attribute} );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$log->debugf( "Warning: %s (%s) does not exist in input hash\n",
|
|
||||||
$_key, $_json_attribute );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
# deserialize non-array data
|
# deserialize non-array data
|
||||||
sub _deserialize {
|
sub _deserialize {
|
||||||
my ( $self, $type, $data ) = @_;
|
my ($self, $type, $data) = @_;
|
||||||
$log->debugf( "deserializing %s with %s", Dumper($data), $type );
|
$log->debugf("deserializing %s with %s",Dumper($data), $type);
|
||||||
|
|
||||||
if ( $type eq 'DateTime' ) {
|
if ($type eq 'DateTime') {
|
||||||
return DateTime->from_epoch( epoch => str2time($data) );
|
return DateTime->from_epoch(epoch => str2time($data));
|
||||||
}
|
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
|
||||||
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
} else { # hash(model)
|
||||||
else { # hash(model)
|
|
||||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||||
return $_instance->from_hash($data);
|
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__->openapi_types(
|
__PACKAGE__->class_documentation({description => '',
|
||||||
{
|
class => 'Capitalization',
|
||||||
'small_camel' => 'string',
|
required => [], # TODO
|
||||||
'capital_camel' => 'string',
|
} );
|
||||||
'small_snake' => 'string',
|
|
||||||
'capital_snake' => 'string',
|
|
||||||
'sca_eth_flow_points' => 'string',
|
|
||||||
'att_name' => 'string'
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
__PACKAGE__->attribute_map(
|
__PACKAGE__->method_documentation({
|
||||||
{
|
'small_camel' => {
|
||||||
'small_camel' => 'smallCamel',
|
datatype => 'string',
|
||||||
'capital_camel' => 'CapitalCamel',
|
base_name => 'smallCamel',
|
||||||
'small_snake' => 'small_Snake',
|
description => '',
|
||||||
'capital_snake' => 'Capital_Snake',
|
format => '',
|
||||||
'sca_eth_flow_points' => 'SCA_ETH_Flow_Points',
|
read_only => '',
|
||||||
'att_name' => 'ATT_NAME'
|
},
|
||||||
}
|
'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__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
=begin comment
|
=begin comment
|
||||||
|
|
||||||
OpenAPI Petstore
|
OpenAPI Petstore
|
||||||
@@ -33,7 +32,7 @@ use DateTime;
|
|||||||
|
|
||||||
use WWW::OpenAPIClient::Object::Animal;
|
use WWW::OpenAPIClient::Object::Animal;
|
||||||
|
|
||||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
use base ("Class::Accessor", "Class::Data::Inheritable", "WWW::OpenAPIClient::Object::Animal");
|
||||||
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
@@ -61,138 +60,131 @@ Generated by: https://openapi-generator.tech
|
|||||||
# Do not edit the class manually.
|
# Do not edit the class manually.
|
||||||
# Ref: https://openapi-generator.tech
|
# Ref: https://openapi-generator.tech
|
||||||
#
|
#
|
||||||
__PACKAGE__->mk_classdata( 'attribute_map' => {} );
|
__PACKAGE__->mk_classdata('attribute_map' => {});
|
||||||
__PACKAGE__->mk_classdata( 'openapi_types' => {} );
|
__PACKAGE__->mk_classdata('openapi_types' => {});
|
||||||
__PACKAGE__->mk_classdata( 'method_documentation' => {} );
|
__PACKAGE__->mk_classdata('method_documentation' => {});
|
||||||
__PACKAGE__->mk_classdata( 'class_documentation' => {} );
|
__PACKAGE__->mk_classdata('class_documentation' => {});
|
||||||
|
|
||||||
# new object
|
# new plain object
|
||||||
sub new {
|
sub new {
|
||||||
my ( $class, %args ) = @_;
|
my ($class, %args) = @_;
|
||||||
|
|
||||||
my $self = bless {}, $class;
|
my $self = bless {}, $class;
|
||||||
|
|
||||||
foreach my $attribute ( keys %{ $class->attribute_map } ) {
|
$self->init(%args);
|
||||||
my $args_key = $class->attribute_map->{$attribute};
|
|
||||||
$self->$attribute( $args{$args_key} );
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
# initialize the object
|
||||||
|
sub init
|
||||||
|
{
|
||||||
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
|
foreach my $attribute (keys %{$self->attribute_map}) {
|
||||||
|
my $args_key = $self->attribute_map->{$attribute};
|
||||||
|
$self->$attribute( $args{ $args_key } );
|
||||||
|
}
|
||||||
|
|
||||||
|
# initialize parent object Animal
|
||||||
|
$self->WWW::OpenAPIClient::Object::Animal::init(%args);
|
||||||
}
|
}
|
||||||
|
|
||||||
# return perl hash
|
# return perl hash
|
||||||
sub to_hash {
|
sub to_hash {
|
||||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
my $self = shift;
|
||||||
|
my $_hash = decode_json(JSON->new->convert_blessed->encode($self));
|
||||||
|
|
||||||
|
# call Animal to_hash and then combine hash
|
||||||
|
$_hash = { %$_hash, %$self->WWW::OpenAPIClient::Object::Animal::to_hash };
|
||||||
|
|
||||||
|
return $_hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
# used by JSON for serialization
|
# used by JSON for serialization
|
||||||
sub TO_JSON {
|
sub TO_JSON {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $_data = {};
|
my $_data = {};
|
||||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
foreach my $_key (keys %{$self->attribute_map}) {
|
||||||
if ( defined $self->{$_key} ) {
|
if (defined $self->{$_key}) {
|
||||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
$_data->{$self->attribute_map->{$_key}} = $self->{$_key};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# combine parent (Animal) TO_JSON
|
||||||
|
$_data = { %$_data, %$self->WWW::OpenAPIClient::Object::Animal::TO_JSON };
|
||||||
|
|
||||||
return $_data;
|
return $_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
# from Perl hashref
|
# from Perl hashref
|
||||||
sub from_hash {
|
sub from_hash {
|
||||||
my ( $self, $hash ) = @_;
|
my ($self, $hash) = @_;
|
||||||
|
|
||||||
# loop through attributes and use openapi_types to deserialize the data
|
# loop through attributes and use openapi_types to deserialize the data
|
||||||
while ( my ( $_key, $_type ) = each %{ $self->openapi_types } ) {
|
while ( my ($_key, $_type) = each %{$self->openapi_types} ) {
|
||||||
my $_json_attribute = $self->attribute_map->{$_key};
|
my $_json_attribute = $self->attribute_map->{$_key};
|
||||||
if ( $_type =~ /^array\[/i ) { # array
|
if ($_type =~ /^array\[/i) { # array
|
||||||
my $_subclass = substr( $_type, 6, -1 );
|
my $_subclass = substr($_type, 6, -1);
|
||||||
my @_array = ();
|
my @_array = ();
|
||||||
foreach my $_element ( @{ $hash->{$_json_attribute} } ) {
|
foreach my $_element (@{$hash->{$_json_attribute}}) {
|
||||||
push @_array, $self->_deserialize( $_subclass, $_element );
|
push @_array, $self->_deserialize($_subclass, $_element);
|
||||||
}
|
}
|
||||||
$self->{$_key} = \@_array;
|
$self->{$_key} = \@_array;
|
||||||
}
|
} elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
|
||||||
elsif ( exists $hash->{$_json_attribute} )
|
$self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute});
|
||||||
{ #hash(model), primitive, datetime
|
} else {
|
||||||
$self->{$_key} =
|
$log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
|
||||||
$self->_deserialize( $_type, $hash->{$_json_attribute} );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$log->debugf( "Warning: %s (%s) does not exist in input hash\n",
|
|
||||||
$_key, $_json_attribute );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# call parent (Animal) from_hash
|
||||||
|
$self->WWW::OpenAPIClient::Object::Animal::from_hash($hash);
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
# deserialize non-array data
|
# deserialize non-array data
|
||||||
sub _deserialize {
|
sub _deserialize {
|
||||||
my ( $self, $type, $data ) = @_;
|
my ($self, $type, $data) = @_;
|
||||||
$log->debugf( "deserializing %s with %s", Dumper($data), $type );
|
$log->debugf("deserializing %s with %s",Dumper($data), $type);
|
||||||
|
|
||||||
if ( $type eq 'DateTime' ) {
|
if ($type eq 'DateTime') {
|
||||||
return DateTime->from_epoch( epoch => str2time($data) );
|
return DateTime->from_epoch(epoch => str2time($data));
|
||||||
}
|
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
|
||||||
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
} else { # hash(model)
|
||||||
else { # hash(model)
|
|
||||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||||
return $_instance->from_hash($data);
|
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__->openapi_types(
|
__PACKAGE__->class_documentation({description => '',
|
||||||
{
|
class => 'Cat',
|
||||||
'class_name' => 'string',
|
required => [], # TODO
|
||||||
'color' => 'string',
|
} );
|
||||||
'declawed' => 'boolean'
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
__PACKAGE__->attribute_map(
|
__PACKAGE__->method_documentation({
|
||||||
{
|
'declawed' => {
|
||||||
'class_name' => 'className',
|
datatype => 'boolean',
|
||||||
'color' => 'color',
|
base_name => 'declawed',
|
||||||
'declawed' => 'declawed'
|
description => '',
|
||||||
}
|
format => '',
|
||||||
);
|
read_only => '',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
__PACKAGE__->openapi_types( {
|
||||||
|
'declawed' => 'boolean'
|
||||||
|
} );
|
||||||
|
|
||||||
|
__PACKAGE__->attribute_map( {
|
||||||
|
'declawed' => 'declawed'
|
||||||
|
} );
|
||||||
|
|
||||||
|
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
||||||
|
|
||||||
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
=begin comment
|
=begin comment
|
||||||
|
|
||||||
OpenAPI Petstore
|
OpenAPI Petstore
|
||||||
@@ -31,7 +30,8 @@ use Log::Any qw($log);
|
|||||||
use Date::Parse;
|
use Date::Parse;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
|
||||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
|
||||||
|
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||||
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
@@ -59,129 +59,128 @@ Generated by: https://openapi-generator.tech
|
|||||||
# Do not edit the class manually.
|
# Do not edit the class manually.
|
||||||
# Ref: https://openapi-generator.tech
|
# Ref: https://openapi-generator.tech
|
||||||
#
|
#
|
||||||
__PACKAGE__->mk_classdata( 'attribute_map' => {} );
|
__PACKAGE__->mk_classdata('attribute_map' => {});
|
||||||
__PACKAGE__->mk_classdata( 'openapi_types' => {} );
|
__PACKAGE__->mk_classdata('openapi_types' => {});
|
||||||
__PACKAGE__->mk_classdata( 'method_documentation' => {} );
|
__PACKAGE__->mk_classdata('method_documentation' => {});
|
||||||
__PACKAGE__->mk_classdata( 'class_documentation' => {} );
|
__PACKAGE__->mk_classdata('class_documentation' => {});
|
||||||
|
|
||||||
# new object
|
# new plain object
|
||||||
sub new {
|
sub new {
|
||||||
my ( $class, %args ) = @_;
|
my ($class, %args) = @_;
|
||||||
|
|
||||||
my $self = bless {}, $class;
|
my $self = bless {}, $class;
|
||||||
|
|
||||||
foreach my $attribute ( keys %{ $class->attribute_map } ) {
|
$self->init(%args);
|
||||||
my $args_key = $class->attribute_map->{$attribute};
|
|
||||||
$self->$attribute( $args{$args_key} );
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
# initialize the object
|
||||||
|
sub init
|
||||||
|
{
|
||||||
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
|
foreach my $attribute (keys %{$self->attribute_map}) {
|
||||||
|
my $args_key = $self->attribute_map->{$attribute};
|
||||||
|
$self->$attribute( $args{ $args_key } );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# return perl hash
|
# return perl hash
|
||||||
sub to_hash {
|
sub to_hash {
|
||||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
my $self = shift;
|
||||||
|
my $_hash = decode_json(JSON->new->convert_blessed->encode($self));
|
||||||
|
|
||||||
|
return $_hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
# used by JSON for serialization
|
# used by JSON for serialization
|
||||||
sub TO_JSON {
|
sub TO_JSON {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $_data = {};
|
my $_data = {};
|
||||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
foreach my $_key (keys %{$self->attribute_map}) {
|
||||||
if ( defined $self->{$_key} ) {
|
if (defined $self->{$_key}) {
|
||||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
$_data->{$self->attribute_map->{$_key}} = $self->{$_key};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $_data;
|
return $_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
# from Perl hashref
|
# from Perl hashref
|
||||||
sub from_hash {
|
sub from_hash {
|
||||||
my ( $self, $hash ) = @_;
|
my ($self, $hash) = @_;
|
||||||
|
|
||||||
# loop through attributes and use openapi_types to deserialize the data
|
# loop through attributes and use openapi_types to deserialize the data
|
||||||
while ( my ( $_key, $_type ) = each %{ $self->openapi_types } ) {
|
while ( my ($_key, $_type) = each %{$self->openapi_types} ) {
|
||||||
my $_json_attribute = $self->attribute_map->{$_key};
|
my $_json_attribute = $self->attribute_map->{$_key};
|
||||||
if ( $_type =~ /^array\[/i ) { # array
|
if ($_type =~ /^array\[/i) { # array
|
||||||
my $_subclass = substr( $_type, 6, -1 );
|
my $_subclass = substr($_type, 6, -1);
|
||||||
my @_array = ();
|
my @_array = ();
|
||||||
foreach my $_element ( @{ $hash->{$_json_attribute} } ) {
|
foreach my $_element (@{$hash->{$_json_attribute}}) {
|
||||||
push @_array, $self->_deserialize( $_subclass, $_element );
|
push @_array, $self->_deserialize($_subclass, $_element);
|
||||||
}
|
}
|
||||||
$self->{$_key} = \@_array;
|
$self->{$_key} = \@_array;
|
||||||
}
|
} elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
|
||||||
elsif ( exists $hash->{$_json_attribute} )
|
$self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute});
|
||||||
{ #hash(model), primitive, datetime
|
} else {
|
||||||
$self->{$_key} =
|
$log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
|
||||||
$self->_deserialize( $_type, $hash->{$_json_attribute} );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$log->debugf( "Warning: %s (%s) does not exist in input hash\n",
|
|
||||||
$_key, $_json_attribute );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
# deserialize non-array data
|
# deserialize non-array data
|
||||||
sub _deserialize {
|
sub _deserialize {
|
||||||
my ( $self, $type, $data ) = @_;
|
my ($self, $type, $data) = @_;
|
||||||
$log->debugf( "deserializing %s with %s", Dumper($data), $type );
|
$log->debugf("deserializing %s with %s",Dumper($data), $type);
|
||||||
|
|
||||||
if ( $type eq 'DateTime' ) {
|
if ($type eq 'DateTime') {
|
||||||
return DateTime->from_epoch( epoch => str2time($data) );
|
return DateTime->from_epoch(epoch => str2time($data));
|
||||||
}
|
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
|
||||||
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
} else { # hash(model)
|
||||||
else { # hash(model)
|
|
||||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||||
return $_instance->from_hash($data);
|
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__->openapi_types(
|
__PACKAGE__->class_documentation({description => '',
|
||||||
{
|
class => 'Category',
|
||||||
'id' => 'int',
|
required => [], # TODO
|
||||||
'name' => 'string'
|
} );
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
__PACKAGE__->attribute_map(
|
__PACKAGE__->method_documentation({
|
||||||
{
|
'id' => {
|
||||||
'id' => 'id',
|
datatype => 'int',
|
||||||
'name' => 'name'
|
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__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|||||||
@@ -0,0 +1,199 @@
|
|||||||
|
=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::Child;
|
||||||
|
|
||||||
|
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::Person;
|
||||||
|
|
||||||
|
use base ("Class::Accessor", "Class::Data::Inheritable", "WWW::OpenAPIClient::Object::Person");
|
||||||
|
|
||||||
|
#
|
||||||
|
#A representation of a child
|
||||||
|
#
|
||||||
|
# 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 plain object
|
||||||
|
sub new {
|
||||||
|
my ($class, %args) = @_;
|
||||||
|
|
||||||
|
my $self = bless {}, $class;
|
||||||
|
|
||||||
|
$self->init(%args);
|
||||||
|
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
# initialize the object
|
||||||
|
sub init
|
||||||
|
{
|
||||||
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
|
foreach my $attribute (keys %{$self->attribute_map}) {
|
||||||
|
my $args_key = $self->attribute_map->{$attribute};
|
||||||
|
$self->$attribute( $args{ $args_key } );
|
||||||
|
}
|
||||||
|
|
||||||
|
# initialize parent object Person
|
||||||
|
$self->WWW::OpenAPIClient::Object::Person::init(%args);
|
||||||
|
}
|
||||||
|
|
||||||
|
# return perl hash
|
||||||
|
sub to_hash {
|
||||||
|
my $self = shift;
|
||||||
|
my $_hash = decode_json(JSON->new->convert_blessed->encode($self));
|
||||||
|
|
||||||
|
# call Person to_hash and then combine hash
|
||||||
|
$_hash = { %$_hash, %$self->WWW::OpenAPIClient::Object::Person::to_hash };
|
||||||
|
|
||||||
|
return $_hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
# 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};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# combine parent (Person) TO_JSON
|
||||||
|
$_data = { %$_data, %$self->WWW::OpenAPIClient::Object::Person::TO_JSON };
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# call parent (Person) from_hash
|
||||||
|
$self->WWW::OpenAPIClient::Object::Person::from_hash($hash);
|
||||||
|
|
||||||
|
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 => 'A representation of a child',
|
||||||
|
class => 'Child',
|
||||||
|
required => [], # TODO
|
||||||
|
} );
|
||||||
|
|
||||||
|
__PACKAGE__->method_documentation({
|
||||||
|
'age' => {
|
||||||
|
datatype => 'int',
|
||||||
|
base_name => 'age',
|
||||||
|
description => '',
|
||||||
|
format => '',
|
||||||
|
read_only => '',
|
||||||
|
},
|
||||||
|
'first_name' => {
|
||||||
|
datatype => 'string',
|
||||||
|
base_name => 'firstName',
|
||||||
|
description => '',
|
||||||
|
format => '',
|
||||||
|
read_only => '',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
__PACKAGE__->openapi_types( {
|
||||||
|
'age' => 'int',
|
||||||
|
'first_name' => 'string'
|
||||||
|
} );
|
||||||
|
|
||||||
|
__PACKAGE__->attribute_map( {
|
||||||
|
'age' => 'age',
|
||||||
|
'first_name' => 'firstName'
|
||||||
|
} );
|
||||||
|
|
||||||
|
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
||||||
|
|
||||||
|
|
||||||
|
1;
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
=begin comment
|
=begin comment
|
||||||
|
|
||||||
OpenAPI Petstore
|
OpenAPI Petstore
|
||||||
@@ -31,7 +30,8 @@ use Log::Any qw($log);
|
|||||||
use Date::Parse;
|
use Date::Parse;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
|
||||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
|
||||||
|
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||||
|
|
||||||
#
|
#
|
||||||
#Model for testing model with \"_class\" property
|
#Model for testing model with \"_class\" property
|
||||||
@@ -59,121 +59,119 @@ Generated by: https://openapi-generator.tech
|
|||||||
# Do not edit the class manually.
|
# Do not edit the class manually.
|
||||||
# Ref: https://openapi-generator.tech
|
# Ref: https://openapi-generator.tech
|
||||||
#
|
#
|
||||||
__PACKAGE__->mk_classdata( 'attribute_map' => {} );
|
__PACKAGE__->mk_classdata('attribute_map' => {});
|
||||||
__PACKAGE__->mk_classdata( 'openapi_types' => {} );
|
__PACKAGE__->mk_classdata('openapi_types' => {});
|
||||||
__PACKAGE__->mk_classdata( 'method_documentation' => {} );
|
__PACKAGE__->mk_classdata('method_documentation' => {});
|
||||||
__PACKAGE__->mk_classdata( 'class_documentation' => {} );
|
__PACKAGE__->mk_classdata('class_documentation' => {});
|
||||||
|
|
||||||
# new object
|
# new plain object
|
||||||
sub new {
|
sub new {
|
||||||
my ( $class, %args ) = @_;
|
my ($class, %args) = @_;
|
||||||
|
|
||||||
my $self = bless {}, $class;
|
my $self = bless {}, $class;
|
||||||
|
|
||||||
foreach my $attribute ( keys %{ $class->attribute_map } ) {
|
$self->init(%args);
|
||||||
my $args_key = $class->attribute_map->{$attribute};
|
|
||||||
$self->$attribute( $args{$args_key} );
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
# initialize the object
|
||||||
|
sub init
|
||||||
|
{
|
||||||
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
|
foreach my $attribute (keys %{$self->attribute_map}) {
|
||||||
|
my $args_key = $self->attribute_map->{$attribute};
|
||||||
|
$self->$attribute( $args{ $args_key } );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# return perl hash
|
# return perl hash
|
||||||
sub to_hash {
|
sub to_hash {
|
||||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
my $self = shift;
|
||||||
|
my $_hash = decode_json(JSON->new->convert_blessed->encode($self));
|
||||||
|
|
||||||
|
return $_hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
# used by JSON for serialization
|
# used by JSON for serialization
|
||||||
sub TO_JSON {
|
sub TO_JSON {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $_data = {};
|
my $_data = {};
|
||||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
foreach my $_key (keys %{$self->attribute_map}) {
|
||||||
if ( defined $self->{$_key} ) {
|
if (defined $self->{$_key}) {
|
||||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
$_data->{$self->attribute_map->{$_key}} = $self->{$_key};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $_data;
|
return $_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
# from Perl hashref
|
# from Perl hashref
|
||||||
sub from_hash {
|
sub from_hash {
|
||||||
my ( $self, $hash ) = @_;
|
my ($self, $hash) = @_;
|
||||||
|
|
||||||
# loop through attributes and use openapi_types to deserialize the data
|
# loop through attributes and use openapi_types to deserialize the data
|
||||||
while ( my ( $_key, $_type ) = each %{ $self->openapi_types } ) {
|
while ( my ($_key, $_type) = each %{$self->openapi_types} ) {
|
||||||
my $_json_attribute = $self->attribute_map->{$_key};
|
my $_json_attribute = $self->attribute_map->{$_key};
|
||||||
if ( $_type =~ /^array\[/i ) { # array
|
if ($_type =~ /^array\[/i) { # array
|
||||||
my $_subclass = substr( $_type, 6, -1 );
|
my $_subclass = substr($_type, 6, -1);
|
||||||
my @_array = ();
|
my @_array = ();
|
||||||
foreach my $_element ( @{ $hash->{$_json_attribute} } ) {
|
foreach my $_element (@{$hash->{$_json_attribute}}) {
|
||||||
push @_array, $self->_deserialize( $_subclass, $_element );
|
push @_array, $self->_deserialize($_subclass, $_element);
|
||||||
}
|
}
|
||||||
$self->{$_key} = \@_array;
|
$self->{$_key} = \@_array;
|
||||||
}
|
} elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
|
||||||
elsif ( exists $hash->{$_json_attribute} )
|
$self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute});
|
||||||
{ #hash(model), primitive, datetime
|
} else {
|
||||||
$self->{$_key} =
|
$log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
|
||||||
$self->_deserialize( $_type, $hash->{$_json_attribute} );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$log->debugf( "Warning: %s (%s) does not exist in input hash\n",
|
|
||||||
$_key, $_json_attribute );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
# deserialize non-array data
|
# deserialize non-array data
|
||||||
sub _deserialize {
|
sub _deserialize {
|
||||||
my ( $self, $type, $data ) = @_;
|
my ($self, $type, $data) = @_;
|
||||||
$log->debugf( "deserializing %s with %s", Dumper($data), $type );
|
$log->debugf("deserializing %s with %s",Dumper($data), $type);
|
||||||
|
|
||||||
if ( $type eq 'DateTime' ) {
|
if ($type eq 'DateTime') {
|
||||||
return DateTime->from_epoch( epoch => str2time($data) );
|
return DateTime->from_epoch(epoch => str2time($data));
|
||||||
}
|
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
|
||||||
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
} else { # hash(model)
|
||||||
else { # hash(model)
|
|
||||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||||
return $_instance->from_hash($data);
|
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__->openapi_types(
|
__PACKAGE__->class_documentation({description => 'Model for testing model with \"_class\" property',
|
||||||
{
|
class => 'ClassModel',
|
||||||
'_class' => 'string'
|
required => [], # TODO
|
||||||
}
|
} );
|
||||||
);
|
|
||||||
|
|
||||||
__PACKAGE__->attribute_map(
|
__PACKAGE__->method_documentation({
|
||||||
{
|
'_class' => {
|
||||||
'_class' => '_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__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
=begin comment
|
=begin comment
|
||||||
|
|
||||||
OpenAPI Petstore
|
OpenAPI Petstore
|
||||||
@@ -31,7 +30,8 @@ use Log::Any qw($log);
|
|||||||
use Date::Parse;
|
use Date::Parse;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
|
||||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
|
||||||
|
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||||
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
@@ -59,120 +59,119 @@ Generated by: https://openapi-generator.tech
|
|||||||
# Do not edit the class manually.
|
# Do not edit the class manually.
|
||||||
# Ref: https://openapi-generator.tech
|
# Ref: https://openapi-generator.tech
|
||||||
#
|
#
|
||||||
__PACKAGE__->mk_classdata( 'attribute_map' => {} );
|
__PACKAGE__->mk_classdata('attribute_map' => {});
|
||||||
__PACKAGE__->mk_classdata( 'openapi_types' => {} );
|
__PACKAGE__->mk_classdata('openapi_types' => {});
|
||||||
__PACKAGE__->mk_classdata( 'method_documentation' => {} );
|
__PACKAGE__->mk_classdata('method_documentation' => {});
|
||||||
__PACKAGE__->mk_classdata( 'class_documentation' => {} );
|
__PACKAGE__->mk_classdata('class_documentation' => {});
|
||||||
|
|
||||||
# new object
|
# new plain object
|
||||||
sub new {
|
sub new {
|
||||||
my ( $class, %args ) = @_;
|
my ($class, %args) = @_;
|
||||||
|
|
||||||
my $self = bless {}, $class;
|
my $self = bless {}, $class;
|
||||||
|
|
||||||
foreach my $attribute ( keys %{ $class->attribute_map } ) {
|
$self->init(%args);
|
||||||
my $args_key = $class->attribute_map->{$attribute};
|
|
||||||
$self->$attribute( $args{$args_key} );
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
# initialize the object
|
||||||
|
sub init
|
||||||
|
{
|
||||||
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
|
foreach my $attribute (keys %{$self->attribute_map}) {
|
||||||
|
my $args_key = $self->attribute_map->{$attribute};
|
||||||
|
$self->$attribute( $args{ $args_key } );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# return perl hash
|
# return perl hash
|
||||||
sub to_hash {
|
sub to_hash {
|
||||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
my $self = shift;
|
||||||
|
my $_hash = decode_json(JSON->new->convert_blessed->encode($self));
|
||||||
|
|
||||||
|
return $_hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
# used by JSON for serialization
|
# used by JSON for serialization
|
||||||
sub TO_JSON {
|
sub TO_JSON {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $_data = {};
|
my $_data = {};
|
||||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
foreach my $_key (keys %{$self->attribute_map}) {
|
||||||
if ( defined $self->{$_key} ) {
|
if (defined $self->{$_key}) {
|
||||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
$_data->{$self->attribute_map->{$_key}} = $self->{$_key};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $_data;
|
return $_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
# from Perl hashref
|
# from Perl hashref
|
||||||
sub from_hash {
|
sub from_hash {
|
||||||
my ( $self, $hash ) = @_;
|
my ($self, $hash) = @_;
|
||||||
|
|
||||||
# loop through attributes and use openapi_types to deserialize the data
|
# loop through attributes and use openapi_types to deserialize the data
|
||||||
while ( my ( $_key, $_type ) = each %{ $self->openapi_types } ) {
|
while ( my ($_key, $_type) = each %{$self->openapi_types} ) {
|
||||||
my $_json_attribute = $self->attribute_map->{$_key};
|
my $_json_attribute = $self->attribute_map->{$_key};
|
||||||
if ( $_type =~ /^array\[/i ) { # array
|
if ($_type =~ /^array\[/i) { # array
|
||||||
my $_subclass = substr( $_type, 6, -1 );
|
my $_subclass = substr($_type, 6, -1);
|
||||||
my @_array = ();
|
my @_array = ();
|
||||||
foreach my $_element ( @{ $hash->{$_json_attribute} } ) {
|
foreach my $_element (@{$hash->{$_json_attribute}}) {
|
||||||
push @_array, $self->_deserialize( $_subclass, $_element );
|
push @_array, $self->_deserialize($_subclass, $_element);
|
||||||
}
|
}
|
||||||
$self->{$_key} = \@_array;
|
$self->{$_key} = \@_array;
|
||||||
}
|
} elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
|
||||||
elsif ( exists $hash->{$_json_attribute} )
|
$self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute});
|
||||||
{ #hash(model), primitive, datetime
|
} else {
|
||||||
$self->{$_key} =
|
$log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
|
||||||
$self->_deserialize( $_type, $hash->{$_json_attribute} );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$log->debugf( "Warning: %s (%s) does not exist in input hash\n",
|
|
||||||
$_key, $_json_attribute );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
# deserialize non-array data
|
# deserialize non-array data
|
||||||
sub _deserialize {
|
sub _deserialize {
|
||||||
my ( $self, $type, $data ) = @_;
|
my ($self, $type, $data) = @_;
|
||||||
$log->debugf( "deserializing %s with %s", Dumper($data), $type );
|
$log->debugf("deserializing %s with %s",Dumper($data), $type);
|
||||||
|
|
||||||
if ( $type eq 'DateTime' ) {
|
if ($type eq 'DateTime') {
|
||||||
return DateTime->from_epoch( epoch => str2time($data) );
|
return DateTime->from_epoch(epoch => str2time($data));
|
||||||
}
|
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
|
||||||
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
} else { # hash(model)
|
||||||
else { # hash(model)
|
|
||||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||||
return $_instance->from_hash($data);
|
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__->openapi_types(
|
__PACKAGE__->class_documentation({description => '',
|
||||||
{
|
class => 'Client',
|
||||||
'client' => 'string'
|
required => [], # TODO
|
||||||
}
|
} );
|
||||||
);
|
|
||||||
|
|
||||||
__PACKAGE__->attribute_map(
|
__PACKAGE__->method_documentation({
|
||||||
{
|
'client' => {
|
||||||
'client' => '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__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
=begin comment
|
=begin comment
|
||||||
|
|
||||||
OpenAPI Petstore
|
OpenAPI Petstore
|
||||||
@@ -33,7 +32,7 @@ use DateTime;
|
|||||||
|
|
||||||
use WWW::OpenAPIClient::Object::Animal;
|
use WWW::OpenAPIClient::Object::Animal;
|
||||||
|
|
||||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
use base ("Class::Accessor", "Class::Data::Inheritable", "WWW::OpenAPIClient::Object::Animal");
|
||||||
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
@@ -61,138 +60,131 @@ Generated by: https://openapi-generator.tech
|
|||||||
# Do not edit the class manually.
|
# Do not edit the class manually.
|
||||||
# Ref: https://openapi-generator.tech
|
# Ref: https://openapi-generator.tech
|
||||||
#
|
#
|
||||||
__PACKAGE__->mk_classdata( 'attribute_map' => {} );
|
__PACKAGE__->mk_classdata('attribute_map' => {});
|
||||||
__PACKAGE__->mk_classdata( 'openapi_types' => {} );
|
__PACKAGE__->mk_classdata('openapi_types' => {});
|
||||||
__PACKAGE__->mk_classdata( 'method_documentation' => {} );
|
__PACKAGE__->mk_classdata('method_documentation' => {});
|
||||||
__PACKAGE__->mk_classdata( 'class_documentation' => {} );
|
__PACKAGE__->mk_classdata('class_documentation' => {});
|
||||||
|
|
||||||
# new object
|
# new plain object
|
||||||
sub new {
|
sub new {
|
||||||
my ( $class, %args ) = @_;
|
my ($class, %args) = @_;
|
||||||
|
|
||||||
my $self = bless {}, $class;
|
my $self = bless {}, $class;
|
||||||
|
|
||||||
foreach my $attribute ( keys %{ $class->attribute_map } ) {
|
$self->init(%args);
|
||||||
my $args_key = $class->attribute_map->{$attribute};
|
|
||||||
$self->$attribute( $args{$args_key} );
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
# initialize the object
|
||||||
|
sub init
|
||||||
|
{
|
||||||
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
|
foreach my $attribute (keys %{$self->attribute_map}) {
|
||||||
|
my $args_key = $self->attribute_map->{$attribute};
|
||||||
|
$self->$attribute( $args{ $args_key } );
|
||||||
|
}
|
||||||
|
|
||||||
|
# initialize parent object Animal
|
||||||
|
$self->WWW::OpenAPIClient::Object::Animal::init(%args);
|
||||||
}
|
}
|
||||||
|
|
||||||
# return perl hash
|
# return perl hash
|
||||||
sub to_hash {
|
sub to_hash {
|
||||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
my $self = shift;
|
||||||
|
my $_hash = decode_json(JSON->new->convert_blessed->encode($self));
|
||||||
|
|
||||||
|
# call Animal to_hash and then combine hash
|
||||||
|
$_hash = { %$_hash, %$self->WWW::OpenAPIClient::Object::Animal::to_hash };
|
||||||
|
|
||||||
|
return $_hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
# used by JSON for serialization
|
# used by JSON for serialization
|
||||||
sub TO_JSON {
|
sub TO_JSON {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $_data = {};
|
my $_data = {};
|
||||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
foreach my $_key (keys %{$self->attribute_map}) {
|
||||||
if ( defined $self->{$_key} ) {
|
if (defined $self->{$_key}) {
|
||||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
$_data->{$self->attribute_map->{$_key}} = $self->{$_key};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# combine parent (Animal) TO_JSON
|
||||||
|
$_data = { %$_data, %$self->WWW::OpenAPIClient::Object::Animal::TO_JSON };
|
||||||
|
|
||||||
return $_data;
|
return $_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
# from Perl hashref
|
# from Perl hashref
|
||||||
sub from_hash {
|
sub from_hash {
|
||||||
my ( $self, $hash ) = @_;
|
my ($self, $hash) = @_;
|
||||||
|
|
||||||
# loop through attributes and use openapi_types to deserialize the data
|
# loop through attributes and use openapi_types to deserialize the data
|
||||||
while ( my ( $_key, $_type ) = each %{ $self->openapi_types } ) {
|
while ( my ($_key, $_type) = each %{$self->openapi_types} ) {
|
||||||
my $_json_attribute = $self->attribute_map->{$_key};
|
my $_json_attribute = $self->attribute_map->{$_key};
|
||||||
if ( $_type =~ /^array\[/i ) { # array
|
if ($_type =~ /^array\[/i) { # array
|
||||||
my $_subclass = substr( $_type, 6, -1 );
|
my $_subclass = substr($_type, 6, -1);
|
||||||
my @_array = ();
|
my @_array = ();
|
||||||
foreach my $_element ( @{ $hash->{$_json_attribute} } ) {
|
foreach my $_element (@{$hash->{$_json_attribute}}) {
|
||||||
push @_array, $self->_deserialize( $_subclass, $_element );
|
push @_array, $self->_deserialize($_subclass, $_element);
|
||||||
}
|
}
|
||||||
$self->{$_key} = \@_array;
|
$self->{$_key} = \@_array;
|
||||||
}
|
} elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
|
||||||
elsif ( exists $hash->{$_json_attribute} )
|
$self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute});
|
||||||
{ #hash(model), primitive, datetime
|
} else {
|
||||||
$self->{$_key} =
|
$log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
|
||||||
$self->_deserialize( $_type, $hash->{$_json_attribute} );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$log->debugf( "Warning: %s (%s) does not exist in input hash\n",
|
|
||||||
$_key, $_json_attribute );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# call parent (Animal) from_hash
|
||||||
|
$self->WWW::OpenAPIClient::Object::Animal::from_hash($hash);
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
# deserialize non-array data
|
# deserialize non-array data
|
||||||
sub _deserialize {
|
sub _deserialize {
|
||||||
my ( $self, $type, $data ) = @_;
|
my ($self, $type, $data) = @_;
|
||||||
$log->debugf( "deserializing %s with %s", Dumper($data), $type );
|
$log->debugf("deserializing %s with %s",Dumper($data), $type);
|
||||||
|
|
||||||
if ( $type eq 'DateTime' ) {
|
if ($type eq 'DateTime') {
|
||||||
return DateTime->from_epoch( epoch => str2time($data) );
|
return DateTime->from_epoch(epoch => str2time($data));
|
||||||
}
|
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
|
||||||
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
} else { # hash(model)
|
||||||
else { # hash(model)
|
|
||||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||||
return $_instance->from_hash($data);
|
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__->openapi_types(
|
__PACKAGE__->class_documentation({description => '',
|
||||||
{
|
class => 'Dog',
|
||||||
'class_name' => 'string',
|
required => [], # TODO
|
||||||
'color' => 'string',
|
} );
|
||||||
'breed' => 'string'
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
__PACKAGE__->attribute_map(
|
__PACKAGE__->method_documentation({
|
||||||
{
|
'breed' => {
|
||||||
'class_name' => 'className',
|
datatype => 'string',
|
||||||
'color' => 'color',
|
base_name => 'breed',
|
||||||
'breed' => 'breed'
|
description => '',
|
||||||
}
|
format => '',
|
||||||
);
|
read_only => '',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
__PACKAGE__->openapi_types( {
|
||||||
|
'breed' => 'string'
|
||||||
|
} );
|
||||||
|
|
||||||
|
__PACKAGE__->attribute_map( {
|
||||||
|
'breed' => 'breed'
|
||||||
|
} );
|
||||||
|
|
||||||
|
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
||||||
|
|
||||||
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
=begin comment
|
=begin comment
|
||||||
|
|
||||||
OpenAPI Petstore
|
OpenAPI Petstore
|
||||||
@@ -31,7 +30,8 @@ use Log::Any qw($log);
|
|||||||
use Date::Parse;
|
use Date::Parse;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
|
||||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
|
||||||
|
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||||
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
@@ -59,129 +59,128 @@ Generated by: https://openapi-generator.tech
|
|||||||
# Do not edit the class manually.
|
# Do not edit the class manually.
|
||||||
# Ref: https://openapi-generator.tech
|
# Ref: https://openapi-generator.tech
|
||||||
#
|
#
|
||||||
__PACKAGE__->mk_classdata( 'attribute_map' => {} );
|
__PACKAGE__->mk_classdata('attribute_map' => {});
|
||||||
__PACKAGE__->mk_classdata( 'openapi_types' => {} );
|
__PACKAGE__->mk_classdata('openapi_types' => {});
|
||||||
__PACKAGE__->mk_classdata( 'method_documentation' => {} );
|
__PACKAGE__->mk_classdata('method_documentation' => {});
|
||||||
__PACKAGE__->mk_classdata( 'class_documentation' => {} );
|
__PACKAGE__->mk_classdata('class_documentation' => {});
|
||||||
|
|
||||||
# new object
|
# new plain object
|
||||||
sub new {
|
sub new {
|
||||||
my ( $class, %args ) = @_;
|
my ($class, %args) = @_;
|
||||||
|
|
||||||
my $self = bless {}, $class;
|
my $self = bless {}, $class;
|
||||||
|
|
||||||
foreach my $attribute ( keys %{ $class->attribute_map } ) {
|
$self->init(%args);
|
||||||
my $args_key = $class->attribute_map->{$attribute};
|
|
||||||
$self->$attribute( $args{$args_key} );
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
# initialize the object
|
||||||
|
sub init
|
||||||
|
{
|
||||||
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
|
foreach my $attribute (keys %{$self->attribute_map}) {
|
||||||
|
my $args_key = $self->attribute_map->{$attribute};
|
||||||
|
$self->$attribute( $args{ $args_key } );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# return perl hash
|
# return perl hash
|
||||||
sub to_hash {
|
sub to_hash {
|
||||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
my $self = shift;
|
||||||
|
my $_hash = decode_json(JSON->new->convert_blessed->encode($self));
|
||||||
|
|
||||||
|
return $_hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
# used by JSON for serialization
|
# used by JSON for serialization
|
||||||
sub TO_JSON {
|
sub TO_JSON {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $_data = {};
|
my $_data = {};
|
||||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
foreach my $_key (keys %{$self->attribute_map}) {
|
||||||
if ( defined $self->{$_key} ) {
|
if (defined $self->{$_key}) {
|
||||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
$_data->{$self->attribute_map->{$_key}} = $self->{$_key};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $_data;
|
return $_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
# from Perl hashref
|
# from Perl hashref
|
||||||
sub from_hash {
|
sub from_hash {
|
||||||
my ( $self, $hash ) = @_;
|
my ($self, $hash) = @_;
|
||||||
|
|
||||||
# loop through attributes and use openapi_types to deserialize the data
|
# loop through attributes and use openapi_types to deserialize the data
|
||||||
while ( my ( $_key, $_type ) = each %{ $self->openapi_types } ) {
|
while ( my ($_key, $_type) = each %{$self->openapi_types} ) {
|
||||||
my $_json_attribute = $self->attribute_map->{$_key};
|
my $_json_attribute = $self->attribute_map->{$_key};
|
||||||
if ( $_type =~ /^array\[/i ) { # array
|
if ($_type =~ /^array\[/i) { # array
|
||||||
my $_subclass = substr( $_type, 6, -1 );
|
my $_subclass = substr($_type, 6, -1);
|
||||||
my @_array = ();
|
my @_array = ();
|
||||||
foreach my $_element ( @{ $hash->{$_json_attribute} } ) {
|
foreach my $_element (@{$hash->{$_json_attribute}}) {
|
||||||
push @_array, $self->_deserialize( $_subclass, $_element );
|
push @_array, $self->_deserialize($_subclass, $_element);
|
||||||
}
|
}
|
||||||
$self->{$_key} = \@_array;
|
$self->{$_key} = \@_array;
|
||||||
}
|
} elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
|
||||||
elsif ( exists $hash->{$_json_attribute} )
|
$self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute});
|
||||||
{ #hash(model), primitive, datetime
|
} else {
|
||||||
$self->{$_key} =
|
$log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
|
||||||
$self->_deserialize( $_type, $hash->{$_json_attribute} );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$log->debugf( "Warning: %s (%s) does not exist in input hash\n",
|
|
||||||
$_key, $_json_attribute );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
# deserialize non-array data
|
# deserialize non-array data
|
||||||
sub _deserialize {
|
sub _deserialize {
|
||||||
my ( $self, $type, $data ) = @_;
|
my ($self, $type, $data) = @_;
|
||||||
$log->debugf( "deserializing %s with %s", Dumper($data), $type );
|
$log->debugf("deserializing %s with %s",Dumper($data), $type);
|
||||||
|
|
||||||
if ( $type eq 'DateTime' ) {
|
if ($type eq 'DateTime') {
|
||||||
return DateTime->from_epoch( epoch => str2time($data) );
|
return DateTime->from_epoch(epoch => str2time($data));
|
||||||
}
|
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
|
||||||
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
} else { # hash(model)
|
||||||
else { # hash(model)
|
|
||||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||||
return $_instance->from_hash($data);
|
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__->openapi_types(
|
__PACKAGE__->class_documentation({description => '',
|
||||||
{
|
class => 'EnumArrays',
|
||||||
'just_symbol' => 'string',
|
required => [], # TODO
|
||||||
'array_enum' => 'ARRAY[string]'
|
} );
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
__PACKAGE__->attribute_map(
|
__PACKAGE__->method_documentation({
|
||||||
{
|
'just_symbol' => {
|
||||||
'just_symbol' => 'just_symbol',
|
datatype => 'string',
|
||||||
'array_enum' => 'array_enum'
|
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__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
=begin comment
|
=begin comment
|
||||||
|
|
||||||
OpenAPI Petstore
|
OpenAPI Petstore
|
||||||
@@ -31,7 +30,8 @@ use Log::Any qw($log);
|
|||||||
use Date::Parse;
|
use Date::Parse;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
|
||||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
|
||||||
|
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||||
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
@@ -59,110 +59,112 @@ Generated by: https://openapi-generator.tech
|
|||||||
# Do not edit the class manually.
|
# Do not edit the class manually.
|
||||||
# Ref: https://openapi-generator.tech
|
# Ref: https://openapi-generator.tech
|
||||||
#
|
#
|
||||||
__PACKAGE__->mk_classdata( 'attribute_map' => {} );
|
__PACKAGE__->mk_classdata('attribute_map' => {});
|
||||||
__PACKAGE__->mk_classdata( 'openapi_types' => {} );
|
__PACKAGE__->mk_classdata('openapi_types' => {});
|
||||||
__PACKAGE__->mk_classdata( 'method_documentation' => {} );
|
__PACKAGE__->mk_classdata('method_documentation' => {});
|
||||||
__PACKAGE__->mk_classdata( 'class_documentation' => {} );
|
__PACKAGE__->mk_classdata('class_documentation' => {});
|
||||||
|
|
||||||
# new object
|
# new plain object
|
||||||
sub new {
|
sub new {
|
||||||
my ( $class, %args ) = @_;
|
my ($class, %args) = @_;
|
||||||
|
|
||||||
my $self = bless {}, $class;
|
my $self = bless {}, $class;
|
||||||
|
|
||||||
foreach my $attribute ( keys %{ $class->attribute_map } ) {
|
$self->init(%args);
|
||||||
my $args_key = $class->attribute_map->{$attribute};
|
|
||||||
$self->$attribute( $args{$args_key} );
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
# initialize the object
|
||||||
|
sub init
|
||||||
|
{
|
||||||
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
|
foreach my $attribute (keys %{$self->attribute_map}) {
|
||||||
|
my $args_key = $self->attribute_map->{$attribute};
|
||||||
|
$self->$attribute( $args{ $args_key } );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# return perl hash
|
# return perl hash
|
||||||
sub to_hash {
|
sub to_hash {
|
||||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
my $self = shift;
|
||||||
|
my $_hash = decode_json(JSON->new->convert_blessed->encode($self));
|
||||||
|
|
||||||
|
return $_hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
# used by JSON for serialization
|
# used by JSON for serialization
|
||||||
sub TO_JSON {
|
sub TO_JSON {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $_data = {};
|
my $_data = {};
|
||||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
foreach my $_key (keys %{$self->attribute_map}) {
|
||||||
if ( defined $self->{$_key} ) {
|
if (defined $self->{$_key}) {
|
||||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
$_data->{$self->attribute_map->{$_key}} = $self->{$_key};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $_data;
|
return $_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
# from Perl hashref
|
# from Perl hashref
|
||||||
sub from_hash {
|
sub from_hash {
|
||||||
my ( $self, $hash ) = @_;
|
my ($self, $hash) = @_;
|
||||||
|
|
||||||
# loop through attributes and use openapi_types to deserialize the data
|
# loop through attributes and use openapi_types to deserialize the data
|
||||||
while ( my ( $_key, $_type ) = each %{ $self->openapi_types } ) {
|
while ( my ($_key, $_type) = each %{$self->openapi_types} ) {
|
||||||
my $_json_attribute = $self->attribute_map->{$_key};
|
my $_json_attribute = $self->attribute_map->{$_key};
|
||||||
if ( $_type =~ /^array\[/i ) { # array
|
if ($_type =~ /^array\[/i) { # array
|
||||||
my $_subclass = substr( $_type, 6, -1 );
|
my $_subclass = substr($_type, 6, -1);
|
||||||
my @_array = ();
|
my @_array = ();
|
||||||
foreach my $_element ( @{ $hash->{$_json_attribute} } ) {
|
foreach my $_element (@{$hash->{$_json_attribute}}) {
|
||||||
push @_array, $self->_deserialize( $_subclass, $_element );
|
push @_array, $self->_deserialize($_subclass, $_element);
|
||||||
}
|
}
|
||||||
$self->{$_key} = \@_array;
|
$self->{$_key} = \@_array;
|
||||||
}
|
} elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
|
||||||
elsif ( exists $hash->{$_json_attribute} )
|
$self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute});
|
||||||
{ #hash(model), primitive, datetime
|
} else {
|
||||||
$self->{$_key} =
|
$log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
|
||||||
$self->_deserialize( $_type, $hash->{$_json_attribute} );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$log->debugf( "Warning: %s (%s) does not exist in input hash\n",
|
|
||||||
$_key, $_json_attribute );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
# deserialize non-array data
|
# deserialize non-array data
|
||||||
sub _deserialize {
|
sub _deserialize {
|
||||||
my ( $self, $type, $data ) = @_;
|
my ($self, $type, $data) = @_;
|
||||||
$log->debugf( "deserializing %s with %s", Dumper($data), $type );
|
$log->debugf("deserializing %s with %s",Dumper($data), $type);
|
||||||
|
|
||||||
if ( $type eq 'DateTime' ) {
|
if ($type eq 'DateTime') {
|
||||||
return DateTime->from_epoch( epoch => str2time($data) );
|
return DateTime->from_epoch(epoch => str2time($data));
|
||||||
}
|
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
|
||||||
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
} else { # hash(model)
|
||||||
else { # hash(model)
|
|
||||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||||
return $_instance->from_hash($data);
|
return $_instance->from_hash($data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
__PACKAGE__->class_documentation(
|
|
||||||
{
|
|
||||||
description => '',
|
|
||||||
class => 'EnumClass',
|
|
||||||
required => [], # TODO
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
__PACKAGE__->method_documentation( {} );
|
|
||||||
|
|
||||||
__PACKAGE__->openapi_types(
|
__PACKAGE__->class_documentation({description => '',
|
||||||
{
|
class => 'EnumClass',
|
||||||
|
required => [], # TODO
|
||||||
|
} );
|
||||||
|
|
||||||
}
|
__PACKAGE__->method_documentation({
|
||||||
);
|
});
|
||||||
|
|
||||||
__PACKAGE__->attribute_map(
|
__PACKAGE__->openapi_types( {
|
||||||
{
|
|
||||||
|
} );
|
||||||
|
|
||||||
}
|
__PACKAGE__->attribute_map( {
|
||||||
);
|
|
||||||
|
} );
|
||||||
|
|
||||||
|
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
||||||
|
|
||||||
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
=begin comment
|
=begin comment
|
||||||
|
|
||||||
OpenAPI Petstore
|
OpenAPI Petstore
|
||||||
@@ -33,7 +32,7 @@ use DateTime;
|
|||||||
|
|
||||||
use WWW::OpenAPIClient::Object::OuterEnum;
|
use WWW::OpenAPIClient::Object::OuterEnum;
|
||||||
|
|
||||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||||
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
@@ -61,156 +60,155 @@ Generated by: https://openapi-generator.tech
|
|||||||
# Do not edit the class manually.
|
# Do not edit the class manually.
|
||||||
# Ref: https://openapi-generator.tech
|
# Ref: https://openapi-generator.tech
|
||||||
#
|
#
|
||||||
__PACKAGE__->mk_classdata( 'attribute_map' => {} );
|
__PACKAGE__->mk_classdata('attribute_map' => {});
|
||||||
__PACKAGE__->mk_classdata( 'openapi_types' => {} );
|
__PACKAGE__->mk_classdata('openapi_types' => {});
|
||||||
__PACKAGE__->mk_classdata( 'method_documentation' => {} );
|
__PACKAGE__->mk_classdata('method_documentation' => {});
|
||||||
__PACKAGE__->mk_classdata( 'class_documentation' => {} );
|
__PACKAGE__->mk_classdata('class_documentation' => {});
|
||||||
|
|
||||||
# new object
|
# new plain object
|
||||||
sub new {
|
sub new {
|
||||||
my ( $class, %args ) = @_;
|
my ($class, %args) = @_;
|
||||||
|
|
||||||
my $self = bless {}, $class;
|
my $self = bless {}, $class;
|
||||||
|
|
||||||
foreach my $attribute ( keys %{ $class->attribute_map } ) {
|
$self->init(%args);
|
||||||
my $args_key = $class->attribute_map->{$attribute};
|
|
||||||
$self->$attribute( $args{$args_key} );
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
# initialize the object
|
||||||
|
sub init
|
||||||
|
{
|
||||||
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
|
foreach my $attribute (keys %{$self->attribute_map}) {
|
||||||
|
my $args_key = $self->attribute_map->{$attribute};
|
||||||
|
$self->$attribute( $args{ $args_key } );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# return perl hash
|
# return perl hash
|
||||||
sub to_hash {
|
sub to_hash {
|
||||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
my $self = shift;
|
||||||
|
my $_hash = decode_json(JSON->new->convert_blessed->encode($self));
|
||||||
|
|
||||||
|
return $_hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
# used by JSON for serialization
|
# used by JSON for serialization
|
||||||
sub TO_JSON {
|
sub TO_JSON {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $_data = {};
|
my $_data = {};
|
||||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
foreach my $_key (keys %{$self->attribute_map}) {
|
||||||
if ( defined $self->{$_key} ) {
|
if (defined $self->{$_key}) {
|
||||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
$_data->{$self->attribute_map->{$_key}} = $self->{$_key};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $_data;
|
return $_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
# from Perl hashref
|
# from Perl hashref
|
||||||
sub from_hash {
|
sub from_hash {
|
||||||
my ( $self, $hash ) = @_;
|
my ($self, $hash) = @_;
|
||||||
|
|
||||||
# loop through attributes and use openapi_types to deserialize the data
|
# loop through attributes and use openapi_types to deserialize the data
|
||||||
while ( my ( $_key, $_type ) = each %{ $self->openapi_types } ) {
|
while ( my ($_key, $_type) = each %{$self->openapi_types} ) {
|
||||||
my $_json_attribute = $self->attribute_map->{$_key};
|
my $_json_attribute = $self->attribute_map->{$_key};
|
||||||
if ( $_type =~ /^array\[/i ) { # array
|
if ($_type =~ /^array\[/i) { # array
|
||||||
my $_subclass = substr( $_type, 6, -1 );
|
my $_subclass = substr($_type, 6, -1);
|
||||||
my @_array = ();
|
my @_array = ();
|
||||||
foreach my $_element ( @{ $hash->{$_json_attribute} } ) {
|
foreach my $_element (@{$hash->{$_json_attribute}}) {
|
||||||
push @_array, $self->_deserialize( $_subclass, $_element );
|
push @_array, $self->_deserialize($_subclass, $_element);
|
||||||
}
|
}
|
||||||
$self->{$_key} = \@_array;
|
$self->{$_key} = \@_array;
|
||||||
}
|
} elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
|
||||||
elsif ( exists $hash->{$_json_attribute} )
|
$self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute});
|
||||||
{ #hash(model), primitive, datetime
|
} else {
|
||||||
$self->{$_key} =
|
$log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
|
||||||
$self->_deserialize( $_type, $hash->{$_json_attribute} );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$log->debugf( "Warning: %s (%s) does not exist in input hash\n",
|
|
||||||
$_key, $_json_attribute );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
# deserialize non-array data
|
# deserialize non-array data
|
||||||
sub _deserialize {
|
sub _deserialize {
|
||||||
my ( $self, $type, $data ) = @_;
|
my ($self, $type, $data) = @_;
|
||||||
$log->debugf( "deserializing %s with %s", Dumper($data), $type );
|
$log->debugf("deserializing %s with %s",Dumper($data), $type);
|
||||||
|
|
||||||
if ( $type eq 'DateTime' ) {
|
if ($type eq 'DateTime') {
|
||||||
return DateTime->from_epoch( epoch => str2time($data) );
|
return DateTime->from_epoch(epoch => str2time($data));
|
||||||
}
|
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
|
||||||
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
} else { # hash(model)
|
||||||
else { # hash(model)
|
|
||||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||||
return $_instance->from_hash($data);
|
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__->openapi_types(
|
__PACKAGE__->class_documentation({description => '',
|
||||||
{
|
class => 'EnumTest',
|
||||||
'enum_string' => 'string',
|
required => [], # TODO
|
||||||
'enum_string_required' => 'string',
|
} );
|
||||||
'enum_integer' => 'int',
|
|
||||||
'enum_number' => 'double',
|
|
||||||
'outer_enum' => 'OuterEnum'
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
__PACKAGE__->attribute_map(
|
__PACKAGE__->method_documentation({
|
||||||
{
|
'enum_string' => {
|
||||||
'enum_string' => 'enum_string',
|
datatype => 'string',
|
||||||
'enum_string_required' => 'enum_string_required',
|
base_name => 'enum_string',
|
||||||
'enum_integer' => 'enum_integer',
|
description => '',
|
||||||
'enum_number' => 'enum_number',
|
format => '',
|
||||||
'outer_enum' => 'outerEnum'
|
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__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
=begin comment
|
=begin comment
|
||||||
|
|
||||||
OpenAPI Petstore
|
OpenAPI Petstore
|
||||||
@@ -31,7 +30,8 @@ use Log::Any qw($log);
|
|||||||
use Date::Parse;
|
use Date::Parse;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
|
||||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
|
||||||
|
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||||
|
|
||||||
#
|
#
|
||||||
#Must be named `File` for test.
|
#Must be named `File` for test.
|
||||||
@@ -59,120 +59,119 @@ Generated by: https://openapi-generator.tech
|
|||||||
# Do not edit the class manually.
|
# Do not edit the class manually.
|
||||||
# Ref: https://openapi-generator.tech
|
# Ref: https://openapi-generator.tech
|
||||||
#
|
#
|
||||||
__PACKAGE__->mk_classdata( 'attribute_map' => {} );
|
__PACKAGE__->mk_classdata('attribute_map' => {});
|
||||||
__PACKAGE__->mk_classdata( 'openapi_types' => {} );
|
__PACKAGE__->mk_classdata('openapi_types' => {});
|
||||||
__PACKAGE__->mk_classdata( 'method_documentation' => {} );
|
__PACKAGE__->mk_classdata('method_documentation' => {});
|
||||||
__PACKAGE__->mk_classdata( 'class_documentation' => {} );
|
__PACKAGE__->mk_classdata('class_documentation' => {});
|
||||||
|
|
||||||
# new object
|
# new plain object
|
||||||
sub new {
|
sub new {
|
||||||
my ( $class, %args ) = @_;
|
my ($class, %args) = @_;
|
||||||
|
|
||||||
my $self = bless {}, $class;
|
my $self = bless {}, $class;
|
||||||
|
|
||||||
foreach my $attribute ( keys %{ $class->attribute_map } ) {
|
$self->init(%args);
|
||||||
my $args_key = $class->attribute_map->{$attribute};
|
|
||||||
$self->$attribute( $args{$args_key} );
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
# initialize the object
|
||||||
|
sub init
|
||||||
|
{
|
||||||
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
|
foreach my $attribute (keys %{$self->attribute_map}) {
|
||||||
|
my $args_key = $self->attribute_map->{$attribute};
|
||||||
|
$self->$attribute( $args{ $args_key } );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# return perl hash
|
# return perl hash
|
||||||
sub to_hash {
|
sub to_hash {
|
||||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
my $self = shift;
|
||||||
|
my $_hash = decode_json(JSON->new->convert_blessed->encode($self));
|
||||||
|
|
||||||
|
return $_hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
# used by JSON for serialization
|
# used by JSON for serialization
|
||||||
sub TO_JSON {
|
sub TO_JSON {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $_data = {};
|
my $_data = {};
|
||||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
foreach my $_key (keys %{$self->attribute_map}) {
|
||||||
if ( defined $self->{$_key} ) {
|
if (defined $self->{$_key}) {
|
||||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
$_data->{$self->attribute_map->{$_key}} = $self->{$_key};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $_data;
|
return $_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
# from Perl hashref
|
# from Perl hashref
|
||||||
sub from_hash {
|
sub from_hash {
|
||||||
my ( $self, $hash ) = @_;
|
my ($self, $hash) = @_;
|
||||||
|
|
||||||
# loop through attributes and use openapi_types to deserialize the data
|
# loop through attributes and use openapi_types to deserialize the data
|
||||||
while ( my ( $_key, $_type ) = each %{ $self->openapi_types } ) {
|
while ( my ($_key, $_type) = each %{$self->openapi_types} ) {
|
||||||
my $_json_attribute = $self->attribute_map->{$_key};
|
my $_json_attribute = $self->attribute_map->{$_key};
|
||||||
if ( $_type =~ /^array\[/i ) { # array
|
if ($_type =~ /^array\[/i) { # array
|
||||||
my $_subclass = substr( $_type, 6, -1 );
|
my $_subclass = substr($_type, 6, -1);
|
||||||
my @_array = ();
|
my @_array = ();
|
||||||
foreach my $_element ( @{ $hash->{$_json_attribute} } ) {
|
foreach my $_element (@{$hash->{$_json_attribute}}) {
|
||||||
push @_array, $self->_deserialize( $_subclass, $_element );
|
push @_array, $self->_deserialize($_subclass, $_element);
|
||||||
}
|
}
|
||||||
$self->{$_key} = \@_array;
|
$self->{$_key} = \@_array;
|
||||||
}
|
} elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
|
||||||
elsif ( exists $hash->{$_json_attribute} )
|
$self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute});
|
||||||
{ #hash(model), primitive, datetime
|
} else {
|
||||||
$self->{$_key} =
|
$log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
|
||||||
$self->_deserialize( $_type, $hash->{$_json_attribute} );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$log->debugf( "Warning: %s (%s) does not exist in input hash\n",
|
|
||||||
$_key, $_json_attribute );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
# deserialize non-array data
|
# deserialize non-array data
|
||||||
sub _deserialize {
|
sub _deserialize {
|
||||||
my ( $self, $type, $data ) = @_;
|
my ($self, $type, $data) = @_;
|
||||||
$log->debugf( "deserializing %s with %s", Dumper($data), $type );
|
$log->debugf("deserializing %s with %s",Dumper($data), $type);
|
||||||
|
|
||||||
if ( $type eq 'DateTime' ) {
|
if ($type eq 'DateTime') {
|
||||||
return DateTime->from_epoch( epoch => str2time($data) );
|
return DateTime->from_epoch(epoch => str2time($data));
|
||||||
}
|
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
|
||||||
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
} else { # hash(model)
|
||||||
else { # hash(model)
|
|
||||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||||
return $_instance->from_hash($data);
|
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(
|
__PACKAGE__->class_documentation({description => 'Must be named `File` for test.',
|
||||||
{
|
class => 'File',
|
||||||
'source_uri' => 'string'
|
required => [], # TODO
|
||||||
}
|
} );
|
||||||
);
|
|
||||||
|
|
||||||
__PACKAGE__->attribute_map(
|
__PACKAGE__->method_documentation({
|
||||||
{
|
'source_uri' => {
|
||||||
'source_uri' => 'sourceURI'
|
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});
|
||||||
|
|
||||||
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
=begin comment
|
=begin comment
|
||||||
|
|
||||||
OpenAPI Petstore
|
OpenAPI Petstore
|
||||||
@@ -33,7 +32,7 @@ use DateTime;
|
|||||||
|
|
||||||
use WWW::OpenAPIClient::Object::File;
|
use WWW::OpenAPIClient::Object::File;
|
||||||
|
|
||||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||||
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
@@ -61,129 +60,128 @@ Generated by: https://openapi-generator.tech
|
|||||||
# Do not edit the class manually.
|
# Do not edit the class manually.
|
||||||
# Ref: https://openapi-generator.tech
|
# Ref: https://openapi-generator.tech
|
||||||
#
|
#
|
||||||
__PACKAGE__->mk_classdata( 'attribute_map' => {} );
|
__PACKAGE__->mk_classdata('attribute_map' => {});
|
||||||
__PACKAGE__->mk_classdata( 'openapi_types' => {} );
|
__PACKAGE__->mk_classdata('openapi_types' => {});
|
||||||
__PACKAGE__->mk_classdata( 'method_documentation' => {} );
|
__PACKAGE__->mk_classdata('method_documentation' => {});
|
||||||
__PACKAGE__->mk_classdata( 'class_documentation' => {} );
|
__PACKAGE__->mk_classdata('class_documentation' => {});
|
||||||
|
|
||||||
# new object
|
# new plain object
|
||||||
sub new {
|
sub new {
|
||||||
my ( $class, %args ) = @_;
|
my ($class, %args) = @_;
|
||||||
|
|
||||||
my $self = bless {}, $class;
|
my $self = bless {}, $class;
|
||||||
|
|
||||||
foreach my $attribute ( keys %{ $class->attribute_map } ) {
|
$self->init(%args);
|
||||||
my $args_key = $class->attribute_map->{$attribute};
|
|
||||||
$self->$attribute( $args{$args_key} );
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
# initialize the object
|
||||||
|
sub init
|
||||||
|
{
|
||||||
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
|
foreach my $attribute (keys %{$self->attribute_map}) {
|
||||||
|
my $args_key = $self->attribute_map->{$attribute};
|
||||||
|
$self->$attribute( $args{ $args_key } );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# return perl hash
|
# return perl hash
|
||||||
sub to_hash {
|
sub to_hash {
|
||||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
my $self = shift;
|
||||||
|
my $_hash = decode_json(JSON->new->convert_blessed->encode($self));
|
||||||
|
|
||||||
|
return $_hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
# used by JSON for serialization
|
# used by JSON for serialization
|
||||||
sub TO_JSON {
|
sub TO_JSON {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $_data = {};
|
my $_data = {};
|
||||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
foreach my $_key (keys %{$self->attribute_map}) {
|
||||||
if ( defined $self->{$_key} ) {
|
if (defined $self->{$_key}) {
|
||||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
$_data->{$self->attribute_map->{$_key}} = $self->{$_key};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $_data;
|
return $_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
# from Perl hashref
|
# from Perl hashref
|
||||||
sub from_hash {
|
sub from_hash {
|
||||||
my ( $self, $hash ) = @_;
|
my ($self, $hash) = @_;
|
||||||
|
|
||||||
# loop through attributes and use openapi_types to deserialize the data
|
# loop through attributes and use openapi_types to deserialize the data
|
||||||
while ( my ( $_key, $_type ) = each %{ $self->openapi_types } ) {
|
while ( my ($_key, $_type) = each %{$self->openapi_types} ) {
|
||||||
my $_json_attribute = $self->attribute_map->{$_key};
|
my $_json_attribute = $self->attribute_map->{$_key};
|
||||||
if ( $_type =~ /^array\[/i ) { # array
|
if ($_type =~ /^array\[/i) { # array
|
||||||
my $_subclass = substr( $_type, 6, -1 );
|
my $_subclass = substr($_type, 6, -1);
|
||||||
my @_array = ();
|
my @_array = ();
|
||||||
foreach my $_element ( @{ $hash->{$_json_attribute} } ) {
|
foreach my $_element (@{$hash->{$_json_attribute}}) {
|
||||||
push @_array, $self->_deserialize( $_subclass, $_element );
|
push @_array, $self->_deserialize($_subclass, $_element);
|
||||||
}
|
}
|
||||||
$self->{$_key} = \@_array;
|
$self->{$_key} = \@_array;
|
||||||
}
|
} elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
|
||||||
elsif ( exists $hash->{$_json_attribute} )
|
$self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute});
|
||||||
{ #hash(model), primitive, datetime
|
} else {
|
||||||
$self->{$_key} =
|
$log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
|
||||||
$self->_deserialize( $_type, $hash->{$_json_attribute} );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$log->debugf( "Warning: %s (%s) does not exist in input hash\n",
|
|
||||||
$_key, $_json_attribute );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
# deserialize non-array data
|
# deserialize non-array data
|
||||||
sub _deserialize {
|
sub _deserialize {
|
||||||
my ( $self, $type, $data ) = @_;
|
my ($self, $type, $data) = @_;
|
||||||
$log->debugf( "deserializing %s with %s", Dumper($data), $type );
|
$log->debugf("deserializing %s with %s",Dumper($data), $type);
|
||||||
|
|
||||||
if ( $type eq 'DateTime' ) {
|
if ($type eq 'DateTime') {
|
||||||
return DateTime->from_epoch( epoch => str2time($data) );
|
return DateTime->from_epoch(epoch => str2time($data));
|
||||||
}
|
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
|
||||||
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
} else { # hash(model)
|
||||||
else { # hash(model)
|
|
||||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||||
return $_instance->from_hash($data);
|
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(
|
__PACKAGE__->class_documentation({description => '',
|
||||||
{
|
class => 'FileSchemaTestClass',
|
||||||
'file' => 'File',
|
required => [], # TODO
|
||||||
'files' => 'ARRAY[File]'
|
} );
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
__PACKAGE__->attribute_map(
|
__PACKAGE__->method_documentation({
|
||||||
{
|
'file' => {
|
||||||
'file' => 'file',
|
datatype => 'File',
|
||||||
'files' => 'files'
|
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});
|
||||||
|
|
||||||
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|||||||
177
samples/client/petstore/perl/lib/WWW/OpenAPIClient/Object/Foo.pm
Normal file
177
samples/client/petstore/perl/lib/WWW/OpenAPIClient/Object/Foo.pm
Normal file
@@ -0,0 +1,177 @@
|
|||||||
|
=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::Foo;
|
||||||
|
|
||||||
|
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 plain object
|
||||||
|
sub new {
|
||||||
|
my ($class, %args) = @_;
|
||||||
|
|
||||||
|
my $self = bless {}, $class;
|
||||||
|
|
||||||
|
$self->init(%args);
|
||||||
|
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
# initialize the object
|
||||||
|
sub init
|
||||||
|
{
|
||||||
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
|
foreach my $attribute (keys %{$self->attribute_map}) {
|
||||||
|
my $args_key = $self->attribute_map->{$attribute};
|
||||||
|
$self->$attribute( $args{ $args_key } );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# return perl hash
|
||||||
|
sub to_hash {
|
||||||
|
my $self = shift;
|
||||||
|
my $_hash = decode_json(JSON->new->convert_blessed->encode($self));
|
||||||
|
|
||||||
|
return $_hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
# 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 => 'Foo',
|
||||||
|
required => [], # TODO
|
||||||
|
} );
|
||||||
|
|
||||||
|
__PACKAGE__->method_documentation({
|
||||||
|
'bar' => {
|
||||||
|
datatype => 'string',
|
||||||
|
base_name => 'bar',
|
||||||
|
description => '',
|
||||||
|
format => '',
|
||||||
|
read_only => '',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
__PACKAGE__->openapi_types( {
|
||||||
|
'bar' => 'string'
|
||||||
|
} );
|
||||||
|
|
||||||
|
__PACKAGE__->attribute_map( {
|
||||||
|
'bar' => 'bar'
|
||||||
|
} );
|
||||||
|
|
||||||
|
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
||||||
|
|
||||||
|
|
||||||
|
1;
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
=begin comment
|
=begin comment
|
||||||
|
|
||||||
OpenAPI Petstore
|
OpenAPI Petstore
|
||||||
@@ -31,7 +30,8 @@ use Log::Any qw($log);
|
|||||||
use Date::Parse;
|
use Date::Parse;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
|
||||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
|
||||||
|
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||||
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
@@ -59,228 +59,227 @@ Generated by: https://openapi-generator.tech
|
|||||||
# Do not edit the class manually.
|
# Do not edit the class manually.
|
||||||
# Ref: https://openapi-generator.tech
|
# Ref: https://openapi-generator.tech
|
||||||
#
|
#
|
||||||
__PACKAGE__->mk_classdata( 'attribute_map' => {} );
|
__PACKAGE__->mk_classdata('attribute_map' => {});
|
||||||
__PACKAGE__->mk_classdata( 'openapi_types' => {} );
|
__PACKAGE__->mk_classdata('openapi_types' => {});
|
||||||
__PACKAGE__->mk_classdata( 'method_documentation' => {} );
|
__PACKAGE__->mk_classdata('method_documentation' => {});
|
||||||
__PACKAGE__->mk_classdata( 'class_documentation' => {} );
|
__PACKAGE__->mk_classdata('class_documentation' => {});
|
||||||
|
|
||||||
# new object
|
# new plain object
|
||||||
sub new {
|
sub new {
|
||||||
my ( $class, %args ) = @_;
|
my ($class, %args) = @_;
|
||||||
|
|
||||||
my $self = bless {}, $class;
|
my $self = bless {}, $class;
|
||||||
|
|
||||||
foreach my $attribute ( keys %{ $class->attribute_map } ) {
|
$self->init(%args);
|
||||||
my $args_key = $class->attribute_map->{$attribute};
|
|
||||||
$self->$attribute( $args{$args_key} );
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
# initialize the object
|
||||||
|
sub init
|
||||||
|
{
|
||||||
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
|
foreach my $attribute (keys %{$self->attribute_map}) {
|
||||||
|
my $args_key = $self->attribute_map->{$attribute};
|
||||||
|
$self->$attribute( $args{ $args_key } );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# return perl hash
|
# return perl hash
|
||||||
sub to_hash {
|
sub to_hash {
|
||||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
my $self = shift;
|
||||||
|
my $_hash = decode_json(JSON->new->convert_blessed->encode($self));
|
||||||
|
|
||||||
|
return $_hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
# used by JSON for serialization
|
# used by JSON for serialization
|
||||||
sub TO_JSON {
|
sub TO_JSON {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $_data = {};
|
my $_data = {};
|
||||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
foreach my $_key (keys %{$self->attribute_map}) {
|
||||||
if ( defined $self->{$_key} ) {
|
if (defined $self->{$_key}) {
|
||||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
$_data->{$self->attribute_map->{$_key}} = $self->{$_key};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $_data;
|
return $_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
# from Perl hashref
|
# from Perl hashref
|
||||||
sub from_hash {
|
sub from_hash {
|
||||||
my ( $self, $hash ) = @_;
|
my ($self, $hash) = @_;
|
||||||
|
|
||||||
# loop through attributes and use openapi_types to deserialize the data
|
# loop through attributes and use openapi_types to deserialize the data
|
||||||
while ( my ( $_key, $_type ) = each %{ $self->openapi_types } ) {
|
while ( my ($_key, $_type) = each %{$self->openapi_types} ) {
|
||||||
my $_json_attribute = $self->attribute_map->{$_key};
|
my $_json_attribute = $self->attribute_map->{$_key};
|
||||||
if ( $_type =~ /^array\[/i ) { # array
|
if ($_type =~ /^array\[/i) { # array
|
||||||
my $_subclass = substr( $_type, 6, -1 );
|
my $_subclass = substr($_type, 6, -1);
|
||||||
my @_array = ();
|
my @_array = ();
|
||||||
foreach my $_element ( @{ $hash->{$_json_attribute} } ) {
|
foreach my $_element (@{$hash->{$_json_attribute}}) {
|
||||||
push @_array, $self->_deserialize( $_subclass, $_element );
|
push @_array, $self->_deserialize($_subclass, $_element);
|
||||||
}
|
}
|
||||||
$self->{$_key} = \@_array;
|
$self->{$_key} = \@_array;
|
||||||
}
|
} elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
|
||||||
elsif ( exists $hash->{$_json_attribute} )
|
$self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute});
|
||||||
{ #hash(model), primitive, datetime
|
} else {
|
||||||
$self->{$_key} =
|
$log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
|
||||||
$self->_deserialize( $_type, $hash->{$_json_attribute} );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$log->debugf( "Warning: %s (%s) does not exist in input hash\n",
|
|
||||||
$_key, $_json_attribute );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
# deserialize non-array data
|
# deserialize non-array data
|
||||||
sub _deserialize {
|
sub _deserialize {
|
||||||
my ( $self, $type, $data ) = @_;
|
my ($self, $type, $data) = @_;
|
||||||
$log->debugf( "deserializing %s with %s", Dumper($data), $type );
|
$log->debugf("deserializing %s with %s",Dumper($data), $type);
|
||||||
|
|
||||||
if ( $type eq 'DateTime' ) {
|
if ($type eq 'DateTime') {
|
||||||
return DateTime->from_epoch( epoch => str2time($data) );
|
return DateTime->from_epoch(epoch => str2time($data));
|
||||||
}
|
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
|
||||||
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
} else { # hash(model)
|
||||||
else { # hash(model)
|
|
||||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||||
return $_instance->from_hash($data);
|
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__->openapi_types(
|
__PACKAGE__->class_documentation({description => '',
|
||||||
{
|
class => 'FormatTest',
|
||||||
'integer' => 'int',
|
required => [], # TODO
|
||||||
'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(
|
__PACKAGE__->method_documentation({
|
||||||
{
|
'integer' => {
|
||||||
'integer' => 'integer',
|
datatype => 'int',
|
||||||
'int32' => 'int32',
|
base_name => 'integer',
|
||||||
'int64' => 'int64',
|
description => '',
|
||||||
'number' => 'number',
|
format => '',
|
||||||
'float' => 'float',
|
read_only => '',
|
||||||
'double' => 'double',
|
},
|
||||||
'string' => 'string',
|
'int32' => {
|
||||||
'byte' => 'byte',
|
datatype => 'int',
|
||||||
'binary' => 'binary',
|
base_name => 'int32',
|
||||||
'date' => 'date',
|
description => '',
|
||||||
'date_time' => 'dateTime',
|
format => '',
|
||||||
'uuid' => 'uuid',
|
read_only => '',
|
||||||
'password' => 'password'
|
},
|
||||||
}
|
'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__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
=begin comment
|
=begin comment
|
||||||
|
|
||||||
OpenAPI Petstore
|
OpenAPI Petstore
|
||||||
@@ -31,7 +30,8 @@ use Log::Any qw($log);
|
|||||||
use Date::Parse;
|
use Date::Parse;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
|
||||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
|
||||||
|
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||||
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
@@ -59,129 +59,128 @@ Generated by: https://openapi-generator.tech
|
|||||||
# Do not edit the class manually.
|
# Do not edit the class manually.
|
||||||
# Ref: https://openapi-generator.tech
|
# Ref: https://openapi-generator.tech
|
||||||
#
|
#
|
||||||
__PACKAGE__->mk_classdata( 'attribute_map' => {} );
|
__PACKAGE__->mk_classdata('attribute_map' => {});
|
||||||
__PACKAGE__->mk_classdata( 'openapi_types' => {} );
|
__PACKAGE__->mk_classdata('openapi_types' => {});
|
||||||
__PACKAGE__->mk_classdata( 'method_documentation' => {} );
|
__PACKAGE__->mk_classdata('method_documentation' => {});
|
||||||
__PACKAGE__->mk_classdata( 'class_documentation' => {} );
|
__PACKAGE__->mk_classdata('class_documentation' => {});
|
||||||
|
|
||||||
# new object
|
# new plain object
|
||||||
sub new {
|
sub new {
|
||||||
my ( $class, %args ) = @_;
|
my ($class, %args) = @_;
|
||||||
|
|
||||||
my $self = bless {}, $class;
|
my $self = bless {}, $class;
|
||||||
|
|
||||||
foreach my $attribute ( keys %{ $class->attribute_map } ) {
|
$self->init(%args);
|
||||||
my $args_key = $class->attribute_map->{$attribute};
|
|
||||||
$self->$attribute( $args{$args_key} );
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
# initialize the object
|
||||||
|
sub init
|
||||||
|
{
|
||||||
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
|
foreach my $attribute (keys %{$self->attribute_map}) {
|
||||||
|
my $args_key = $self->attribute_map->{$attribute};
|
||||||
|
$self->$attribute( $args{ $args_key } );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# return perl hash
|
# return perl hash
|
||||||
sub to_hash {
|
sub to_hash {
|
||||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
my $self = shift;
|
||||||
|
my $_hash = decode_json(JSON->new->convert_blessed->encode($self));
|
||||||
|
|
||||||
|
return $_hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
# used by JSON for serialization
|
# used by JSON for serialization
|
||||||
sub TO_JSON {
|
sub TO_JSON {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $_data = {};
|
my $_data = {};
|
||||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
foreach my $_key (keys %{$self->attribute_map}) {
|
||||||
if ( defined $self->{$_key} ) {
|
if (defined $self->{$_key}) {
|
||||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
$_data->{$self->attribute_map->{$_key}} = $self->{$_key};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $_data;
|
return $_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
# from Perl hashref
|
# from Perl hashref
|
||||||
sub from_hash {
|
sub from_hash {
|
||||||
my ( $self, $hash ) = @_;
|
my ($self, $hash) = @_;
|
||||||
|
|
||||||
# loop through attributes and use openapi_types to deserialize the data
|
# loop through attributes and use openapi_types to deserialize the data
|
||||||
while ( my ( $_key, $_type ) = each %{ $self->openapi_types } ) {
|
while ( my ($_key, $_type) = each %{$self->openapi_types} ) {
|
||||||
my $_json_attribute = $self->attribute_map->{$_key};
|
my $_json_attribute = $self->attribute_map->{$_key};
|
||||||
if ( $_type =~ /^array\[/i ) { # array
|
if ($_type =~ /^array\[/i) { # array
|
||||||
my $_subclass = substr( $_type, 6, -1 );
|
my $_subclass = substr($_type, 6, -1);
|
||||||
my @_array = ();
|
my @_array = ();
|
||||||
foreach my $_element ( @{ $hash->{$_json_attribute} } ) {
|
foreach my $_element (@{$hash->{$_json_attribute}}) {
|
||||||
push @_array, $self->_deserialize( $_subclass, $_element );
|
push @_array, $self->_deserialize($_subclass, $_element);
|
||||||
}
|
}
|
||||||
$self->{$_key} = \@_array;
|
$self->{$_key} = \@_array;
|
||||||
}
|
} elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
|
||||||
elsif ( exists $hash->{$_json_attribute} )
|
$self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute});
|
||||||
{ #hash(model), primitive, datetime
|
} else {
|
||||||
$self->{$_key} =
|
$log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
|
||||||
$self->_deserialize( $_type, $hash->{$_json_attribute} );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$log->debugf( "Warning: %s (%s) does not exist in input hash\n",
|
|
||||||
$_key, $_json_attribute );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
# deserialize non-array data
|
# deserialize non-array data
|
||||||
sub _deserialize {
|
sub _deserialize {
|
||||||
my ( $self, $type, $data ) = @_;
|
my ($self, $type, $data) = @_;
|
||||||
$log->debugf( "deserializing %s with %s", Dumper($data), $type );
|
$log->debugf("deserializing %s with %s",Dumper($data), $type);
|
||||||
|
|
||||||
if ( $type eq 'DateTime' ) {
|
if ($type eq 'DateTime') {
|
||||||
return DateTime->from_epoch( epoch => str2time($data) );
|
return DateTime->from_epoch(epoch => str2time($data));
|
||||||
}
|
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
|
||||||
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
} else { # hash(model)
|
||||||
else { # hash(model)
|
|
||||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||||
return $_instance->from_hash($data);
|
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__->openapi_types(
|
__PACKAGE__->class_documentation({description => '',
|
||||||
{
|
class => 'HasOnlyReadOnly',
|
||||||
'bar' => 'string',
|
required => [], # TODO
|
||||||
'foo' => 'string'
|
} );
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
__PACKAGE__->attribute_map(
|
__PACKAGE__->method_documentation({
|
||||||
{
|
'bar' => {
|
||||||
'bar' => 'bar',
|
datatype => 'string',
|
||||||
'foo' => 'foo'
|
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__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|||||||
@@ -0,0 +1,186 @@
|
|||||||
|
=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::Human;
|
||||||
|
|
||||||
|
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 plain object
|
||||||
|
sub new {
|
||||||
|
my ($class, %args) = @_;
|
||||||
|
|
||||||
|
my $self = bless {}, $class;
|
||||||
|
|
||||||
|
$self->init(%args);
|
||||||
|
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
# initialize the object
|
||||||
|
sub init
|
||||||
|
{
|
||||||
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
|
foreach my $attribute (keys %{$self->attribute_map}) {
|
||||||
|
my $args_key = $self->attribute_map->{$attribute};
|
||||||
|
$self->$attribute( $args{ $args_key } );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# return perl hash
|
||||||
|
sub to_hash {
|
||||||
|
my $self = shift;
|
||||||
|
my $_hash = decode_json(JSON->new->convert_blessed->encode($self));
|
||||||
|
|
||||||
|
return $_hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
# 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 => 'Human',
|
||||||
|
required => [], # TODO
|
||||||
|
} );
|
||||||
|
|
||||||
|
__PACKAGE__->method_documentation({
|
||||||
|
'___type' => {
|
||||||
|
datatype => 'string',
|
||||||
|
base_name => '$_type',
|
||||||
|
description => '',
|
||||||
|
format => '',
|
||||||
|
read_only => '',
|
||||||
|
},
|
||||||
|
'body' => {
|
||||||
|
datatype => 'string',
|
||||||
|
base_name => 'body',
|
||||||
|
description => '',
|
||||||
|
format => '',
|
||||||
|
read_only => '',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
__PACKAGE__->openapi_types( {
|
||||||
|
'___type' => 'string',
|
||||||
|
'body' => 'string'
|
||||||
|
} );
|
||||||
|
|
||||||
|
__PACKAGE__->attribute_map( {
|
||||||
|
'___type' => '$_type',
|
||||||
|
'body' => 'body'
|
||||||
|
} );
|
||||||
|
|
||||||
|
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
||||||
|
|
||||||
|
|
||||||
|
1;
|
||||||
@@ -0,0 +1,186 @@
|
|||||||
|
=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::InlineObject;
|
||||||
|
|
||||||
|
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 plain object
|
||||||
|
sub new {
|
||||||
|
my ($class, %args) = @_;
|
||||||
|
|
||||||
|
my $self = bless {}, $class;
|
||||||
|
|
||||||
|
$self->init(%args);
|
||||||
|
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
# initialize the object
|
||||||
|
sub init
|
||||||
|
{
|
||||||
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
|
foreach my $attribute (keys %{$self->attribute_map}) {
|
||||||
|
my $args_key = $self->attribute_map->{$attribute};
|
||||||
|
$self->$attribute( $args{ $args_key } );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# return perl hash
|
||||||
|
sub to_hash {
|
||||||
|
my $self = shift;
|
||||||
|
my $_hash = decode_json(JSON->new->convert_blessed->encode($self));
|
||||||
|
|
||||||
|
return $_hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
# 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 => 'InlineObject',
|
||||||
|
required => [], # TODO
|
||||||
|
} );
|
||||||
|
|
||||||
|
__PACKAGE__->method_documentation({
|
||||||
|
'name' => {
|
||||||
|
datatype => 'string',
|
||||||
|
base_name => 'name',
|
||||||
|
description => 'Updated name of the pet',
|
||||||
|
format => '',
|
||||||
|
read_only => '',
|
||||||
|
},
|
||||||
|
'status' => {
|
||||||
|
datatype => 'string',
|
||||||
|
base_name => 'status',
|
||||||
|
description => 'Updated status of the pet',
|
||||||
|
format => '',
|
||||||
|
read_only => '',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
__PACKAGE__->openapi_types( {
|
||||||
|
'name' => 'string',
|
||||||
|
'status' => 'string'
|
||||||
|
} );
|
||||||
|
|
||||||
|
__PACKAGE__->attribute_map( {
|
||||||
|
'name' => 'name',
|
||||||
|
'status' => 'status'
|
||||||
|
} );
|
||||||
|
|
||||||
|
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
||||||
|
|
||||||
|
|
||||||
|
1;
|
||||||
@@ -0,0 +1,186 @@
|
|||||||
|
=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::InlineObject1;
|
||||||
|
|
||||||
|
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 plain object
|
||||||
|
sub new {
|
||||||
|
my ($class, %args) = @_;
|
||||||
|
|
||||||
|
my $self = bless {}, $class;
|
||||||
|
|
||||||
|
$self->init(%args);
|
||||||
|
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
# initialize the object
|
||||||
|
sub init
|
||||||
|
{
|
||||||
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
|
foreach my $attribute (keys %{$self->attribute_map}) {
|
||||||
|
my $args_key = $self->attribute_map->{$attribute};
|
||||||
|
$self->$attribute( $args{ $args_key } );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# return perl hash
|
||||||
|
sub to_hash {
|
||||||
|
my $self = shift;
|
||||||
|
my $_hash = decode_json(JSON->new->convert_blessed->encode($self));
|
||||||
|
|
||||||
|
return $_hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
# 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 => 'InlineObject1',
|
||||||
|
required => [], # TODO
|
||||||
|
} );
|
||||||
|
|
||||||
|
__PACKAGE__->method_documentation({
|
||||||
|
'additional_metadata' => {
|
||||||
|
datatype => 'string',
|
||||||
|
base_name => 'additionalMetadata',
|
||||||
|
description => 'Additional data to pass to server',
|
||||||
|
format => '',
|
||||||
|
read_only => '',
|
||||||
|
},
|
||||||
|
'file' => {
|
||||||
|
datatype => 'string',
|
||||||
|
base_name => 'file',
|
||||||
|
description => 'file to upload',
|
||||||
|
format => '',
|
||||||
|
read_only => '',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
__PACKAGE__->openapi_types( {
|
||||||
|
'additional_metadata' => 'string',
|
||||||
|
'file' => 'string'
|
||||||
|
} );
|
||||||
|
|
||||||
|
__PACKAGE__->attribute_map( {
|
||||||
|
'additional_metadata' => 'additionalMetadata',
|
||||||
|
'file' => 'file'
|
||||||
|
} );
|
||||||
|
|
||||||
|
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
||||||
|
|
||||||
|
|
||||||
|
1;
|
||||||
@@ -0,0 +1,186 @@
|
|||||||
|
=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::InlineObject2;
|
||||||
|
|
||||||
|
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 plain object
|
||||||
|
sub new {
|
||||||
|
my ($class, %args) = @_;
|
||||||
|
|
||||||
|
my $self = bless {}, $class;
|
||||||
|
|
||||||
|
$self->init(%args);
|
||||||
|
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
# initialize the object
|
||||||
|
sub init
|
||||||
|
{
|
||||||
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
|
foreach my $attribute (keys %{$self->attribute_map}) {
|
||||||
|
my $args_key = $self->attribute_map->{$attribute};
|
||||||
|
$self->$attribute( $args{ $args_key } );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# return perl hash
|
||||||
|
sub to_hash {
|
||||||
|
my $self = shift;
|
||||||
|
my $_hash = decode_json(JSON->new->convert_blessed->encode($self));
|
||||||
|
|
||||||
|
return $_hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
# 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 => 'InlineObject2',
|
||||||
|
required => [], # TODO
|
||||||
|
} );
|
||||||
|
|
||||||
|
__PACKAGE__->method_documentation({
|
||||||
|
'enum_form_string_array' => {
|
||||||
|
datatype => 'ARRAY[string]',
|
||||||
|
base_name => 'enum_form_string_array',
|
||||||
|
description => 'Form parameter enum test (string array)',
|
||||||
|
format => '',
|
||||||
|
read_only => '',
|
||||||
|
},
|
||||||
|
'enum_form_string' => {
|
||||||
|
datatype => 'string',
|
||||||
|
base_name => 'enum_form_string',
|
||||||
|
description => 'Form parameter enum test (string)',
|
||||||
|
format => '',
|
||||||
|
read_only => '',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
__PACKAGE__->openapi_types( {
|
||||||
|
'enum_form_string_array' => 'ARRAY[string]',
|
||||||
|
'enum_form_string' => 'string'
|
||||||
|
} );
|
||||||
|
|
||||||
|
__PACKAGE__->attribute_map( {
|
||||||
|
'enum_form_string_array' => 'enum_form_string_array',
|
||||||
|
'enum_form_string' => 'enum_form_string'
|
||||||
|
} );
|
||||||
|
|
||||||
|
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
||||||
|
|
||||||
|
|
||||||
|
1;
|
||||||
@@ -0,0 +1,294 @@
|
|||||||
|
=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::InlineObject3;
|
||||||
|
|
||||||
|
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 plain object
|
||||||
|
sub new {
|
||||||
|
my ($class, %args) = @_;
|
||||||
|
|
||||||
|
my $self = bless {}, $class;
|
||||||
|
|
||||||
|
$self->init(%args);
|
||||||
|
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
# initialize the object
|
||||||
|
sub init
|
||||||
|
{
|
||||||
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
|
foreach my $attribute (keys %{$self->attribute_map}) {
|
||||||
|
my $args_key = $self->attribute_map->{$attribute};
|
||||||
|
$self->$attribute( $args{ $args_key } );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# return perl hash
|
||||||
|
sub to_hash {
|
||||||
|
my $self = shift;
|
||||||
|
my $_hash = decode_json(JSON->new->convert_blessed->encode($self));
|
||||||
|
|
||||||
|
return $_hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
# 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 => 'InlineObject3',
|
||||||
|
required => [], # TODO
|
||||||
|
} );
|
||||||
|
|
||||||
|
__PACKAGE__->method_documentation({
|
||||||
|
'integer' => {
|
||||||
|
datatype => 'int',
|
||||||
|
base_name => 'integer',
|
||||||
|
description => 'None',
|
||||||
|
format => '',
|
||||||
|
read_only => '',
|
||||||
|
},
|
||||||
|
'int32' => {
|
||||||
|
datatype => 'int',
|
||||||
|
base_name => 'int32',
|
||||||
|
description => 'None',
|
||||||
|
format => '',
|
||||||
|
read_only => '',
|
||||||
|
},
|
||||||
|
'int64' => {
|
||||||
|
datatype => 'int',
|
||||||
|
base_name => 'int64',
|
||||||
|
description => 'None',
|
||||||
|
format => '',
|
||||||
|
read_only => '',
|
||||||
|
},
|
||||||
|
'number' => {
|
||||||
|
datatype => 'double',
|
||||||
|
base_name => 'number',
|
||||||
|
description => 'None',
|
||||||
|
format => '',
|
||||||
|
read_only => '',
|
||||||
|
},
|
||||||
|
'float' => {
|
||||||
|
datatype => 'double',
|
||||||
|
base_name => 'float',
|
||||||
|
description => 'None',
|
||||||
|
format => '',
|
||||||
|
read_only => '',
|
||||||
|
},
|
||||||
|
'double' => {
|
||||||
|
datatype => 'double',
|
||||||
|
base_name => 'double',
|
||||||
|
description => 'None',
|
||||||
|
format => '',
|
||||||
|
read_only => '',
|
||||||
|
},
|
||||||
|
'string' => {
|
||||||
|
datatype => 'string',
|
||||||
|
base_name => 'string',
|
||||||
|
description => 'None',
|
||||||
|
format => '',
|
||||||
|
read_only => '',
|
||||||
|
},
|
||||||
|
'pattern_without_delimiter' => {
|
||||||
|
datatype => 'string',
|
||||||
|
base_name => 'pattern_without_delimiter',
|
||||||
|
description => 'None',
|
||||||
|
format => '',
|
||||||
|
read_only => '',
|
||||||
|
},
|
||||||
|
'byte' => {
|
||||||
|
datatype => 'string',
|
||||||
|
base_name => 'byte',
|
||||||
|
description => 'None',
|
||||||
|
format => '',
|
||||||
|
read_only => '',
|
||||||
|
},
|
||||||
|
'binary' => {
|
||||||
|
datatype => 'string',
|
||||||
|
base_name => 'binary',
|
||||||
|
description => 'None',
|
||||||
|
format => '',
|
||||||
|
read_only => '',
|
||||||
|
},
|
||||||
|
'date' => {
|
||||||
|
datatype => 'DateTime',
|
||||||
|
base_name => 'date',
|
||||||
|
description => 'None',
|
||||||
|
format => '',
|
||||||
|
read_only => '',
|
||||||
|
},
|
||||||
|
'date_time' => {
|
||||||
|
datatype => 'DateTime',
|
||||||
|
base_name => 'dateTime',
|
||||||
|
description => 'None',
|
||||||
|
format => '',
|
||||||
|
read_only => '',
|
||||||
|
},
|
||||||
|
'password' => {
|
||||||
|
datatype => 'string',
|
||||||
|
base_name => 'password',
|
||||||
|
description => 'None',
|
||||||
|
format => '',
|
||||||
|
read_only => '',
|
||||||
|
},
|
||||||
|
'callback' => {
|
||||||
|
datatype => 'string',
|
||||||
|
base_name => 'callback',
|
||||||
|
description => 'None',
|
||||||
|
format => '',
|
||||||
|
read_only => '',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
__PACKAGE__->openapi_types( {
|
||||||
|
'integer' => 'int',
|
||||||
|
'int32' => 'int',
|
||||||
|
'int64' => 'int',
|
||||||
|
'number' => 'double',
|
||||||
|
'float' => 'double',
|
||||||
|
'double' => 'double',
|
||||||
|
'string' => 'string',
|
||||||
|
'pattern_without_delimiter' => 'string',
|
||||||
|
'byte' => 'string',
|
||||||
|
'binary' => 'string',
|
||||||
|
'date' => 'DateTime',
|
||||||
|
'date_time' => 'DateTime',
|
||||||
|
'password' => 'string',
|
||||||
|
'callback' => 'string'
|
||||||
|
} );
|
||||||
|
|
||||||
|
__PACKAGE__->attribute_map( {
|
||||||
|
'integer' => 'integer',
|
||||||
|
'int32' => 'int32',
|
||||||
|
'int64' => 'int64',
|
||||||
|
'number' => 'number',
|
||||||
|
'float' => 'float',
|
||||||
|
'double' => 'double',
|
||||||
|
'string' => 'string',
|
||||||
|
'pattern_without_delimiter' => 'pattern_without_delimiter',
|
||||||
|
'byte' => 'byte',
|
||||||
|
'binary' => 'binary',
|
||||||
|
'date' => 'date',
|
||||||
|
'date_time' => 'dateTime',
|
||||||
|
'password' => 'password',
|
||||||
|
'callback' => 'callback'
|
||||||
|
} );
|
||||||
|
|
||||||
|
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
||||||
|
|
||||||
|
|
||||||
|
1;
|
||||||
@@ -0,0 +1,186 @@
|
|||||||
|
=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::InlineObject4;
|
||||||
|
|
||||||
|
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 plain object
|
||||||
|
sub new {
|
||||||
|
my ($class, %args) = @_;
|
||||||
|
|
||||||
|
my $self = bless {}, $class;
|
||||||
|
|
||||||
|
$self->init(%args);
|
||||||
|
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
# initialize the object
|
||||||
|
sub init
|
||||||
|
{
|
||||||
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
|
foreach my $attribute (keys %{$self->attribute_map}) {
|
||||||
|
my $args_key = $self->attribute_map->{$attribute};
|
||||||
|
$self->$attribute( $args{ $args_key } );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# return perl hash
|
||||||
|
sub to_hash {
|
||||||
|
my $self = shift;
|
||||||
|
my $_hash = decode_json(JSON->new->convert_blessed->encode($self));
|
||||||
|
|
||||||
|
return $_hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
# 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 => 'InlineObject4',
|
||||||
|
required => [], # TODO
|
||||||
|
} );
|
||||||
|
|
||||||
|
__PACKAGE__->method_documentation({
|
||||||
|
'param' => {
|
||||||
|
datatype => 'string',
|
||||||
|
base_name => 'param',
|
||||||
|
description => 'field1',
|
||||||
|
format => '',
|
||||||
|
read_only => '',
|
||||||
|
},
|
||||||
|
'param2' => {
|
||||||
|
datatype => 'string',
|
||||||
|
base_name => 'param2',
|
||||||
|
description => 'field2',
|
||||||
|
format => '',
|
||||||
|
read_only => '',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
__PACKAGE__->openapi_types( {
|
||||||
|
'param' => 'string',
|
||||||
|
'param2' => 'string'
|
||||||
|
} );
|
||||||
|
|
||||||
|
__PACKAGE__->attribute_map( {
|
||||||
|
'param' => 'param',
|
||||||
|
'param2' => 'param2'
|
||||||
|
} );
|
||||||
|
|
||||||
|
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
||||||
|
|
||||||
|
|
||||||
|
1;
|
||||||
@@ -0,0 +1,186 @@
|
|||||||
|
=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::InlineObject5;
|
||||||
|
|
||||||
|
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 plain object
|
||||||
|
sub new {
|
||||||
|
my ($class, %args) = @_;
|
||||||
|
|
||||||
|
my $self = bless {}, $class;
|
||||||
|
|
||||||
|
$self->init(%args);
|
||||||
|
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
# initialize the object
|
||||||
|
sub init
|
||||||
|
{
|
||||||
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
|
foreach my $attribute (keys %{$self->attribute_map}) {
|
||||||
|
my $args_key = $self->attribute_map->{$attribute};
|
||||||
|
$self->$attribute( $args{ $args_key } );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# return perl hash
|
||||||
|
sub to_hash {
|
||||||
|
my $self = shift;
|
||||||
|
my $_hash = decode_json(JSON->new->convert_blessed->encode($self));
|
||||||
|
|
||||||
|
return $_hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
# 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 => 'InlineObject5',
|
||||||
|
required => [], # TODO
|
||||||
|
} );
|
||||||
|
|
||||||
|
__PACKAGE__->method_documentation({
|
||||||
|
'additional_metadata' => {
|
||||||
|
datatype => 'string',
|
||||||
|
base_name => 'additionalMetadata',
|
||||||
|
description => 'Additional data to pass to server',
|
||||||
|
format => '',
|
||||||
|
read_only => '',
|
||||||
|
},
|
||||||
|
'required_file' => {
|
||||||
|
datatype => 'string',
|
||||||
|
base_name => 'requiredFile',
|
||||||
|
description => 'file to upload',
|
||||||
|
format => '',
|
||||||
|
read_only => '',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
__PACKAGE__->openapi_types( {
|
||||||
|
'additional_metadata' => 'string',
|
||||||
|
'required_file' => 'string'
|
||||||
|
} );
|
||||||
|
|
||||||
|
__PACKAGE__->attribute_map( {
|
||||||
|
'additional_metadata' => 'additionalMetadata',
|
||||||
|
'required_file' => 'requiredFile'
|
||||||
|
} );
|
||||||
|
|
||||||
|
__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::InlineResponseDefault;
|
||||||
|
|
||||||
|
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::Foo;
|
||||||
|
|
||||||
|
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 plain object
|
||||||
|
sub new {
|
||||||
|
my ($class, %args) = @_;
|
||||||
|
|
||||||
|
my $self = bless {}, $class;
|
||||||
|
|
||||||
|
$self->init(%args);
|
||||||
|
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
# initialize the object
|
||||||
|
sub init
|
||||||
|
{
|
||||||
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
|
foreach my $attribute (keys %{$self->attribute_map}) {
|
||||||
|
my $args_key = $self->attribute_map->{$attribute};
|
||||||
|
$self->$attribute( $args{ $args_key } );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# return perl hash
|
||||||
|
sub to_hash {
|
||||||
|
my $self = shift;
|
||||||
|
my $_hash = decode_json(JSON->new->convert_blessed->encode($self));
|
||||||
|
|
||||||
|
return $_hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
# 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 => 'InlineResponseDefault',
|
||||||
|
required => [], # TODO
|
||||||
|
} );
|
||||||
|
|
||||||
|
__PACKAGE__->method_documentation({
|
||||||
|
'string' => {
|
||||||
|
datatype => 'Foo',
|
||||||
|
base_name => 'string',
|
||||||
|
description => '',
|
||||||
|
format => '',
|
||||||
|
read_only => '',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
__PACKAGE__->openapi_types( {
|
||||||
|
'string' => 'Foo'
|
||||||
|
} );
|
||||||
|
|
||||||
|
__PACKAGE__->attribute_map( {
|
||||||
|
'string' => 'string'
|
||||||
|
} );
|
||||||
|
|
||||||
|
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
||||||
|
|
||||||
|
|
||||||
|
1;
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
=begin comment
|
=begin comment
|
||||||
|
|
||||||
OpenAPI Petstore
|
OpenAPI Petstore
|
||||||
@@ -31,7 +30,8 @@ use Log::Any qw($log);
|
|||||||
use Date::Parse;
|
use Date::Parse;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
|
||||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
|
||||||
|
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||||
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
@@ -59,120 +59,119 @@ Generated by: https://openapi-generator.tech
|
|||||||
# Do not edit the class manually.
|
# Do not edit the class manually.
|
||||||
# Ref: https://openapi-generator.tech
|
# Ref: https://openapi-generator.tech
|
||||||
#
|
#
|
||||||
__PACKAGE__->mk_classdata( 'attribute_map' => {} );
|
__PACKAGE__->mk_classdata('attribute_map' => {});
|
||||||
__PACKAGE__->mk_classdata( 'openapi_types' => {} );
|
__PACKAGE__->mk_classdata('openapi_types' => {});
|
||||||
__PACKAGE__->mk_classdata( 'method_documentation' => {} );
|
__PACKAGE__->mk_classdata('method_documentation' => {});
|
||||||
__PACKAGE__->mk_classdata( 'class_documentation' => {} );
|
__PACKAGE__->mk_classdata('class_documentation' => {});
|
||||||
|
|
||||||
# new object
|
# new plain object
|
||||||
sub new {
|
sub new {
|
||||||
my ( $class, %args ) = @_;
|
my ($class, %args) = @_;
|
||||||
|
|
||||||
my $self = bless {}, $class;
|
my $self = bless {}, $class;
|
||||||
|
|
||||||
foreach my $attribute ( keys %{ $class->attribute_map } ) {
|
$self->init(%args);
|
||||||
my $args_key = $class->attribute_map->{$attribute};
|
|
||||||
$self->$attribute( $args{$args_key} );
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
# initialize the object
|
||||||
|
sub init
|
||||||
|
{
|
||||||
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
|
foreach my $attribute (keys %{$self->attribute_map}) {
|
||||||
|
my $args_key = $self->attribute_map->{$attribute};
|
||||||
|
$self->$attribute( $args{ $args_key } );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# return perl hash
|
# return perl hash
|
||||||
sub to_hash {
|
sub to_hash {
|
||||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
my $self = shift;
|
||||||
|
my $_hash = decode_json(JSON->new->convert_blessed->encode($self));
|
||||||
|
|
||||||
|
return $_hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
# used by JSON for serialization
|
# used by JSON for serialization
|
||||||
sub TO_JSON {
|
sub TO_JSON {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $_data = {};
|
my $_data = {};
|
||||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
foreach my $_key (keys %{$self->attribute_map}) {
|
||||||
if ( defined $self->{$_key} ) {
|
if (defined $self->{$_key}) {
|
||||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
$_data->{$self->attribute_map->{$_key}} = $self->{$_key};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $_data;
|
return $_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
# from Perl hashref
|
# from Perl hashref
|
||||||
sub from_hash {
|
sub from_hash {
|
||||||
my ( $self, $hash ) = @_;
|
my ($self, $hash) = @_;
|
||||||
|
|
||||||
# loop through attributes and use openapi_types to deserialize the data
|
# loop through attributes and use openapi_types to deserialize the data
|
||||||
while ( my ( $_key, $_type ) = each %{ $self->openapi_types } ) {
|
while ( my ($_key, $_type) = each %{$self->openapi_types} ) {
|
||||||
my $_json_attribute = $self->attribute_map->{$_key};
|
my $_json_attribute = $self->attribute_map->{$_key};
|
||||||
if ( $_type =~ /^array\[/i ) { # array
|
if ($_type =~ /^array\[/i) { # array
|
||||||
my $_subclass = substr( $_type, 6, -1 );
|
my $_subclass = substr($_type, 6, -1);
|
||||||
my @_array = ();
|
my @_array = ();
|
||||||
foreach my $_element ( @{ $hash->{$_json_attribute} } ) {
|
foreach my $_element (@{$hash->{$_json_attribute}}) {
|
||||||
push @_array, $self->_deserialize( $_subclass, $_element );
|
push @_array, $self->_deserialize($_subclass, $_element);
|
||||||
}
|
}
|
||||||
$self->{$_key} = \@_array;
|
$self->{$_key} = \@_array;
|
||||||
}
|
} elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
|
||||||
elsif ( exists $hash->{$_json_attribute} )
|
$self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute});
|
||||||
{ #hash(model), primitive, datetime
|
} else {
|
||||||
$self->{$_key} =
|
$log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
|
||||||
$self->_deserialize( $_type, $hash->{$_json_attribute} );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$log->debugf( "Warning: %s (%s) does not exist in input hash\n",
|
|
||||||
$_key, $_json_attribute );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
# deserialize non-array data
|
# deserialize non-array data
|
||||||
sub _deserialize {
|
sub _deserialize {
|
||||||
my ( $self, $type, $data ) = @_;
|
my ($self, $type, $data) = @_;
|
||||||
$log->debugf( "deserializing %s with %s", Dumper($data), $type );
|
$log->debugf("deserializing %s with %s",Dumper($data), $type);
|
||||||
|
|
||||||
if ( $type eq 'DateTime' ) {
|
if ($type eq 'DateTime') {
|
||||||
return DateTime->from_epoch( epoch => str2time($data) );
|
return DateTime->from_epoch(epoch => str2time($data));
|
||||||
}
|
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
|
||||||
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
} else { # hash(model)
|
||||||
else { # hash(model)
|
|
||||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||||
return $_instance->from_hash($data);
|
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__->openapi_types(
|
__PACKAGE__->class_documentation({description => '',
|
||||||
{
|
class => 'List',
|
||||||
'_123_list' => 'string'
|
required => [], # TODO
|
||||||
}
|
} );
|
||||||
);
|
|
||||||
|
|
||||||
__PACKAGE__->attribute_map(
|
__PACKAGE__->method_documentation({
|
||||||
{
|
'_123_list' => {
|
||||||
'_123_list' => '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__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
=begin comment
|
=begin comment
|
||||||
|
|
||||||
OpenAPI Petstore
|
OpenAPI Petstore
|
||||||
@@ -31,9 +30,8 @@ use Log::Any qw($log);
|
|||||||
use Date::Parse;
|
use Date::Parse;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
|
||||||
use WWW::OpenAPIClient::Object::StringBooleanMap;
|
|
||||||
|
|
||||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||||
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
@@ -61,147 +59,146 @@ Generated by: https://openapi-generator.tech
|
|||||||
# Do not edit the class manually.
|
# Do not edit the class manually.
|
||||||
# Ref: https://openapi-generator.tech
|
# Ref: https://openapi-generator.tech
|
||||||
#
|
#
|
||||||
__PACKAGE__->mk_classdata( 'attribute_map' => {} );
|
__PACKAGE__->mk_classdata('attribute_map' => {});
|
||||||
__PACKAGE__->mk_classdata( 'openapi_types' => {} );
|
__PACKAGE__->mk_classdata('openapi_types' => {});
|
||||||
__PACKAGE__->mk_classdata( 'method_documentation' => {} );
|
__PACKAGE__->mk_classdata('method_documentation' => {});
|
||||||
__PACKAGE__->mk_classdata( 'class_documentation' => {} );
|
__PACKAGE__->mk_classdata('class_documentation' => {});
|
||||||
|
|
||||||
# new object
|
# new plain object
|
||||||
sub new {
|
sub new {
|
||||||
my ( $class, %args ) = @_;
|
my ($class, %args) = @_;
|
||||||
|
|
||||||
my $self = bless {}, $class;
|
my $self = bless {}, $class;
|
||||||
|
|
||||||
foreach my $attribute ( keys %{ $class->attribute_map } ) {
|
$self->init(%args);
|
||||||
my $args_key = $class->attribute_map->{$attribute};
|
|
||||||
$self->$attribute( $args{$args_key} );
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
# initialize the object
|
||||||
|
sub init
|
||||||
|
{
|
||||||
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
|
foreach my $attribute (keys %{$self->attribute_map}) {
|
||||||
|
my $args_key = $self->attribute_map->{$attribute};
|
||||||
|
$self->$attribute( $args{ $args_key } );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# return perl hash
|
# return perl hash
|
||||||
sub to_hash {
|
sub to_hash {
|
||||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
my $self = shift;
|
||||||
|
my $_hash = decode_json(JSON->new->convert_blessed->encode($self));
|
||||||
|
|
||||||
|
return $_hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
# used by JSON for serialization
|
# used by JSON for serialization
|
||||||
sub TO_JSON {
|
sub TO_JSON {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $_data = {};
|
my $_data = {};
|
||||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
foreach my $_key (keys %{$self->attribute_map}) {
|
||||||
if ( defined $self->{$_key} ) {
|
if (defined $self->{$_key}) {
|
||||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
$_data->{$self->attribute_map->{$_key}} = $self->{$_key};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $_data;
|
return $_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
# from Perl hashref
|
# from Perl hashref
|
||||||
sub from_hash {
|
sub from_hash {
|
||||||
my ( $self, $hash ) = @_;
|
my ($self, $hash) = @_;
|
||||||
|
|
||||||
# loop through attributes and use openapi_types to deserialize the data
|
# loop through attributes and use openapi_types to deserialize the data
|
||||||
while ( my ( $_key, $_type ) = each %{ $self->openapi_types } ) {
|
while ( my ($_key, $_type) = each %{$self->openapi_types} ) {
|
||||||
my $_json_attribute = $self->attribute_map->{$_key};
|
my $_json_attribute = $self->attribute_map->{$_key};
|
||||||
if ( $_type =~ /^array\[/i ) { # array
|
if ($_type =~ /^array\[/i) { # array
|
||||||
my $_subclass = substr( $_type, 6, -1 );
|
my $_subclass = substr($_type, 6, -1);
|
||||||
my @_array = ();
|
my @_array = ();
|
||||||
foreach my $_element ( @{ $hash->{$_json_attribute} } ) {
|
foreach my $_element (@{$hash->{$_json_attribute}}) {
|
||||||
push @_array, $self->_deserialize( $_subclass, $_element );
|
push @_array, $self->_deserialize($_subclass, $_element);
|
||||||
}
|
}
|
||||||
$self->{$_key} = \@_array;
|
$self->{$_key} = \@_array;
|
||||||
}
|
} elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
|
||||||
elsif ( exists $hash->{$_json_attribute} )
|
$self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute});
|
||||||
{ #hash(model), primitive, datetime
|
} else {
|
||||||
$self->{$_key} =
|
$log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
|
||||||
$self->_deserialize( $_type, $hash->{$_json_attribute} );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$log->debugf( "Warning: %s (%s) does not exist in input hash\n",
|
|
||||||
$_key, $_json_attribute );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
# deserialize non-array data
|
# deserialize non-array data
|
||||||
sub _deserialize {
|
sub _deserialize {
|
||||||
my ( $self, $type, $data ) = @_;
|
my ($self, $type, $data) = @_;
|
||||||
$log->debugf( "deserializing %s with %s", Dumper($data), $type );
|
$log->debugf("deserializing %s with %s",Dumper($data), $type);
|
||||||
|
|
||||||
if ( $type eq 'DateTime' ) {
|
if ($type eq 'DateTime') {
|
||||||
return DateTime->from_epoch( epoch => str2time($data) );
|
return DateTime->from_epoch(epoch => str2time($data));
|
||||||
}
|
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
|
||||||
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
} else { # hash(model)
|
||||||
else { # hash(model)
|
|
||||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||||
return $_instance->from_hash($data);
|
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__->openapi_types(
|
__PACKAGE__->class_documentation({description => '',
|
||||||
{
|
class => 'MapTest',
|
||||||
'map_map_of_string' => 'HASH[string,HASH[string,string]]',
|
required => [], # TODO
|
||||||
'map_of_enum_string' => 'HASH[string,string]',
|
} );
|
||||||
'direct_map' => 'HASH[string,boolean]',
|
|
||||||
'indirect_map' => 'StringBooleanMap'
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
__PACKAGE__->attribute_map(
|
__PACKAGE__->method_documentation({
|
||||||
{
|
'map_map_of_string' => {
|
||||||
'map_map_of_string' => 'map_map_of_string',
|
datatype => 'HASH[string,HASH[string,string]]',
|
||||||
'map_of_enum_string' => 'map_of_enum_string',
|
base_name => 'map_map_of_string',
|
||||||
'direct_map' => 'direct_map',
|
description => '',
|
||||||
'indirect_map' => 'indirect_map'
|
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 => 'HASH[string,boolean]',
|
||||||
|
base_name => 'indirect_map',
|
||||||
|
description => '',
|
||||||
|
format => '',
|
||||||
|
read_only => '',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
__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' => 'HASH[string,boolean]'
|
||||||
|
} );
|
||||||
|
|
||||||
|
__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});
|
||||||
|
|
||||||
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
=begin comment
|
=begin comment
|
||||||
|
|
||||||
OpenAPI Petstore
|
OpenAPI Petstore
|
||||||
@@ -33,7 +32,7 @@ use DateTime;
|
|||||||
|
|
||||||
use WWW::OpenAPIClient::Object::Animal;
|
use WWW::OpenAPIClient::Object::Animal;
|
||||||
|
|
||||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||||
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
@@ -61,138 +60,137 @@ Generated by: https://openapi-generator.tech
|
|||||||
# Do not edit the class manually.
|
# Do not edit the class manually.
|
||||||
# Ref: https://openapi-generator.tech
|
# Ref: https://openapi-generator.tech
|
||||||
#
|
#
|
||||||
__PACKAGE__->mk_classdata( 'attribute_map' => {} );
|
__PACKAGE__->mk_classdata('attribute_map' => {});
|
||||||
__PACKAGE__->mk_classdata( 'openapi_types' => {} );
|
__PACKAGE__->mk_classdata('openapi_types' => {});
|
||||||
__PACKAGE__->mk_classdata( 'method_documentation' => {} );
|
__PACKAGE__->mk_classdata('method_documentation' => {});
|
||||||
__PACKAGE__->mk_classdata( 'class_documentation' => {} );
|
__PACKAGE__->mk_classdata('class_documentation' => {});
|
||||||
|
|
||||||
# new object
|
# new plain object
|
||||||
sub new {
|
sub new {
|
||||||
my ( $class, %args ) = @_;
|
my ($class, %args) = @_;
|
||||||
|
|
||||||
my $self = bless {}, $class;
|
my $self = bless {}, $class;
|
||||||
|
|
||||||
foreach my $attribute ( keys %{ $class->attribute_map } ) {
|
$self->init(%args);
|
||||||
my $args_key = $class->attribute_map->{$attribute};
|
|
||||||
$self->$attribute( $args{$args_key} );
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
# initialize the object
|
||||||
|
sub init
|
||||||
|
{
|
||||||
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
|
foreach my $attribute (keys %{$self->attribute_map}) {
|
||||||
|
my $args_key = $self->attribute_map->{$attribute};
|
||||||
|
$self->$attribute( $args{ $args_key } );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# return perl hash
|
# return perl hash
|
||||||
sub to_hash {
|
sub to_hash {
|
||||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
my $self = shift;
|
||||||
|
my $_hash = decode_json(JSON->new->convert_blessed->encode($self));
|
||||||
|
|
||||||
|
return $_hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
# used by JSON for serialization
|
# used by JSON for serialization
|
||||||
sub TO_JSON {
|
sub TO_JSON {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $_data = {};
|
my $_data = {};
|
||||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
foreach my $_key (keys %{$self->attribute_map}) {
|
||||||
if ( defined $self->{$_key} ) {
|
if (defined $self->{$_key}) {
|
||||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
$_data->{$self->attribute_map->{$_key}} = $self->{$_key};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $_data;
|
return $_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
# from Perl hashref
|
# from Perl hashref
|
||||||
sub from_hash {
|
sub from_hash {
|
||||||
my ( $self, $hash ) = @_;
|
my ($self, $hash) = @_;
|
||||||
|
|
||||||
# loop through attributes and use openapi_types to deserialize the data
|
# loop through attributes and use openapi_types to deserialize the data
|
||||||
while ( my ( $_key, $_type ) = each %{ $self->openapi_types } ) {
|
while ( my ($_key, $_type) = each %{$self->openapi_types} ) {
|
||||||
my $_json_attribute = $self->attribute_map->{$_key};
|
my $_json_attribute = $self->attribute_map->{$_key};
|
||||||
if ( $_type =~ /^array\[/i ) { # array
|
if ($_type =~ /^array\[/i) { # array
|
||||||
my $_subclass = substr( $_type, 6, -1 );
|
my $_subclass = substr($_type, 6, -1);
|
||||||
my @_array = ();
|
my @_array = ();
|
||||||
foreach my $_element ( @{ $hash->{$_json_attribute} } ) {
|
foreach my $_element (@{$hash->{$_json_attribute}}) {
|
||||||
push @_array, $self->_deserialize( $_subclass, $_element );
|
push @_array, $self->_deserialize($_subclass, $_element);
|
||||||
}
|
}
|
||||||
$self->{$_key} = \@_array;
|
$self->{$_key} = \@_array;
|
||||||
}
|
} elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
|
||||||
elsif ( exists $hash->{$_json_attribute} )
|
$self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute});
|
||||||
{ #hash(model), primitive, datetime
|
} else {
|
||||||
$self->{$_key} =
|
$log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
|
||||||
$self->_deserialize( $_type, $hash->{$_json_attribute} );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$log->debugf( "Warning: %s (%s) does not exist in input hash\n",
|
|
||||||
$_key, $_json_attribute );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
# deserialize non-array data
|
# deserialize non-array data
|
||||||
sub _deserialize {
|
sub _deserialize {
|
||||||
my ( $self, $type, $data ) = @_;
|
my ($self, $type, $data) = @_;
|
||||||
$log->debugf( "deserializing %s with %s", Dumper($data), $type );
|
$log->debugf("deserializing %s with %s",Dumper($data), $type);
|
||||||
|
|
||||||
if ( $type eq 'DateTime' ) {
|
if ($type eq 'DateTime') {
|
||||||
return DateTime->from_epoch( epoch => str2time($data) );
|
return DateTime->from_epoch(epoch => str2time($data));
|
||||||
}
|
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
|
||||||
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
} else { # hash(model)
|
||||||
else { # hash(model)
|
|
||||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||||
return $_instance->from_hash($data);
|
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__->openapi_types(
|
__PACKAGE__->class_documentation({description => '',
|
||||||
{
|
class => 'MixedPropertiesAndAdditionalPropertiesClass',
|
||||||
'uuid' => 'string',
|
required => [], # TODO
|
||||||
'date_time' => 'DateTime',
|
} );
|
||||||
'map' => 'HASH[string,Animal]'
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
__PACKAGE__->attribute_map(
|
__PACKAGE__->method_documentation({
|
||||||
{
|
'uuid' => {
|
||||||
'uuid' => 'uuid',
|
datatype => 'string',
|
||||||
'date_time' => 'dateTime',
|
base_name => 'uuid',
|
||||||
'map' => 'map'
|
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__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
=begin comment
|
=begin comment
|
||||||
|
|
||||||
OpenAPI Petstore
|
OpenAPI Petstore
|
||||||
@@ -31,7 +30,8 @@ use Log::Any qw($log);
|
|||||||
use Date::Parse;
|
use Date::Parse;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
|
||||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
|
||||||
|
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||||
|
|
||||||
#
|
#
|
||||||
#Model for testing model name starting with number
|
#Model for testing model name starting with number
|
||||||
@@ -59,129 +59,128 @@ Generated by: https://openapi-generator.tech
|
|||||||
# Do not edit the class manually.
|
# Do not edit the class manually.
|
||||||
# Ref: https://openapi-generator.tech
|
# Ref: https://openapi-generator.tech
|
||||||
#
|
#
|
||||||
__PACKAGE__->mk_classdata( 'attribute_map' => {} );
|
__PACKAGE__->mk_classdata('attribute_map' => {});
|
||||||
__PACKAGE__->mk_classdata( 'openapi_types' => {} );
|
__PACKAGE__->mk_classdata('openapi_types' => {});
|
||||||
__PACKAGE__->mk_classdata( 'method_documentation' => {} );
|
__PACKAGE__->mk_classdata('method_documentation' => {});
|
||||||
__PACKAGE__->mk_classdata( 'class_documentation' => {} );
|
__PACKAGE__->mk_classdata('class_documentation' => {});
|
||||||
|
|
||||||
# new object
|
# new plain object
|
||||||
sub new {
|
sub new {
|
||||||
my ( $class, %args ) = @_;
|
my ($class, %args) = @_;
|
||||||
|
|
||||||
my $self = bless {}, $class;
|
my $self = bless {}, $class;
|
||||||
|
|
||||||
foreach my $attribute ( keys %{ $class->attribute_map } ) {
|
$self->init(%args);
|
||||||
my $args_key = $class->attribute_map->{$attribute};
|
|
||||||
$self->$attribute( $args{$args_key} );
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
# initialize the object
|
||||||
|
sub init
|
||||||
|
{
|
||||||
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
|
foreach my $attribute (keys %{$self->attribute_map}) {
|
||||||
|
my $args_key = $self->attribute_map->{$attribute};
|
||||||
|
$self->$attribute( $args{ $args_key } );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# return perl hash
|
# return perl hash
|
||||||
sub to_hash {
|
sub to_hash {
|
||||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
my $self = shift;
|
||||||
|
my $_hash = decode_json(JSON->new->convert_blessed->encode($self));
|
||||||
|
|
||||||
|
return $_hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
# used by JSON for serialization
|
# used by JSON for serialization
|
||||||
sub TO_JSON {
|
sub TO_JSON {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $_data = {};
|
my $_data = {};
|
||||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
foreach my $_key (keys %{$self->attribute_map}) {
|
||||||
if ( defined $self->{$_key} ) {
|
if (defined $self->{$_key}) {
|
||||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
$_data->{$self->attribute_map->{$_key}} = $self->{$_key};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $_data;
|
return $_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
# from Perl hashref
|
# from Perl hashref
|
||||||
sub from_hash {
|
sub from_hash {
|
||||||
my ( $self, $hash ) = @_;
|
my ($self, $hash) = @_;
|
||||||
|
|
||||||
# loop through attributes and use openapi_types to deserialize the data
|
# loop through attributes and use openapi_types to deserialize the data
|
||||||
while ( my ( $_key, $_type ) = each %{ $self->openapi_types } ) {
|
while ( my ($_key, $_type) = each %{$self->openapi_types} ) {
|
||||||
my $_json_attribute = $self->attribute_map->{$_key};
|
my $_json_attribute = $self->attribute_map->{$_key};
|
||||||
if ( $_type =~ /^array\[/i ) { # array
|
if ($_type =~ /^array\[/i) { # array
|
||||||
my $_subclass = substr( $_type, 6, -1 );
|
my $_subclass = substr($_type, 6, -1);
|
||||||
my @_array = ();
|
my @_array = ();
|
||||||
foreach my $_element ( @{ $hash->{$_json_attribute} } ) {
|
foreach my $_element (@{$hash->{$_json_attribute}}) {
|
||||||
push @_array, $self->_deserialize( $_subclass, $_element );
|
push @_array, $self->_deserialize($_subclass, $_element);
|
||||||
}
|
}
|
||||||
$self->{$_key} = \@_array;
|
$self->{$_key} = \@_array;
|
||||||
}
|
} elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
|
||||||
elsif ( exists $hash->{$_json_attribute} )
|
$self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute});
|
||||||
{ #hash(model), primitive, datetime
|
} else {
|
||||||
$self->{$_key} =
|
$log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
|
||||||
$self->_deserialize( $_type, $hash->{$_json_attribute} );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$log->debugf( "Warning: %s (%s) does not exist in input hash\n",
|
|
||||||
$_key, $_json_attribute );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
# deserialize non-array data
|
# deserialize non-array data
|
||||||
sub _deserialize {
|
sub _deserialize {
|
||||||
my ( $self, $type, $data ) = @_;
|
my ($self, $type, $data) = @_;
|
||||||
$log->debugf( "deserializing %s with %s", Dumper($data), $type );
|
$log->debugf("deserializing %s with %s",Dumper($data), $type);
|
||||||
|
|
||||||
if ( $type eq 'DateTime' ) {
|
if ($type eq 'DateTime') {
|
||||||
return DateTime->from_epoch( epoch => str2time($data) );
|
return DateTime->from_epoch(epoch => str2time($data));
|
||||||
}
|
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
|
||||||
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
} else { # hash(model)
|
||||||
else { # hash(model)
|
|
||||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||||
return $_instance->from_hash($data);
|
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__->openapi_types(
|
__PACKAGE__->class_documentation({description => 'Model for testing model name starting with number',
|
||||||
{
|
class => 'Model200Response',
|
||||||
'name' => 'int',
|
required => [], # TODO
|
||||||
'class' => 'string'
|
} );
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
__PACKAGE__->attribute_map(
|
__PACKAGE__->method_documentation({
|
||||||
{
|
'name' => {
|
||||||
'name' => 'name',
|
datatype => 'int',
|
||||||
'class' => 'class'
|
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__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
=begin comment
|
=begin comment
|
||||||
|
|
||||||
OpenAPI Petstore
|
OpenAPI Petstore
|
||||||
@@ -31,7 +30,8 @@ use Log::Any qw($log);
|
|||||||
use Date::Parse;
|
use Date::Parse;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
|
||||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
|
||||||
|
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||||
|
|
||||||
#
|
#
|
||||||
#Model for testing reserved words
|
#Model for testing reserved words
|
||||||
@@ -59,120 +59,119 @@ Generated by: https://openapi-generator.tech
|
|||||||
# Do not edit the class manually.
|
# Do not edit the class manually.
|
||||||
# Ref: https://openapi-generator.tech
|
# Ref: https://openapi-generator.tech
|
||||||
#
|
#
|
||||||
__PACKAGE__->mk_classdata( 'attribute_map' => {} );
|
__PACKAGE__->mk_classdata('attribute_map' => {});
|
||||||
__PACKAGE__->mk_classdata( 'openapi_types' => {} );
|
__PACKAGE__->mk_classdata('openapi_types' => {});
|
||||||
__PACKAGE__->mk_classdata( 'method_documentation' => {} );
|
__PACKAGE__->mk_classdata('method_documentation' => {});
|
||||||
__PACKAGE__->mk_classdata( 'class_documentation' => {} );
|
__PACKAGE__->mk_classdata('class_documentation' => {});
|
||||||
|
|
||||||
# new object
|
# new plain object
|
||||||
sub new {
|
sub new {
|
||||||
my ( $class, %args ) = @_;
|
my ($class, %args) = @_;
|
||||||
|
|
||||||
my $self = bless {}, $class;
|
my $self = bless {}, $class;
|
||||||
|
|
||||||
foreach my $attribute ( keys %{ $class->attribute_map } ) {
|
$self->init(%args);
|
||||||
my $args_key = $class->attribute_map->{$attribute};
|
|
||||||
$self->$attribute( $args{$args_key} );
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
# initialize the object
|
||||||
|
sub init
|
||||||
|
{
|
||||||
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
|
foreach my $attribute (keys %{$self->attribute_map}) {
|
||||||
|
my $args_key = $self->attribute_map->{$attribute};
|
||||||
|
$self->$attribute( $args{ $args_key } );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# return perl hash
|
# return perl hash
|
||||||
sub to_hash {
|
sub to_hash {
|
||||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
my $self = shift;
|
||||||
|
my $_hash = decode_json(JSON->new->convert_blessed->encode($self));
|
||||||
|
|
||||||
|
return $_hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
# used by JSON for serialization
|
# used by JSON for serialization
|
||||||
sub TO_JSON {
|
sub TO_JSON {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $_data = {};
|
my $_data = {};
|
||||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
foreach my $_key (keys %{$self->attribute_map}) {
|
||||||
if ( defined $self->{$_key} ) {
|
if (defined $self->{$_key}) {
|
||||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
$_data->{$self->attribute_map->{$_key}} = $self->{$_key};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $_data;
|
return $_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
# from Perl hashref
|
# from Perl hashref
|
||||||
sub from_hash {
|
sub from_hash {
|
||||||
my ( $self, $hash ) = @_;
|
my ($self, $hash) = @_;
|
||||||
|
|
||||||
# loop through attributes and use openapi_types to deserialize the data
|
# loop through attributes and use openapi_types to deserialize the data
|
||||||
while ( my ( $_key, $_type ) = each %{ $self->openapi_types } ) {
|
while ( my ($_key, $_type) = each %{$self->openapi_types} ) {
|
||||||
my $_json_attribute = $self->attribute_map->{$_key};
|
my $_json_attribute = $self->attribute_map->{$_key};
|
||||||
if ( $_type =~ /^array\[/i ) { # array
|
if ($_type =~ /^array\[/i) { # array
|
||||||
my $_subclass = substr( $_type, 6, -1 );
|
my $_subclass = substr($_type, 6, -1);
|
||||||
my @_array = ();
|
my @_array = ();
|
||||||
foreach my $_element ( @{ $hash->{$_json_attribute} } ) {
|
foreach my $_element (@{$hash->{$_json_attribute}}) {
|
||||||
push @_array, $self->_deserialize( $_subclass, $_element );
|
push @_array, $self->_deserialize($_subclass, $_element);
|
||||||
}
|
}
|
||||||
$self->{$_key} = \@_array;
|
$self->{$_key} = \@_array;
|
||||||
}
|
} elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
|
||||||
elsif ( exists $hash->{$_json_attribute} )
|
$self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute});
|
||||||
{ #hash(model), primitive, datetime
|
} else {
|
||||||
$self->{$_key} =
|
$log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
|
||||||
$self->_deserialize( $_type, $hash->{$_json_attribute} );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$log->debugf( "Warning: %s (%s) does not exist in input hash\n",
|
|
||||||
$_key, $_json_attribute );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
# deserialize non-array data
|
# deserialize non-array data
|
||||||
sub _deserialize {
|
sub _deserialize {
|
||||||
my ( $self, $type, $data ) = @_;
|
my ($self, $type, $data) = @_;
|
||||||
$log->debugf( "deserializing %s with %s", Dumper($data), $type );
|
$log->debugf("deserializing %s with %s",Dumper($data), $type);
|
||||||
|
|
||||||
if ( $type eq 'DateTime' ) {
|
if ($type eq 'DateTime') {
|
||||||
return DateTime->from_epoch( epoch => str2time($data) );
|
return DateTime->from_epoch(epoch => str2time($data));
|
||||||
}
|
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
|
||||||
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
} else { # hash(model)
|
||||||
else { # hash(model)
|
|
||||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||||
return $_instance->from_hash($data);
|
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__->openapi_types(
|
__PACKAGE__->class_documentation({description => 'Model for testing reserved words',
|
||||||
{
|
class => 'ModelReturn',
|
||||||
'return' => 'int'
|
required => [], # TODO
|
||||||
}
|
} );
|
||||||
);
|
|
||||||
|
|
||||||
__PACKAGE__->attribute_map(
|
__PACKAGE__->method_documentation({
|
||||||
{
|
'return' => {
|
||||||
'return' => '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__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
=begin comment
|
=begin comment
|
||||||
|
|
||||||
OpenAPI Petstore
|
OpenAPI Petstore
|
||||||
@@ -31,7 +30,8 @@ use Log::Any qw($log);
|
|||||||
use Date::Parse;
|
use Date::Parse;
|
||||||
use DateTime;
|
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
|
#Model for testing model name same as property name
|
||||||
@@ -59,147 +59,146 @@ Generated by: https://openapi-generator.tech
|
|||||||
# Do not edit the class manually.
|
# Do not edit the class manually.
|
||||||
# Ref: https://openapi-generator.tech
|
# Ref: https://openapi-generator.tech
|
||||||
#
|
#
|
||||||
__PACKAGE__->mk_classdata( 'attribute_map' => {} );
|
__PACKAGE__->mk_classdata('attribute_map' => {});
|
||||||
__PACKAGE__->mk_classdata( 'openapi_types' => {} );
|
__PACKAGE__->mk_classdata('openapi_types' => {});
|
||||||
__PACKAGE__->mk_classdata( 'method_documentation' => {} );
|
__PACKAGE__->mk_classdata('method_documentation' => {});
|
||||||
__PACKAGE__->mk_classdata( 'class_documentation' => {} );
|
__PACKAGE__->mk_classdata('class_documentation' => {});
|
||||||
|
|
||||||
# new object
|
# new plain object
|
||||||
sub new {
|
sub new {
|
||||||
my ( $class, %args ) = @_;
|
my ($class, %args) = @_;
|
||||||
|
|
||||||
my $self = bless {}, $class;
|
my $self = bless {}, $class;
|
||||||
|
|
||||||
foreach my $attribute ( keys %{ $class->attribute_map } ) {
|
$self->init(%args);
|
||||||
my $args_key = $class->attribute_map->{$attribute};
|
|
||||||
$self->$attribute( $args{$args_key} );
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
# initialize the object
|
||||||
|
sub init
|
||||||
|
{
|
||||||
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
|
foreach my $attribute (keys %{$self->attribute_map}) {
|
||||||
|
my $args_key = $self->attribute_map->{$attribute};
|
||||||
|
$self->$attribute( $args{ $args_key } );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# return perl hash
|
# return perl hash
|
||||||
sub to_hash {
|
sub to_hash {
|
||||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
my $self = shift;
|
||||||
|
my $_hash = decode_json(JSON->new->convert_blessed->encode($self));
|
||||||
|
|
||||||
|
return $_hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
# used by JSON for serialization
|
# used by JSON for serialization
|
||||||
sub TO_JSON {
|
sub TO_JSON {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $_data = {};
|
my $_data = {};
|
||||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
foreach my $_key (keys %{$self->attribute_map}) {
|
||||||
if ( defined $self->{$_key} ) {
|
if (defined $self->{$_key}) {
|
||||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
$_data->{$self->attribute_map->{$_key}} = $self->{$_key};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $_data;
|
return $_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
# from Perl hashref
|
# from Perl hashref
|
||||||
sub from_hash {
|
sub from_hash {
|
||||||
my ( $self, $hash ) = @_;
|
my ($self, $hash) = @_;
|
||||||
|
|
||||||
# loop through attributes and use openapi_types to deserialize the data
|
# loop through attributes and use openapi_types to deserialize the data
|
||||||
while ( my ( $_key, $_type ) = each %{ $self->openapi_types } ) {
|
while ( my ($_key, $_type) = each %{$self->openapi_types} ) {
|
||||||
my $_json_attribute = $self->attribute_map->{$_key};
|
my $_json_attribute = $self->attribute_map->{$_key};
|
||||||
if ( $_type =~ /^array\[/i ) { # array
|
if ($_type =~ /^array\[/i) { # array
|
||||||
my $_subclass = substr( $_type, 6, -1 );
|
my $_subclass = substr($_type, 6, -1);
|
||||||
my @_array = ();
|
my @_array = ();
|
||||||
foreach my $_element ( @{ $hash->{$_json_attribute} } ) {
|
foreach my $_element (@{$hash->{$_json_attribute}}) {
|
||||||
push @_array, $self->_deserialize( $_subclass, $_element );
|
push @_array, $self->_deserialize($_subclass, $_element);
|
||||||
}
|
}
|
||||||
$self->{$_key} = \@_array;
|
$self->{$_key} = \@_array;
|
||||||
}
|
} elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
|
||||||
elsif ( exists $hash->{$_json_attribute} )
|
$self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute});
|
||||||
{ #hash(model), primitive, datetime
|
} else {
|
||||||
$self->{$_key} =
|
$log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
|
||||||
$self->_deserialize( $_type, $hash->{$_json_attribute} );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$log->debugf( "Warning: %s (%s) does not exist in input hash\n",
|
|
||||||
$_key, $_json_attribute );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
# deserialize non-array data
|
# deserialize non-array data
|
||||||
sub _deserialize {
|
sub _deserialize {
|
||||||
my ( $self, $type, $data ) = @_;
|
my ($self, $type, $data) = @_;
|
||||||
$log->debugf( "deserializing %s with %s", Dumper($data), $type );
|
$log->debugf("deserializing %s with %s",Dumper($data), $type);
|
||||||
|
|
||||||
if ( $type eq 'DateTime' ) {
|
if ($type eq 'DateTime') {
|
||||||
return DateTime->from_epoch( epoch => str2time($data) );
|
return DateTime->from_epoch(epoch => str2time($data));
|
||||||
}
|
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
|
||||||
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
} else { # hash(model)
|
||||||
else { # hash(model)
|
|
||||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||||
return $_instance->from_hash($data);
|
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__->openapi_types(
|
__PACKAGE__->class_documentation({description => 'Model for testing model name same as property name',
|
||||||
{
|
class => 'Name',
|
||||||
'name' => 'int',
|
required => [], # TODO
|
||||||
'snake_case' => 'int',
|
} );
|
||||||
'property' => 'string',
|
|
||||||
'_123_number' => 'int'
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
__PACKAGE__->attribute_map(
|
__PACKAGE__->method_documentation({
|
||||||
{
|
'name' => {
|
||||||
'name' => 'name',
|
datatype => 'int',
|
||||||
'snake_case' => 'snake_case',
|
base_name => 'name',
|
||||||
'property' => 'property',
|
description => '',
|
||||||
'_123_number' => '123Number'
|
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__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
=begin comment
|
=begin comment
|
||||||
|
|
||||||
OpenAPI Petstore
|
OpenAPI Petstore
|
||||||
@@ -31,7 +30,8 @@ use Log::Any qw($log);
|
|||||||
use Date::Parse;
|
use Date::Parse;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
|
||||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
|
||||||
|
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||||
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
@@ -59,120 +59,119 @@ Generated by: https://openapi-generator.tech
|
|||||||
# Do not edit the class manually.
|
# Do not edit the class manually.
|
||||||
# Ref: https://openapi-generator.tech
|
# Ref: https://openapi-generator.tech
|
||||||
#
|
#
|
||||||
__PACKAGE__->mk_classdata( 'attribute_map' => {} );
|
__PACKAGE__->mk_classdata('attribute_map' => {});
|
||||||
__PACKAGE__->mk_classdata( 'openapi_types' => {} );
|
__PACKAGE__->mk_classdata('openapi_types' => {});
|
||||||
__PACKAGE__->mk_classdata( 'method_documentation' => {} );
|
__PACKAGE__->mk_classdata('method_documentation' => {});
|
||||||
__PACKAGE__->mk_classdata( 'class_documentation' => {} );
|
__PACKAGE__->mk_classdata('class_documentation' => {});
|
||||||
|
|
||||||
# new object
|
# new plain object
|
||||||
sub new {
|
sub new {
|
||||||
my ( $class, %args ) = @_;
|
my ($class, %args) = @_;
|
||||||
|
|
||||||
my $self = bless {}, $class;
|
my $self = bless {}, $class;
|
||||||
|
|
||||||
foreach my $attribute ( keys %{ $class->attribute_map } ) {
|
$self->init(%args);
|
||||||
my $args_key = $class->attribute_map->{$attribute};
|
|
||||||
$self->$attribute( $args{$args_key} );
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
# initialize the object
|
||||||
|
sub init
|
||||||
|
{
|
||||||
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
|
foreach my $attribute (keys %{$self->attribute_map}) {
|
||||||
|
my $args_key = $self->attribute_map->{$attribute};
|
||||||
|
$self->$attribute( $args{ $args_key } );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# return perl hash
|
# return perl hash
|
||||||
sub to_hash {
|
sub to_hash {
|
||||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
my $self = shift;
|
||||||
|
my $_hash = decode_json(JSON->new->convert_blessed->encode($self));
|
||||||
|
|
||||||
|
return $_hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
# used by JSON for serialization
|
# used by JSON for serialization
|
||||||
sub TO_JSON {
|
sub TO_JSON {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $_data = {};
|
my $_data = {};
|
||||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
foreach my $_key (keys %{$self->attribute_map}) {
|
||||||
if ( defined $self->{$_key} ) {
|
if (defined $self->{$_key}) {
|
||||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
$_data->{$self->attribute_map->{$_key}} = $self->{$_key};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $_data;
|
return $_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
# from Perl hashref
|
# from Perl hashref
|
||||||
sub from_hash {
|
sub from_hash {
|
||||||
my ( $self, $hash ) = @_;
|
my ($self, $hash) = @_;
|
||||||
|
|
||||||
# loop through attributes and use openapi_types to deserialize the data
|
# loop through attributes and use openapi_types to deserialize the data
|
||||||
while ( my ( $_key, $_type ) = each %{ $self->openapi_types } ) {
|
while ( my ($_key, $_type) = each %{$self->openapi_types} ) {
|
||||||
my $_json_attribute = $self->attribute_map->{$_key};
|
my $_json_attribute = $self->attribute_map->{$_key};
|
||||||
if ( $_type =~ /^array\[/i ) { # array
|
if ($_type =~ /^array\[/i) { # array
|
||||||
my $_subclass = substr( $_type, 6, -1 );
|
my $_subclass = substr($_type, 6, -1);
|
||||||
my @_array = ();
|
my @_array = ();
|
||||||
foreach my $_element ( @{ $hash->{$_json_attribute} } ) {
|
foreach my $_element (@{$hash->{$_json_attribute}}) {
|
||||||
push @_array, $self->_deserialize( $_subclass, $_element );
|
push @_array, $self->_deserialize($_subclass, $_element);
|
||||||
}
|
}
|
||||||
$self->{$_key} = \@_array;
|
$self->{$_key} = \@_array;
|
||||||
}
|
} elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
|
||||||
elsif ( exists $hash->{$_json_attribute} )
|
$self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute});
|
||||||
{ #hash(model), primitive, datetime
|
} else {
|
||||||
$self->{$_key} =
|
$log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
|
||||||
$self->_deserialize( $_type, $hash->{$_json_attribute} );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$log->debugf( "Warning: %s (%s) does not exist in input hash\n",
|
|
||||||
$_key, $_json_attribute );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
# deserialize non-array data
|
# deserialize non-array data
|
||||||
sub _deserialize {
|
sub _deserialize {
|
||||||
my ( $self, $type, $data ) = @_;
|
my ($self, $type, $data) = @_;
|
||||||
$log->debugf( "deserializing %s with %s", Dumper($data), $type );
|
$log->debugf("deserializing %s with %s",Dumper($data), $type);
|
||||||
|
|
||||||
if ( $type eq 'DateTime' ) {
|
if ($type eq 'DateTime') {
|
||||||
return DateTime->from_epoch( epoch => str2time($data) );
|
return DateTime->from_epoch(epoch => str2time($data));
|
||||||
}
|
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
|
||||||
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
} else { # hash(model)
|
||||||
else { # hash(model)
|
|
||||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||||
return $_instance->from_hash($data);
|
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__->openapi_types(
|
__PACKAGE__->class_documentation({description => '',
|
||||||
{
|
class => 'NumberOnly',
|
||||||
'just_number' => 'double'
|
required => [], # TODO
|
||||||
}
|
} );
|
||||||
);
|
|
||||||
|
|
||||||
__PACKAGE__->attribute_map(
|
__PACKAGE__->method_documentation({
|
||||||
{
|
'just_number' => {
|
||||||
'just_number' => 'JustNumber'
|
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__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
=begin comment
|
=begin comment
|
||||||
|
|
||||||
OpenAPI Petstore
|
OpenAPI Petstore
|
||||||
@@ -31,7 +30,8 @@ use Log::Any qw($log);
|
|||||||
use Date::Parse;
|
use Date::Parse;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
|
||||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
|
||||||
|
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||||
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
@@ -59,165 +59,164 @@ Generated by: https://openapi-generator.tech
|
|||||||
# Do not edit the class manually.
|
# Do not edit the class manually.
|
||||||
# Ref: https://openapi-generator.tech
|
# Ref: https://openapi-generator.tech
|
||||||
#
|
#
|
||||||
__PACKAGE__->mk_classdata( 'attribute_map' => {} );
|
__PACKAGE__->mk_classdata('attribute_map' => {});
|
||||||
__PACKAGE__->mk_classdata( 'openapi_types' => {} );
|
__PACKAGE__->mk_classdata('openapi_types' => {});
|
||||||
__PACKAGE__->mk_classdata( 'method_documentation' => {} );
|
__PACKAGE__->mk_classdata('method_documentation' => {});
|
||||||
__PACKAGE__->mk_classdata( 'class_documentation' => {} );
|
__PACKAGE__->mk_classdata('class_documentation' => {});
|
||||||
|
|
||||||
# new object
|
# new plain object
|
||||||
sub new {
|
sub new {
|
||||||
my ( $class, %args ) = @_;
|
my ($class, %args) = @_;
|
||||||
|
|
||||||
my $self = bless {}, $class;
|
my $self = bless {}, $class;
|
||||||
|
|
||||||
foreach my $attribute ( keys %{ $class->attribute_map } ) {
|
$self->init(%args);
|
||||||
my $args_key = $class->attribute_map->{$attribute};
|
|
||||||
$self->$attribute( $args{$args_key} );
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
# initialize the object
|
||||||
|
sub init
|
||||||
|
{
|
||||||
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
|
foreach my $attribute (keys %{$self->attribute_map}) {
|
||||||
|
my $args_key = $self->attribute_map->{$attribute};
|
||||||
|
$self->$attribute( $args{ $args_key } );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# return perl hash
|
# return perl hash
|
||||||
sub to_hash {
|
sub to_hash {
|
||||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
my $self = shift;
|
||||||
|
my $_hash = decode_json(JSON->new->convert_blessed->encode($self));
|
||||||
|
|
||||||
|
return $_hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
# used by JSON for serialization
|
# used by JSON for serialization
|
||||||
sub TO_JSON {
|
sub TO_JSON {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $_data = {};
|
my $_data = {};
|
||||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
foreach my $_key (keys %{$self->attribute_map}) {
|
||||||
if ( defined $self->{$_key} ) {
|
if (defined $self->{$_key}) {
|
||||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
$_data->{$self->attribute_map->{$_key}} = $self->{$_key};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $_data;
|
return $_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
# from Perl hashref
|
# from Perl hashref
|
||||||
sub from_hash {
|
sub from_hash {
|
||||||
my ( $self, $hash ) = @_;
|
my ($self, $hash) = @_;
|
||||||
|
|
||||||
# loop through attributes and use openapi_types to deserialize the data
|
# loop through attributes and use openapi_types to deserialize the data
|
||||||
while ( my ( $_key, $_type ) = each %{ $self->openapi_types } ) {
|
while ( my ($_key, $_type) = each %{$self->openapi_types} ) {
|
||||||
my $_json_attribute = $self->attribute_map->{$_key};
|
my $_json_attribute = $self->attribute_map->{$_key};
|
||||||
if ( $_type =~ /^array\[/i ) { # array
|
if ($_type =~ /^array\[/i) { # array
|
||||||
my $_subclass = substr( $_type, 6, -1 );
|
my $_subclass = substr($_type, 6, -1);
|
||||||
my @_array = ();
|
my @_array = ();
|
||||||
foreach my $_element ( @{ $hash->{$_json_attribute} } ) {
|
foreach my $_element (@{$hash->{$_json_attribute}}) {
|
||||||
push @_array, $self->_deserialize( $_subclass, $_element );
|
push @_array, $self->_deserialize($_subclass, $_element);
|
||||||
}
|
}
|
||||||
$self->{$_key} = \@_array;
|
$self->{$_key} = \@_array;
|
||||||
}
|
} elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
|
||||||
elsif ( exists $hash->{$_json_attribute} )
|
$self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute});
|
||||||
{ #hash(model), primitive, datetime
|
} else {
|
||||||
$self->{$_key} =
|
$log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
|
||||||
$self->_deserialize( $_type, $hash->{$_json_attribute} );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$log->debugf( "Warning: %s (%s) does not exist in input hash\n",
|
|
||||||
$_key, $_json_attribute );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
# deserialize non-array data
|
# deserialize non-array data
|
||||||
sub _deserialize {
|
sub _deserialize {
|
||||||
my ( $self, $type, $data ) = @_;
|
my ($self, $type, $data) = @_;
|
||||||
$log->debugf( "deserializing %s with %s", Dumper($data), $type );
|
$log->debugf("deserializing %s with %s",Dumper($data), $type);
|
||||||
|
|
||||||
if ( $type eq 'DateTime' ) {
|
if ($type eq 'DateTime') {
|
||||||
return DateTime->from_epoch( epoch => str2time($data) );
|
return DateTime->from_epoch(epoch => str2time($data));
|
||||||
}
|
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
|
||||||
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
} else { # hash(model)
|
||||||
else { # hash(model)
|
|
||||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||||
return $_instance->from_hash($data);
|
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__->openapi_types(
|
__PACKAGE__->class_documentation({description => '',
|
||||||
{
|
class => 'Order',
|
||||||
'id' => 'int',
|
required => [], # TODO
|
||||||
'pet_id' => 'int',
|
} );
|
||||||
'quantity' => 'int',
|
|
||||||
'ship_date' => 'DateTime',
|
|
||||||
'status' => 'string',
|
|
||||||
'complete' => 'boolean'
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
__PACKAGE__->attribute_map(
|
__PACKAGE__->method_documentation({
|
||||||
{
|
'id' => {
|
||||||
'id' => 'id',
|
datatype => 'int',
|
||||||
'pet_id' => 'petId',
|
base_name => 'id',
|
||||||
'quantity' => 'quantity',
|
description => '',
|
||||||
'ship_date' => 'shipDate',
|
format => '',
|
||||||
'status' => 'status',
|
read_only => '',
|
||||||
'complete' => 'complete'
|
},
|
||||||
}
|
'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__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
=begin comment
|
=begin comment
|
||||||
|
|
||||||
OpenAPI Petstore
|
OpenAPI Petstore
|
||||||
@@ -31,7 +30,8 @@ use Log::Any qw($log);
|
|||||||
use Date::Parse;
|
use Date::Parse;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
|
||||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
|
||||||
|
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||||
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
@@ -59,138 +59,137 @@ Generated by: https://openapi-generator.tech
|
|||||||
# Do not edit the class manually.
|
# Do not edit the class manually.
|
||||||
# Ref: https://openapi-generator.tech
|
# Ref: https://openapi-generator.tech
|
||||||
#
|
#
|
||||||
__PACKAGE__->mk_classdata( 'attribute_map' => {} );
|
__PACKAGE__->mk_classdata('attribute_map' => {});
|
||||||
__PACKAGE__->mk_classdata( 'openapi_types' => {} );
|
__PACKAGE__->mk_classdata('openapi_types' => {});
|
||||||
__PACKAGE__->mk_classdata( 'method_documentation' => {} );
|
__PACKAGE__->mk_classdata('method_documentation' => {});
|
||||||
__PACKAGE__->mk_classdata( 'class_documentation' => {} );
|
__PACKAGE__->mk_classdata('class_documentation' => {});
|
||||||
|
|
||||||
# new object
|
# new plain object
|
||||||
sub new {
|
sub new {
|
||||||
my ( $class, %args ) = @_;
|
my ($class, %args) = @_;
|
||||||
|
|
||||||
my $self = bless {}, $class;
|
my $self = bless {}, $class;
|
||||||
|
|
||||||
foreach my $attribute ( keys %{ $class->attribute_map } ) {
|
$self->init(%args);
|
||||||
my $args_key = $class->attribute_map->{$attribute};
|
|
||||||
$self->$attribute( $args{$args_key} );
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
# initialize the object
|
||||||
|
sub init
|
||||||
|
{
|
||||||
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
|
foreach my $attribute (keys %{$self->attribute_map}) {
|
||||||
|
my $args_key = $self->attribute_map->{$attribute};
|
||||||
|
$self->$attribute( $args{ $args_key } );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# return perl hash
|
# return perl hash
|
||||||
sub to_hash {
|
sub to_hash {
|
||||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
my $self = shift;
|
||||||
|
my $_hash = decode_json(JSON->new->convert_blessed->encode($self));
|
||||||
|
|
||||||
|
return $_hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
# used by JSON for serialization
|
# used by JSON for serialization
|
||||||
sub TO_JSON {
|
sub TO_JSON {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $_data = {};
|
my $_data = {};
|
||||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
foreach my $_key (keys %{$self->attribute_map}) {
|
||||||
if ( defined $self->{$_key} ) {
|
if (defined $self->{$_key}) {
|
||||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
$_data->{$self->attribute_map->{$_key}} = $self->{$_key};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $_data;
|
return $_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
# from Perl hashref
|
# from Perl hashref
|
||||||
sub from_hash {
|
sub from_hash {
|
||||||
my ( $self, $hash ) = @_;
|
my ($self, $hash) = @_;
|
||||||
|
|
||||||
# loop through attributes and use openapi_types to deserialize the data
|
# loop through attributes and use openapi_types to deserialize the data
|
||||||
while ( my ( $_key, $_type ) = each %{ $self->openapi_types } ) {
|
while ( my ($_key, $_type) = each %{$self->openapi_types} ) {
|
||||||
my $_json_attribute = $self->attribute_map->{$_key};
|
my $_json_attribute = $self->attribute_map->{$_key};
|
||||||
if ( $_type =~ /^array\[/i ) { # array
|
if ($_type =~ /^array\[/i) { # array
|
||||||
my $_subclass = substr( $_type, 6, -1 );
|
my $_subclass = substr($_type, 6, -1);
|
||||||
my @_array = ();
|
my @_array = ();
|
||||||
foreach my $_element ( @{ $hash->{$_json_attribute} } ) {
|
foreach my $_element (@{$hash->{$_json_attribute}}) {
|
||||||
push @_array, $self->_deserialize( $_subclass, $_element );
|
push @_array, $self->_deserialize($_subclass, $_element);
|
||||||
}
|
}
|
||||||
$self->{$_key} = \@_array;
|
$self->{$_key} = \@_array;
|
||||||
}
|
} elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
|
||||||
elsif ( exists $hash->{$_json_attribute} )
|
$self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute});
|
||||||
{ #hash(model), primitive, datetime
|
} else {
|
||||||
$self->{$_key} =
|
$log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
|
||||||
$self->_deserialize( $_type, $hash->{$_json_attribute} );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$log->debugf( "Warning: %s (%s) does not exist in input hash\n",
|
|
||||||
$_key, $_json_attribute );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
# deserialize non-array data
|
# deserialize non-array data
|
||||||
sub _deserialize {
|
sub _deserialize {
|
||||||
my ( $self, $type, $data ) = @_;
|
my ($self, $type, $data) = @_;
|
||||||
$log->debugf( "deserializing %s with %s", Dumper($data), $type );
|
$log->debugf("deserializing %s with %s",Dumper($data), $type);
|
||||||
|
|
||||||
if ( $type eq 'DateTime' ) {
|
if ($type eq 'DateTime') {
|
||||||
return DateTime->from_epoch( epoch => str2time($data) );
|
return DateTime->from_epoch(epoch => str2time($data));
|
||||||
}
|
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
|
||||||
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
} else { # hash(model)
|
||||||
else { # hash(model)
|
|
||||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||||
return $_instance->from_hash($data);
|
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__->openapi_types(
|
__PACKAGE__->class_documentation({description => '',
|
||||||
{
|
class => 'OuterComposite',
|
||||||
'my_number' => 'double',
|
required => [], # TODO
|
||||||
'my_string' => 'string',
|
} );
|
||||||
'my_boolean' => 'boolean'
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
__PACKAGE__->attribute_map(
|
__PACKAGE__->method_documentation({
|
||||||
{
|
'my_number' => {
|
||||||
'my_number' => 'my_number',
|
datatype => 'double',
|
||||||
'my_string' => 'my_string',
|
base_name => 'my_number',
|
||||||
'my_boolean' => 'my_boolean'
|
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__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
=begin comment
|
=begin comment
|
||||||
|
|
||||||
OpenAPI Petstore
|
OpenAPI Petstore
|
||||||
@@ -31,7 +30,8 @@ use Log::Any qw($log);
|
|||||||
use Date::Parse;
|
use Date::Parse;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
|
||||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
|
||||||
|
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||||
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
@@ -59,110 +59,112 @@ Generated by: https://openapi-generator.tech
|
|||||||
# Do not edit the class manually.
|
# Do not edit the class manually.
|
||||||
# Ref: https://openapi-generator.tech
|
# Ref: https://openapi-generator.tech
|
||||||
#
|
#
|
||||||
__PACKAGE__->mk_classdata( 'attribute_map' => {} );
|
__PACKAGE__->mk_classdata('attribute_map' => {});
|
||||||
__PACKAGE__->mk_classdata( 'openapi_types' => {} );
|
__PACKAGE__->mk_classdata('openapi_types' => {});
|
||||||
__PACKAGE__->mk_classdata( 'method_documentation' => {} );
|
__PACKAGE__->mk_classdata('method_documentation' => {});
|
||||||
__PACKAGE__->mk_classdata( 'class_documentation' => {} );
|
__PACKAGE__->mk_classdata('class_documentation' => {});
|
||||||
|
|
||||||
# new object
|
# new plain object
|
||||||
sub new {
|
sub new {
|
||||||
my ( $class, %args ) = @_;
|
my ($class, %args) = @_;
|
||||||
|
|
||||||
my $self = bless {}, $class;
|
my $self = bless {}, $class;
|
||||||
|
|
||||||
foreach my $attribute ( keys %{ $class->attribute_map } ) {
|
$self->init(%args);
|
||||||
my $args_key = $class->attribute_map->{$attribute};
|
|
||||||
$self->$attribute( $args{$args_key} );
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
# initialize the object
|
||||||
|
sub init
|
||||||
|
{
|
||||||
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
|
foreach my $attribute (keys %{$self->attribute_map}) {
|
||||||
|
my $args_key = $self->attribute_map->{$attribute};
|
||||||
|
$self->$attribute( $args{ $args_key } );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# return perl hash
|
# return perl hash
|
||||||
sub to_hash {
|
sub to_hash {
|
||||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
my $self = shift;
|
||||||
|
my $_hash = decode_json(JSON->new->convert_blessed->encode($self));
|
||||||
|
|
||||||
|
return $_hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
# used by JSON for serialization
|
# used by JSON for serialization
|
||||||
sub TO_JSON {
|
sub TO_JSON {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $_data = {};
|
my $_data = {};
|
||||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
foreach my $_key (keys %{$self->attribute_map}) {
|
||||||
if ( defined $self->{$_key} ) {
|
if (defined $self->{$_key}) {
|
||||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
$_data->{$self->attribute_map->{$_key}} = $self->{$_key};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $_data;
|
return $_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
# from Perl hashref
|
# from Perl hashref
|
||||||
sub from_hash {
|
sub from_hash {
|
||||||
my ( $self, $hash ) = @_;
|
my ($self, $hash) = @_;
|
||||||
|
|
||||||
# loop through attributes and use openapi_types to deserialize the data
|
# loop through attributes and use openapi_types to deserialize the data
|
||||||
while ( my ( $_key, $_type ) = each %{ $self->openapi_types } ) {
|
while ( my ($_key, $_type) = each %{$self->openapi_types} ) {
|
||||||
my $_json_attribute = $self->attribute_map->{$_key};
|
my $_json_attribute = $self->attribute_map->{$_key};
|
||||||
if ( $_type =~ /^array\[/i ) { # array
|
if ($_type =~ /^array\[/i) { # array
|
||||||
my $_subclass = substr( $_type, 6, -1 );
|
my $_subclass = substr($_type, 6, -1);
|
||||||
my @_array = ();
|
my @_array = ();
|
||||||
foreach my $_element ( @{ $hash->{$_json_attribute} } ) {
|
foreach my $_element (@{$hash->{$_json_attribute}}) {
|
||||||
push @_array, $self->_deserialize( $_subclass, $_element );
|
push @_array, $self->_deserialize($_subclass, $_element);
|
||||||
}
|
}
|
||||||
$self->{$_key} = \@_array;
|
$self->{$_key} = \@_array;
|
||||||
}
|
} elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
|
||||||
elsif ( exists $hash->{$_json_attribute} )
|
$self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute});
|
||||||
{ #hash(model), primitive, datetime
|
} else {
|
||||||
$self->{$_key} =
|
$log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
|
||||||
$self->_deserialize( $_type, $hash->{$_json_attribute} );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$log->debugf( "Warning: %s (%s) does not exist in input hash\n",
|
|
||||||
$_key, $_json_attribute );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
# deserialize non-array data
|
# deserialize non-array data
|
||||||
sub _deserialize {
|
sub _deserialize {
|
||||||
my ( $self, $type, $data ) = @_;
|
my ($self, $type, $data) = @_;
|
||||||
$log->debugf( "deserializing %s with %s", Dumper($data), $type );
|
$log->debugf("deserializing %s with %s",Dumper($data), $type);
|
||||||
|
|
||||||
if ( $type eq 'DateTime' ) {
|
if ($type eq 'DateTime') {
|
||||||
return DateTime->from_epoch( epoch => str2time($data) );
|
return DateTime->from_epoch(epoch => str2time($data));
|
||||||
}
|
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
|
||||||
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
} else { # hash(model)
|
||||||
else { # hash(model)
|
|
||||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||||
return $_instance->from_hash($data);
|
return $_instance->from_hash($data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
__PACKAGE__->class_documentation(
|
|
||||||
{
|
|
||||||
description => '',
|
|
||||||
class => 'OuterEnum',
|
|
||||||
required => [], # TODO
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
__PACKAGE__->method_documentation( {} );
|
|
||||||
|
|
||||||
__PACKAGE__->openapi_types(
|
__PACKAGE__->class_documentation({description => '',
|
||||||
{
|
class => 'OuterEnum',
|
||||||
|
required => [], # TODO
|
||||||
|
} );
|
||||||
|
|
||||||
}
|
__PACKAGE__->method_documentation({
|
||||||
);
|
});
|
||||||
|
|
||||||
__PACKAGE__->attribute_map(
|
__PACKAGE__->openapi_types( {
|
||||||
{
|
|
||||||
|
} );
|
||||||
|
|
||||||
}
|
__PACKAGE__->attribute_map( {
|
||||||
);
|
|
||||||
|
} );
|
||||||
|
|
||||||
|
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
||||||
|
|
||||||
__PACKAGE__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|||||||
@@ -0,0 +1,222 @@
|
|||||||
|
=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::Person;
|
||||||
|
|
||||||
|
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 plain object
|
||||||
|
sub new {
|
||||||
|
my ($class, %args) = @_;
|
||||||
|
|
||||||
|
my $self = bless {}, $class;
|
||||||
|
|
||||||
|
$self->init(%args);
|
||||||
|
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
# initialize the object
|
||||||
|
sub init
|
||||||
|
{
|
||||||
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
|
foreach my $attribute (keys %{$self->attribute_map}) {
|
||||||
|
my $args_key = $self->attribute_map->{$attribute};
|
||||||
|
$self->$attribute( $args{ $args_key } );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# return perl hash
|
||||||
|
sub to_hash {
|
||||||
|
my $self = shift;
|
||||||
|
my $_hash = decode_json(JSON->new->convert_blessed->encode($self));
|
||||||
|
|
||||||
|
return $_hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
# 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 => 'Person',
|
||||||
|
required => [], # TODO
|
||||||
|
} );
|
||||||
|
|
||||||
|
__PACKAGE__->method_documentation({
|
||||||
|
'___type' => {
|
||||||
|
datatype => 'string',
|
||||||
|
base_name => '$_type',
|
||||||
|
description => '',
|
||||||
|
format => '',
|
||||||
|
read_only => '',
|
||||||
|
},
|
||||||
|
'last_name' => {
|
||||||
|
datatype => 'string',
|
||||||
|
base_name => 'lastName',
|
||||||
|
description => '',
|
||||||
|
format => '',
|
||||||
|
read_only => '',
|
||||||
|
},
|
||||||
|
'first_name' => {
|
||||||
|
datatype => 'string',
|
||||||
|
base_name => 'firstName',
|
||||||
|
description => '',
|
||||||
|
format => '',
|
||||||
|
read_only => '',
|
||||||
|
},
|
||||||
|
'duplicated_optional' => {
|
||||||
|
datatype => 'string',
|
||||||
|
base_name => 'duplicated_optional',
|
||||||
|
description => '',
|
||||||
|
format => '',
|
||||||
|
read_only => '',
|
||||||
|
},
|
||||||
|
'duplicated_required' => {
|
||||||
|
datatype => 'string',
|
||||||
|
base_name => 'duplicated_required',
|
||||||
|
description => '',
|
||||||
|
format => '',
|
||||||
|
read_only => '',
|
||||||
|
},
|
||||||
|
'person_required' => {
|
||||||
|
datatype => 'DateTime',
|
||||||
|
base_name => 'person_required',
|
||||||
|
description => '',
|
||||||
|
format => '',
|
||||||
|
read_only => '',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
__PACKAGE__->openapi_types( {
|
||||||
|
'___type' => 'string',
|
||||||
|
'last_name' => 'string',
|
||||||
|
'first_name' => 'string',
|
||||||
|
'duplicated_optional' => 'string',
|
||||||
|
'duplicated_required' => 'string',
|
||||||
|
'person_required' => 'DateTime'
|
||||||
|
} );
|
||||||
|
|
||||||
|
__PACKAGE__->attribute_map( {
|
||||||
|
'___type' => '$_type',
|
||||||
|
'last_name' => 'lastName',
|
||||||
|
'first_name' => 'firstName',
|
||||||
|
'duplicated_optional' => 'duplicated_optional',
|
||||||
|
'duplicated_required' => 'duplicated_required',
|
||||||
|
'person_required' => 'person_required'
|
||||||
|
} );
|
||||||
|
|
||||||
|
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
||||||
|
|
||||||
|
|
||||||
|
1;
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
=begin comment
|
=begin comment
|
||||||
|
|
||||||
OpenAPI Petstore
|
OpenAPI Petstore
|
||||||
@@ -34,7 +33,7 @@ use DateTime;
|
|||||||
use WWW::OpenAPIClient::Object::Category;
|
use WWW::OpenAPIClient::Object::Category;
|
||||||
use WWW::OpenAPIClient::Object::Tag;
|
use WWW::OpenAPIClient::Object::Tag;
|
||||||
|
|
||||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||||
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
@@ -62,165 +61,164 @@ Generated by: https://openapi-generator.tech
|
|||||||
# Do not edit the class manually.
|
# Do not edit the class manually.
|
||||||
# Ref: https://openapi-generator.tech
|
# Ref: https://openapi-generator.tech
|
||||||
#
|
#
|
||||||
__PACKAGE__->mk_classdata( 'attribute_map' => {} );
|
__PACKAGE__->mk_classdata('attribute_map' => {});
|
||||||
__PACKAGE__->mk_classdata( 'openapi_types' => {} );
|
__PACKAGE__->mk_classdata('openapi_types' => {});
|
||||||
__PACKAGE__->mk_classdata( 'method_documentation' => {} );
|
__PACKAGE__->mk_classdata('method_documentation' => {});
|
||||||
__PACKAGE__->mk_classdata( 'class_documentation' => {} );
|
__PACKAGE__->mk_classdata('class_documentation' => {});
|
||||||
|
|
||||||
# new object
|
# new plain object
|
||||||
sub new {
|
sub new {
|
||||||
my ( $class, %args ) = @_;
|
my ($class, %args) = @_;
|
||||||
|
|
||||||
my $self = bless {}, $class;
|
my $self = bless {}, $class;
|
||||||
|
|
||||||
foreach my $attribute ( keys %{ $class->attribute_map } ) {
|
$self->init(%args);
|
||||||
my $args_key = $class->attribute_map->{$attribute};
|
|
||||||
$self->$attribute( $args{$args_key} );
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
# initialize the object
|
||||||
|
sub init
|
||||||
|
{
|
||||||
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
|
foreach my $attribute (keys %{$self->attribute_map}) {
|
||||||
|
my $args_key = $self->attribute_map->{$attribute};
|
||||||
|
$self->$attribute( $args{ $args_key } );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# return perl hash
|
# return perl hash
|
||||||
sub to_hash {
|
sub to_hash {
|
||||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
my $self = shift;
|
||||||
|
my $_hash = decode_json(JSON->new->convert_blessed->encode($self));
|
||||||
|
|
||||||
|
return $_hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
# used by JSON for serialization
|
# used by JSON for serialization
|
||||||
sub TO_JSON {
|
sub TO_JSON {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $_data = {};
|
my $_data = {};
|
||||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
foreach my $_key (keys %{$self->attribute_map}) {
|
||||||
if ( defined $self->{$_key} ) {
|
if (defined $self->{$_key}) {
|
||||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
$_data->{$self->attribute_map->{$_key}} = $self->{$_key};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $_data;
|
return $_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
# from Perl hashref
|
# from Perl hashref
|
||||||
sub from_hash {
|
sub from_hash {
|
||||||
my ( $self, $hash ) = @_;
|
my ($self, $hash) = @_;
|
||||||
|
|
||||||
# loop through attributes and use openapi_types to deserialize the data
|
# loop through attributes and use openapi_types to deserialize the data
|
||||||
while ( my ( $_key, $_type ) = each %{ $self->openapi_types } ) {
|
while ( my ($_key, $_type) = each %{$self->openapi_types} ) {
|
||||||
my $_json_attribute = $self->attribute_map->{$_key};
|
my $_json_attribute = $self->attribute_map->{$_key};
|
||||||
if ( $_type =~ /^array\[/i ) { # array
|
if ($_type =~ /^array\[/i) { # array
|
||||||
my $_subclass = substr( $_type, 6, -1 );
|
my $_subclass = substr($_type, 6, -1);
|
||||||
my @_array = ();
|
my @_array = ();
|
||||||
foreach my $_element ( @{ $hash->{$_json_attribute} } ) {
|
foreach my $_element (@{$hash->{$_json_attribute}}) {
|
||||||
push @_array, $self->_deserialize( $_subclass, $_element );
|
push @_array, $self->_deserialize($_subclass, $_element);
|
||||||
}
|
}
|
||||||
$self->{$_key} = \@_array;
|
$self->{$_key} = \@_array;
|
||||||
}
|
} elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
|
||||||
elsif ( exists $hash->{$_json_attribute} )
|
$self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute});
|
||||||
{ #hash(model), primitive, datetime
|
} else {
|
||||||
$self->{$_key} =
|
$log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
|
||||||
$self->_deserialize( $_type, $hash->{$_json_attribute} );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$log->debugf( "Warning: %s (%s) does not exist in input hash\n",
|
|
||||||
$_key, $_json_attribute );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
# deserialize non-array data
|
# deserialize non-array data
|
||||||
sub _deserialize {
|
sub _deserialize {
|
||||||
my ( $self, $type, $data ) = @_;
|
my ($self, $type, $data) = @_;
|
||||||
$log->debugf( "deserializing %s with %s", Dumper($data), $type );
|
$log->debugf("deserializing %s with %s",Dumper($data), $type);
|
||||||
|
|
||||||
if ( $type eq 'DateTime' ) {
|
if ($type eq 'DateTime') {
|
||||||
return DateTime->from_epoch( epoch => str2time($data) );
|
return DateTime->from_epoch(epoch => str2time($data));
|
||||||
}
|
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
|
||||||
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
} else { # hash(model)
|
||||||
else { # hash(model)
|
|
||||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||||
return $_instance->from_hash($data);
|
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__->openapi_types(
|
__PACKAGE__->class_documentation({description => '',
|
||||||
{
|
class => 'Pet',
|
||||||
'id' => 'int',
|
required => [], # TODO
|
||||||
'category' => 'Category',
|
} );
|
||||||
'name' => 'string',
|
|
||||||
'photo_urls' => 'ARRAY[string]',
|
|
||||||
'tags' => 'ARRAY[Tag]',
|
|
||||||
'status' => 'string'
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
__PACKAGE__->attribute_map(
|
__PACKAGE__->method_documentation({
|
||||||
{
|
'id' => {
|
||||||
'id' => 'id',
|
datatype => 'int',
|
||||||
'category' => 'category',
|
base_name => 'id',
|
||||||
'name' => 'name',
|
description => '',
|
||||||
'photo_urls' => 'photoUrls',
|
format => '',
|
||||||
'tags' => 'tags',
|
read_only => '',
|
||||||
'status' => 'status'
|
},
|
||||||
}
|
'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__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
=begin comment
|
=begin comment
|
||||||
|
|
||||||
OpenAPI Petstore
|
OpenAPI Petstore
|
||||||
@@ -31,7 +30,8 @@ use Log::Any qw($log);
|
|||||||
use Date::Parse;
|
use Date::Parse;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
|
||||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
|
||||||
|
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||||
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
@@ -59,129 +59,128 @@ Generated by: https://openapi-generator.tech
|
|||||||
# Do not edit the class manually.
|
# Do not edit the class manually.
|
||||||
# Ref: https://openapi-generator.tech
|
# Ref: https://openapi-generator.tech
|
||||||
#
|
#
|
||||||
__PACKAGE__->mk_classdata( 'attribute_map' => {} );
|
__PACKAGE__->mk_classdata('attribute_map' => {});
|
||||||
__PACKAGE__->mk_classdata( 'openapi_types' => {} );
|
__PACKAGE__->mk_classdata('openapi_types' => {});
|
||||||
__PACKAGE__->mk_classdata( 'method_documentation' => {} );
|
__PACKAGE__->mk_classdata('method_documentation' => {});
|
||||||
__PACKAGE__->mk_classdata( 'class_documentation' => {} );
|
__PACKAGE__->mk_classdata('class_documentation' => {});
|
||||||
|
|
||||||
# new object
|
# new plain object
|
||||||
sub new {
|
sub new {
|
||||||
my ( $class, %args ) = @_;
|
my ($class, %args) = @_;
|
||||||
|
|
||||||
my $self = bless {}, $class;
|
my $self = bless {}, $class;
|
||||||
|
|
||||||
foreach my $attribute ( keys %{ $class->attribute_map } ) {
|
$self->init(%args);
|
||||||
my $args_key = $class->attribute_map->{$attribute};
|
|
||||||
$self->$attribute( $args{$args_key} );
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
# initialize the object
|
||||||
|
sub init
|
||||||
|
{
|
||||||
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
|
foreach my $attribute (keys %{$self->attribute_map}) {
|
||||||
|
my $args_key = $self->attribute_map->{$attribute};
|
||||||
|
$self->$attribute( $args{ $args_key } );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# return perl hash
|
# return perl hash
|
||||||
sub to_hash {
|
sub to_hash {
|
||||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
my $self = shift;
|
||||||
|
my $_hash = decode_json(JSON->new->convert_blessed->encode($self));
|
||||||
|
|
||||||
|
return $_hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
# used by JSON for serialization
|
# used by JSON for serialization
|
||||||
sub TO_JSON {
|
sub TO_JSON {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $_data = {};
|
my $_data = {};
|
||||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
foreach my $_key (keys %{$self->attribute_map}) {
|
||||||
if ( defined $self->{$_key} ) {
|
if (defined $self->{$_key}) {
|
||||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
$_data->{$self->attribute_map->{$_key}} = $self->{$_key};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $_data;
|
return $_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
# from Perl hashref
|
# from Perl hashref
|
||||||
sub from_hash {
|
sub from_hash {
|
||||||
my ( $self, $hash ) = @_;
|
my ($self, $hash) = @_;
|
||||||
|
|
||||||
# loop through attributes and use openapi_types to deserialize the data
|
# loop through attributes and use openapi_types to deserialize the data
|
||||||
while ( my ( $_key, $_type ) = each %{ $self->openapi_types } ) {
|
while ( my ($_key, $_type) = each %{$self->openapi_types} ) {
|
||||||
my $_json_attribute = $self->attribute_map->{$_key};
|
my $_json_attribute = $self->attribute_map->{$_key};
|
||||||
if ( $_type =~ /^array\[/i ) { # array
|
if ($_type =~ /^array\[/i) { # array
|
||||||
my $_subclass = substr( $_type, 6, -1 );
|
my $_subclass = substr($_type, 6, -1);
|
||||||
my @_array = ();
|
my @_array = ();
|
||||||
foreach my $_element ( @{ $hash->{$_json_attribute} } ) {
|
foreach my $_element (@{$hash->{$_json_attribute}}) {
|
||||||
push @_array, $self->_deserialize( $_subclass, $_element );
|
push @_array, $self->_deserialize($_subclass, $_element);
|
||||||
}
|
}
|
||||||
$self->{$_key} = \@_array;
|
$self->{$_key} = \@_array;
|
||||||
}
|
} elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
|
||||||
elsif ( exists $hash->{$_json_attribute} )
|
$self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute});
|
||||||
{ #hash(model), primitive, datetime
|
} else {
|
||||||
$self->{$_key} =
|
$log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
|
||||||
$self->_deserialize( $_type, $hash->{$_json_attribute} );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$log->debugf( "Warning: %s (%s) does not exist in input hash\n",
|
|
||||||
$_key, $_json_attribute );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
# deserialize non-array data
|
# deserialize non-array data
|
||||||
sub _deserialize {
|
sub _deserialize {
|
||||||
my ( $self, $type, $data ) = @_;
|
my ($self, $type, $data) = @_;
|
||||||
$log->debugf( "deserializing %s with %s", Dumper($data), $type );
|
$log->debugf("deserializing %s with %s",Dumper($data), $type);
|
||||||
|
|
||||||
if ( $type eq 'DateTime' ) {
|
if ($type eq 'DateTime') {
|
||||||
return DateTime->from_epoch( epoch => str2time($data) );
|
return DateTime->from_epoch(epoch => str2time($data));
|
||||||
}
|
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
|
||||||
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
} else { # hash(model)
|
||||||
else { # hash(model)
|
|
||||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||||
return $_instance->from_hash($data);
|
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__->openapi_types(
|
__PACKAGE__->class_documentation({description => '',
|
||||||
{
|
class => 'ReadOnlyFirst',
|
||||||
'bar' => 'string',
|
required => [], # TODO
|
||||||
'baz' => 'string'
|
} );
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
__PACKAGE__->attribute_map(
|
__PACKAGE__->method_documentation({
|
||||||
{
|
'bar' => {
|
||||||
'bar' => 'bar',
|
datatype => 'string',
|
||||||
'baz' => 'baz'
|
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__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
=begin comment
|
=begin comment
|
||||||
|
|
||||||
OpenAPI Petstore
|
OpenAPI Petstore
|
||||||
@@ -31,7 +30,8 @@ use Log::Any qw($log);
|
|||||||
use Date::Parse;
|
use Date::Parse;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
|
||||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
|
||||||
|
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||||
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
@@ -59,120 +59,119 @@ Generated by: https://openapi-generator.tech
|
|||||||
# Do not edit the class manually.
|
# Do not edit the class manually.
|
||||||
# Ref: https://openapi-generator.tech
|
# Ref: https://openapi-generator.tech
|
||||||
#
|
#
|
||||||
__PACKAGE__->mk_classdata( 'attribute_map' => {} );
|
__PACKAGE__->mk_classdata('attribute_map' => {});
|
||||||
__PACKAGE__->mk_classdata( 'openapi_types' => {} );
|
__PACKAGE__->mk_classdata('openapi_types' => {});
|
||||||
__PACKAGE__->mk_classdata( 'method_documentation' => {} );
|
__PACKAGE__->mk_classdata('method_documentation' => {});
|
||||||
__PACKAGE__->mk_classdata( 'class_documentation' => {} );
|
__PACKAGE__->mk_classdata('class_documentation' => {});
|
||||||
|
|
||||||
# new object
|
# new plain object
|
||||||
sub new {
|
sub new {
|
||||||
my ( $class, %args ) = @_;
|
my ($class, %args) = @_;
|
||||||
|
|
||||||
my $self = bless {}, $class;
|
my $self = bless {}, $class;
|
||||||
|
|
||||||
foreach my $attribute ( keys %{ $class->attribute_map } ) {
|
$self->init(%args);
|
||||||
my $args_key = $class->attribute_map->{$attribute};
|
|
||||||
$self->$attribute( $args{$args_key} );
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
# initialize the object
|
||||||
|
sub init
|
||||||
|
{
|
||||||
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
|
foreach my $attribute (keys %{$self->attribute_map}) {
|
||||||
|
my $args_key = $self->attribute_map->{$attribute};
|
||||||
|
$self->$attribute( $args{ $args_key } );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# return perl hash
|
# return perl hash
|
||||||
sub to_hash {
|
sub to_hash {
|
||||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
my $self = shift;
|
||||||
|
my $_hash = decode_json(JSON->new->convert_blessed->encode($self));
|
||||||
|
|
||||||
|
return $_hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
# used by JSON for serialization
|
# used by JSON for serialization
|
||||||
sub TO_JSON {
|
sub TO_JSON {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $_data = {};
|
my $_data = {};
|
||||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
foreach my $_key (keys %{$self->attribute_map}) {
|
||||||
if ( defined $self->{$_key} ) {
|
if (defined $self->{$_key}) {
|
||||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
$_data->{$self->attribute_map->{$_key}} = $self->{$_key};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $_data;
|
return $_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
# from Perl hashref
|
# from Perl hashref
|
||||||
sub from_hash {
|
sub from_hash {
|
||||||
my ( $self, $hash ) = @_;
|
my ($self, $hash) = @_;
|
||||||
|
|
||||||
# loop through attributes and use openapi_types to deserialize the data
|
# loop through attributes and use openapi_types to deserialize the data
|
||||||
while ( my ( $_key, $_type ) = each %{ $self->openapi_types } ) {
|
while ( my ($_key, $_type) = each %{$self->openapi_types} ) {
|
||||||
my $_json_attribute = $self->attribute_map->{$_key};
|
my $_json_attribute = $self->attribute_map->{$_key};
|
||||||
if ( $_type =~ /^array\[/i ) { # array
|
if ($_type =~ /^array\[/i) { # array
|
||||||
my $_subclass = substr( $_type, 6, -1 );
|
my $_subclass = substr($_type, 6, -1);
|
||||||
my @_array = ();
|
my @_array = ();
|
||||||
foreach my $_element ( @{ $hash->{$_json_attribute} } ) {
|
foreach my $_element (@{$hash->{$_json_attribute}}) {
|
||||||
push @_array, $self->_deserialize( $_subclass, $_element );
|
push @_array, $self->_deserialize($_subclass, $_element);
|
||||||
}
|
}
|
||||||
$self->{$_key} = \@_array;
|
$self->{$_key} = \@_array;
|
||||||
}
|
} elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
|
||||||
elsif ( exists $hash->{$_json_attribute} )
|
$self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute});
|
||||||
{ #hash(model), primitive, datetime
|
} else {
|
||||||
$self->{$_key} =
|
$log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
|
||||||
$self->_deserialize( $_type, $hash->{$_json_attribute} );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$log->debugf( "Warning: %s (%s) does not exist in input hash\n",
|
|
||||||
$_key, $_json_attribute );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
# deserialize non-array data
|
# deserialize non-array data
|
||||||
sub _deserialize {
|
sub _deserialize {
|
||||||
my ( $self, $type, $data ) = @_;
|
my ($self, $type, $data) = @_;
|
||||||
$log->debugf( "deserializing %s with %s", Dumper($data), $type );
|
$log->debugf("deserializing %s with %s",Dumper($data), $type);
|
||||||
|
|
||||||
if ( $type eq 'DateTime' ) {
|
if ($type eq 'DateTime') {
|
||||||
return DateTime->from_epoch( epoch => str2time($data) );
|
return DateTime->from_epoch(epoch => str2time($data));
|
||||||
}
|
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
|
||||||
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
} else { # hash(model)
|
||||||
else { # hash(model)
|
|
||||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||||
return $_instance->from_hash($data);
|
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__->openapi_types(
|
__PACKAGE__->class_documentation({description => '',
|
||||||
{
|
class => 'SpecialModelName',
|
||||||
'__special[property/name]' => 'int'
|
required => [], # TODO
|
||||||
}
|
} );
|
||||||
);
|
|
||||||
|
|
||||||
__PACKAGE__->attribute_map(
|
__PACKAGE__->method_documentation({
|
||||||
{
|
'__special[property/name]' => {
|
||||||
'__special[property/name]' => '$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__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
=begin comment
|
=begin comment
|
||||||
|
|
||||||
OpenAPI Petstore
|
OpenAPI Petstore
|
||||||
@@ -31,7 +30,8 @@ use Log::Any qw($log);
|
|||||||
use Date::Parse;
|
use Date::Parse;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
|
||||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
|
||||||
|
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||||
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
@@ -59,129 +59,128 @@ Generated by: https://openapi-generator.tech
|
|||||||
# Do not edit the class manually.
|
# Do not edit the class manually.
|
||||||
# Ref: https://openapi-generator.tech
|
# Ref: https://openapi-generator.tech
|
||||||
#
|
#
|
||||||
__PACKAGE__->mk_classdata( 'attribute_map' => {} );
|
__PACKAGE__->mk_classdata('attribute_map' => {});
|
||||||
__PACKAGE__->mk_classdata( 'openapi_types' => {} );
|
__PACKAGE__->mk_classdata('openapi_types' => {});
|
||||||
__PACKAGE__->mk_classdata( 'method_documentation' => {} );
|
__PACKAGE__->mk_classdata('method_documentation' => {});
|
||||||
__PACKAGE__->mk_classdata( 'class_documentation' => {} );
|
__PACKAGE__->mk_classdata('class_documentation' => {});
|
||||||
|
|
||||||
# new object
|
# new plain object
|
||||||
sub new {
|
sub new {
|
||||||
my ( $class, %args ) = @_;
|
my ($class, %args) = @_;
|
||||||
|
|
||||||
my $self = bless {}, $class;
|
my $self = bless {}, $class;
|
||||||
|
|
||||||
foreach my $attribute ( keys %{ $class->attribute_map } ) {
|
$self->init(%args);
|
||||||
my $args_key = $class->attribute_map->{$attribute};
|
|
||||||
$self->$attribute( $args{$args_key} );
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
# initialize the object
|
||||||
|
sub init
|
||||||
|
{
|
||||||
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
|
foreach my $attribute (keys %{$self->attribute_map}) {
|
||||||
|
my $args_key = $self->attribute_map->{$attribute};
|
||||||
|
$self->$attribute( $args{ $args_key } );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# return perl hash
|
# return perl hash
|
||||||
sub to_hash {
|
sub to_hash {
|
||||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
my $self = shift;
|
||||||
|
my $_hash = decode_json(JSON->new->convert_blessed->encode($self));
|
||||||
|
|
||||||
|
return $_hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
# used by JSON for serialization
|
# used by JSON for serialization
|
||||||
sub TO_JSON {
|
sub TO_JSON {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $_data = {};
|
my $_data = {};
|
||||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
foreach my $_key (keys %{$self->attribute_map}) {
|
||||||
if ( defined $self->{$_key} ) {
|
if (defined $self->{$_key}) {
|
||||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
$_data->{$self->attribute_map->{$_key}} = $self->{$_key};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $_data;
|
return $_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
# from Perl hashref
|
# from Perl hashref
|
||||||
sub from_hash {
|
sub from_hash {
|
||||||
my ( $self, $hash ) = @_;
|
my ($self, $hash) = @_;
|
||||||
|
|
||||||
# loop through attributes and use openapi_types to deserialize the data
|
# loop through attributes and use openapi_types to deserialize the data
|
||||||
while ( my ( $_key, $_type ) = each %{ $self->openapi_types } ) {
|
while ( my ($_key, $_type) = each %{$self->openapi_types} ) {
|
||||||
my $_json_attribute = $self->attribute_map->{$_key};
|
my $_json_attribute = $self->attribute_map->{$_key};
|
||||||
if ( $_type =~ /^array\[/i ) { # array
|
if ($_type =~ /^array\[/i) { # array
|
||||||
my $_subclass = substr( $_type, 6, -1 );
|
my $_subclass = substr($_type, 6, -1);
|
||||||
my @_array = ();
|
my @_array = ();
|
||||||
foreach my $_element ( @{ $hash->{$_json_attribute} } ) {
|
foreach my $_element (@{$hash->{$_json_attribute}}) {
|
||||||
push @_array, $self->_deserialize( $_subclass, $_element );
|
push @_array, $self->_deserialize($_subclass, $_element);
|
||||||
}
|
}
|
||||||
$self->{$_key} = \@_array;
|
$self->{$_key} = \@_array;
|
||||||
}
|
} elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
|
||||||
elsif ( exists $hash->{$_json_attribute} )
|
$self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute});
|
||||||
{ #hash(model), primitive, datetime
|
} else {
|
||||||
$self->{$_key} =
|
$log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
|
||||||
$self->_deserialize( $_type, $hash->{$_json_attribute} );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$log->debugf( "Warning: %s (%s) does not exist in input hash\n",
|
|
||||||
$_key, $_json_attribute );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
# deserialize non-array data
|
# deserialize non-array data
|
||||||
sub _deserialize {
|
sub _deserialize {
|
||||||
my ( $self, $type, $data ) = @_;
|
my ($self, $type, $data) = @_;
|
||||||
$log->debugf( "deserializing %s with %s", Dumper($data), $type );
|
$log->debugf("deserializing %s with %s",Dumper($data), $type);
|
||||||
|
|
||||||
if ( $type eq 'DateTime' ) {
|
if ($type eq 'DateTime') {
|
||||||
return DateTime->from_epoch( epoch => str2time($data) );
|
return DateTime->from_epoch(epoch => str2time($data));
|
||||||
}
|
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
|
||||||
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
} else { # hash(model)
|
||||||
else { # hash(model)
|
|
||||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||||
return $_instance->from_hash($data);
|
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__->openapi_types(
|
__PACKAGE__->class_documentation({description => '',
|
||||||
{
|
class => 'Tag',
|
||||||
'id' => 'int',
|
required => [], # TODO
|
||||||
'name' => 'string'
|
} );
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
__PACKAGE__->attribute_map(
|
__PACKAGE__->method_documentation({
|
||||||
{
|
'id' => {
|
||||||
'id' => 'id',
|
datatype => 'int',
|
||||||
'name' => 'name'
|
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__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
=begin comment
|
=begin comment
|
||||||
|
|
||||||
OpenAPI Petstore
|
OpenAPI Petstore
|
||||||
@@ -31,7 +30,8 @@ use Log::Any qw($log);
|
|||||||
use Date::Parse;
|
use Date::Parse;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
|
||||||
use base ( "Class::Accessor", "Class::Data::Inheritable" );
|
|
||||||
|
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||||
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
@@ -59,183 +59,182 @@ Generated by: https://openapi-generator.tech
|
|||||||
# Do not edit the class manually.
|
# Do not edit the class manually.
|
||||||
# Ref: https://openapi-generator.tech
|
# Ref: https://openapi-generator.tech
|
||||||
#
|
#
|
||||||
__PACKAGE__->mk_classdata( 'attribute_map' => {} );
|
__PACKAGE__->mk_classdata('attribute_map' => {});
|
||||||
__PACKAGE__->mk_classdata( 'openapi_types' => {} );
|
__PACKAGE__->mk_classdata('openapi_types' => {});
|
||||||
__PACKAGE__->mk_classdata( 'method_documentation' => {} );
|
__PACKAGE__->mk_classdata('method_documentation' => {});
|
||||||
__PACKAGE__->mk_classdata( 'class_documentation' => {} );
|
__PACKAGE__->mk_classdata('class_documentation' => {});
|
||||||
|
|
||||||
# new object
|
# new plain object
|
||||||
sub new {
|
sub new {
|
||||||
my ( $class, %args ) = @_;
|
my ($class, %args) = @_;
|
||||||
|
|
||||||
my $self = bless {}, $class;
|
my $self = bless {}, $class;
|
||||||
|
|
||||||
foreach my $attribute ( keys %{ $class->attribute_map } ) {
|
$self->init(%args);
|
||||||
my $args_key = $class->attribute_map->{$attribute};
|
|
||||||
$self->$attribute( $args{$args_key} );
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
# initialize the object
|
||||||
|
sub init
|
||||||
|
{
|
||||||
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
|
foreach my $attribute (keys %{$self->attribute_map}) {
|
||||||
|
my $args_key = $self->attribute_map->{$attribute};
|
||||||
|
$self->$attribute( $args{ $args_key } );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# return perl hash
|
# return perl hash
|
||||||
sub to_hash {
|
sub to_hash {
|
||||||
return decode_json( JSON->new->convert_blessed->encode(shift) );
|
my $self = shift;
|
||||||
|
my $_hash = decode_json(JSON->new->convert_blessed->encode($self));
|
||||||
|
|
||||||
|
return $_hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
# used by JSON for serialization
|
# used by JSON for serialization
|
||||||
sub TO_JSON {
|
sub TO_JSON {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $_data = {};
|
my $_data = {};
|
||||||
foreach my $_key ( keys %{ $self->attribute_map } ) {
|
foreach my $_key (keys %{$self->attribute_map}) {
|
||||||
if ( defined $self->{$_key} ) {
|
if (defined $self->{$_key}) {
|
||||||
$_data->{ $self->attribute_map->{$_key} } = $self->{$_key};
|
$_data->{$self->attribute_map->{$_key}} = $self->{$_key};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $_data;
|
return $_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
# from Perl hashref
|
# from Perl hashref
|
||||||
sub from_hash {
|
sub from_hash {
|
||||||
my ( $self, $hash ) = @_;
|
my ($self, $hash) = @_;
|
||||||
|
|
||||||
# loop through attributes and use openapi_types to deserialize the data
|
# loop through attributes and use openapi_types to deserialize the data
|
||||||
while ( my ( $_key, $_type ) = each %{ $self->openapi_types } ) {
|
while ( my ($_key, $_type) = each %{$self->openapi_types} ) {
|
||||||
my $_json_attribute = $self->attribute_map->{$_key};
|
my $_json_attribute = $self->attribute_map->{$_key};
|
||||||
if ( $_type =~ /^array\[/i ) { # array
|
if ($_type =~ /^array\[/i) { # array
|
||||||
my $_subclass = substr( $_type, 6, -1 );
|
my $_subclass = substr($_type, 6, -1);
|
||||||
my @_array = ();
|
my @_array = ();
|
||||||
foreach my $_element ( @{ $hash->{$_json_attribute} } ) {
|
foreach my $_element (@{$hash->{$_json_attribute}}) {
|
||||||
push @_array, $self->_deserialize( $_subclass, $_element );
|
push @_array, $self->_deserialize($_subclass, $_element);
|
||||||
}
|
}
|
||||||
$self->{$_key} = \@_array;
|
$self->{$_key} = \@_array;
|
||||||
}
|
} elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
|
||||||
elsif ( exists $hash->{$_json_attribute} )
|
$self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute});
|
||||||
{ #hash(model), primitive, datetime
|
} else {
|
||||||
$self->{$_key} =
|
$log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
|
||||||
$self->_deserialize( $_type, $hash->{$_json_attribute} );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$log->debugf( "Warning: %s (%s) does not exist in input hash\n",
|
|
||||||
$_key, $_json_attribute );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
# deserialize non-array data
|
# deserialize non-array data
|
||||||
sub _deserialize {
|
sub _deserialize {
|
||||||
my ( $self, $type, $data ) = @_;
|
my ($self, $type, $data) = @_;
|
||||||
$log->debugf( "deserializing %s with %s", Dumper($data), $type );
|
$log->debugf("deserializing %s with %s",Dumper($data), $type);
|
||||||
|
|
||||||
if ( $type eq 'DateTime' ) {
|
if ($type eq 'DateTime') {
|
||||||
return DateTime->from_epoch( epoch => str2time($data) );
|
return DateTime->from_epoch(epoch => str2time($data));
|
||||||
}
|
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
|
||||||
elsif ( grep( /^$type$/, ( 'int', 'double', 'string', 'boolean' ) ) ) {
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
} else { # hash(model)
|
||||||
else { # hash(model)
|
|
||||||
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
my $_instance = eval "WWW::OpenAPIClient::Object::$type->new()";
|
||||||
return $_instance->from_hash($data);
|
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__->openapi_types(
|
__PACKAGE__->class_documentation({description => '',
|
||||||
{
|
class => 'User',
|
||||||
'id' => 'int',
|
required => [], # TODO
|
||||||
'username' => 'string',
|
} );
|
||||||
'first_name' => 'string',
|
|
||||||
'last_name' => 'string',
|
|
||||||
'email' => 'string',
|
|
||||||
'password' => 'string',
|
|
||||||
'phone' => 'string',
|
|
||||||
'user_status' => 'int'
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
__PACKAGE__->attribute_map(
|
__PACKAGE__->method_documentation({
|
||||||
{
|
'id' => {
|
||||||
'id' => 'id',
|
datatype => 'int',
|
||||||
'username' => 'username',
|
base_name => 'id',
|
||||||
'first_name' => 'firstName',
|
description => '',
|
||||||
'last_name' => 'lastName',
|
format => '',
|
||||||
'email' => 'email',
|
read_only => '',
|
||||||
'password' => 'password',
|
},
|
||||||
'phone' => 'phone',
|
'username' => {
|
||||||
'user_status' => 'userStatus'
|
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__->mk_accessors( keys %{ __PACKAGE__->attribute_map } );
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
=begin comment
|
=begin comment
|
||||||
|
|
||||||
OpenAPI Petstore
|
OpenAPI Petstore
|
||||||
@@ -27,108 +26,87 @@ use Class::Inspector;
|
|||||||
use Log::Any qw($log);
|
use Log::Any qw($log);
|
||||||
use WWW::OpenAPIClient::ApiFactory;
|
use WWW::OpenAPIClient::ApiFactory;
|
||||||
|
|
||||||
has base_url => (
|
has base_url => ( is => 'ro',
|
||||||
is => 'ro',
|
required => 0,
|
||||||
required => 0,
|
isa => 'Str',
|
||||||
isa => 'Str',
|
documentation => 'Root of the server that requests are sent to',
|
||||||
documentation => 'Root of the server that requests are sent to',
|
);
|
||||||
);
|
|
||||||
|
|
||||||
has api_factory => (
|
has api_factory => ( is => 'ro',
|
||||||
is => 'ro',
|
isa => 'WWW::OpenAPIClient::ApiFactory',
|
||||||
isa => 'WWW::OpenAPIClient::ApiFactory',
|
builder => '_build_af',
|
||||||
builder => '_build_af',
|
lazy => 1,
|
||||||
lazy => 1,
|
documentation => 'Builds an instance of the endpoint API class',
|
||||||
documentation => 'Builds an instance of the endpoint API class',
|
);
|
||||||
);
|
|
||||||
|
|
||||||
has tokens => (
|
has tokens => ( is => 'ro',
|
||||||
is => 'ro',
|
isa => 'HashRef',
|
||||||
isa => 'HashRef',
|
required => 0,
|
||||||
required => 0,
|
default => sub { {} },
|
||||||
default => sub { {} },
|
documentation => 'The auth tokens required by the application - basic, OAuth and/or API key(s)',
|
||||||
documentation =>
|
);
|
||||||
'The auth tokens required by the application - basic, OAuth and/or API key(s)',
|
|
||||||
);
|
|
||||||
|
|
||||||
has _cfg => (
|
has _cfg => ( is => 'ro',
|
||||||
is => 'ro',
|
isa => 'WWW::OpenAPIClient::Configuration',
|
||||||
isa => 'WWW::OpenAPIClient::Configuration',
|
default => sub { WWW::OpenAPIClient::Configuration->new() },
|
||||||
default => sub { WWW::OpenAPIClient::Configuration->new() },
|
);
|
||||||
);
|
|
||||||
|
|
||||||
has version_info => (
|
has version_info => ( is => 'ro',
|
||||||
is => 'ro',
|
isa => 'HashRef',
|
||||||
isa => 'HashRef',
|
default => sub { {
|
||||||
default => sub {
|
app_name => 'OpenAPI Petstore',
|
||||||
{
|
app_version => '1.0.0',
|
||||||
app_name => 'OpenAPI Petstore',
|
generator_class => 'org.openapitools.codegen.languages.PerlClientCodegen',
|
||||||
app_version => '1.0.0',
|
} },
|
||||||
generator_class =>
|
documentation => 'Information about the application version and the codegen codebase version'
|
||||||
'org.openapitools.codegen.languages.PerlClientCodegen',
|
);
|
||||||
}
|
|
||||||
},
|
|
||||||
documentation =>
|
|
||||||
'Information about the application version and the codegen codebase version'
|
|
||||||
);
|
|
||||||
|
|
||||||
sub BUILD {
|
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
|
# ignore these symbols imported into API namespaces
|
||||||
my %outsiders = map { $_ => 1 } qw( croak );
|
my %outsiders = map {$_ => 1} qw( croak );
|
||||||
|
|
||||||
my %delegates;
|
my %delegates;
|
||||||
|
|
||||||
# collect the methods callable on each API
|
# collect the methods callable on each API
|
||||||
foreach my $api_name ( $self->api_factory->apis_available ) {
|
foreach my $api_name ($self->api_factory->apis_available) {
|
||||||
my $api_class = $self->api_factory->classname_for($api_name);
|
my $api_class = $self->api_factory->classname_for($api_name);
|
||||||
my $methods = Class::Inspector->methods( $api_class, 'expanded' )
|
my $methods = Class::Inspector->methods($api_class, 'expanded'); # not Moose, so use CI instead
|
||||||
; # not Moose, so use CI instead
|
my @local_methods = grep {! /^_/} grep {! $outsiders{$_}} map {$_->[2]} grep {$_->[1] eq $api_class} @$methods;
|
||||||
my @local_methods =
|
push( @{$delegates{$_}}, {api_name => $api_name, api_class => $api_class} ) for @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
|
# remove clashes
|
||||||
foreach my $method ( keys %delegates ) {
|
foreach my $method (keys %delegates) {
|
||||||
if ( @{ $delegates{$method} } > 1 ) {
|
if ( @{$delegates{$method}} > 1 ) {
|
||||||
my ($apis) = delete $delegates{$method};
|
my ($apis) = delete $delegates{$method};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# build the flattened API
|
# 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 $att_name = sprintf "%s_api", lc($api_name);
|
||||||
my $api_class = $self->api_factory->classname_for($api_name);
|
my $api_class = $self->api_factory->classname_for($api_name);
|
||||||
my @delegated =
|
my @delegated = grep { $delegates{$_}->[0]->{api_name} eq $api_name } keys %delegates;
|
||||||
grep { $delegates{$_}->[0]->{api_name} eq $api_name } keys %delegates;
|
$log->debugf("Adding API: '%s' handles %s", $att_name, join ', ', @delegated);
|
||||||
$log->debugf( "Adding API: '%s' handles %s",
|
$self->meta->add_attribute( $att_name => (
|
||||||
$att_name, join ', ', @delegated );
|
is => 'ro',
|
||||||
$self->meta->add_attribute(
|
isa => $api_class,
|
||||||
$att_name => (
|
default => sub {$self->api_factory->get_api($api_name)},
|
||||||
is => 'ro',
|
lazy => 1,
|
||||||
isa => $api_class,
|
handles => \@delegated,
|
||||||
default => sub { $self->api_factory->get_api($api_name) },
|
) );
|
||||||
lazy => 1,
|
|
||||||
handles => \@delegated,
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub _build_af {
|
sub _build_af {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my %args;
|
my %args;
|
||||||
$args{base_url} = $self->base_url if $self->base_url;
|
$args{base_url} = $self->base_url if $self->base_url;
|
||||||
return WWW::OpenAPIClient::ApiFactory->new(%args);
|
return WWW::OpenAPIClient::ApiFactory->new(%args);
|
||||||
}
|
}
|
||||||
|
|
||||||
=head1 NAME
|
=head1 NAME
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
=begin comment
|
=begin comment
|
||||||
|
|
||||||
OpenAPI Petstore
|
OpenAPI Petstore
|
||||||
@@ -24,57 +23,56 @@ use List::MoreUtils qw(uniq);
|
|||||||
use Moose::Role;
|
use Moose::Role;
|
||||||
|
|
||||||
sub autodoc {
|
sub autodoc {
|
||||||
my ( $self, $how ) = @_;
|
my ($self, $how) = @_;
|
||||||
|
|
||||||
die "Unknown format '$how'" unless $how =~ /^(pod|wide|narrow)$/;
|
die "Unknown format '$how'" unless $how =~ /^(pod|wide|narrow)$/;
|
||||||
|
|
||||||
$self->_printisa($how);
|
$self->_printisa($how);
|
||||||
$self->_printmethods($how);
|
$self->_printmethods($how);
|
||||||
$self->_printattrs($how);
|
$self->_printattrs($how);
|
||||||
print "\n";
|
print "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
sub _printisa {
|
sub _printisa {
|
||||||
my ( $self, $how ) = @_;
|
my ($self, $how) = @_;
|
||||||
my $meta = $self->meta;
|
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 $myclass = ref $self;
|
my $isa = join ', ', grep {$_ ne $myclass} $meta->linearized_isa;
|
||||||
|
my $sub = join ', ', $meta->subclasses;
|
||||||
my $super = join ', ', $meta->superclasses;
|
my $dsub = join ', ', $meta->direct_subclasses;
|
||||||
my @roles = $meta->calculate_all_roles;
|
|
||||||
|
my $app_name = $self->version_info->{app_name};
|
||||||
#shift(@roles) if @roles > 1; # if > 1, the first is a composite, the rest are the roles
|
my $app_version = $self->version_info->{app_version};
|
||||||
|
my $generated_date = $self->version_info->{generated_date};
|
||||||
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};
|
my $generator_class = $self->version_info->{generator_class};
|
||||||
|
|
||||||
$~ = $how eq 'pod' ? 'INHERIT_POD' : 'INHERIT';
|
$~ = $how eq 'pod' ? 'INHERIT_POD' : 'INHERIT';
|
||||||
write;
|
write;
|
||||||
|
|
||||||
my ( $rolepkg, $role_reqs );
|
my ($rolepkg, $role_reqs);
|
||||||
|
|
||||||
foreach my $role (@roles) {
|
foreach my $role (@roles) {
|
||||||
$rolepkg = $role->{package} || next; # some are anonymous, or something
|
$rolepkg = $role->{package} || next; # some are anonymous, or something
|
||||||
next if $rolepkg eq 'WWW::OpenAPIClient::Role::AutoDoc';
|
next if $rolepkg eq 'WWW::OpenAPIClient::Role::AutoDoc';
|
||||||
$role_reqs = join ', ', keys %{ $role->{required_methods} };
|
$role_reqs = join ', ', keys %{$role->{required_methods}};
|
||||||
$role_reqs ||= '';
|
$role_reqs ||= '';
|
||||||
$~ = $how eq 'pod' ? 'ROLES_POD' : 'ROLES';
|
$~ = $how eq 'pod' ? 'ROLES_POD' : 'ROLES';
|
||||||
write;
|
write;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $how eq 'pod' ) {
|
if ($how eq 'pod') {
|
||||||
$~ = 'ROLES_POD_CLOSE';
|
$~ = 'ROLES_POD_CLOSE';
|
||||||
write;
|
write;
|
||||||
}
|
}
|
||||||
|
|
||||||
# ----- format specs -----
|
# ----- format specs -----
|
||||||
format INHERIT =
|
format INHERIT =
|
||||||
|
|
||||||
@* -
|
@* -
|
||||||
$myclass
|
$myclass
|
||||||
@@ -93,7 +91,7 @@ $myclass
|
|||||||
$generator_class
|
$generator_class
|
||||||
|
|
||||||
.
|
.
|
||||||
format ROLES =
|
format ROLES =
|
||||||
Composes: ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ~
|
Composes: ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ~
|
||||||
$rolepkg
|
$rolepkg
|
||||||
requires: ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ~
|
requires: ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ~
|
||||||
@@ -102,7 +100,7 @@ $myclass
|
|||||||
$role_reqs
|
$role_reqs
|
||||||
.
|
.
|
||||||
|
|
||||||
format INHERIT_POD =
|
format INHERIT_POD =
|
||||||
=head1 NAME
|
=head1 NAME
|
||||||
|
|
||||||
@*
|
@*
|
||||||
@@ -153,7 +151,7 @@ $myclass
|
|||||||
|
|
||||||
|
|
||||||
.
|
.
|
||||||
format ROLES_POD =
|
format ROLES_POD =
|
||||||
=head2 C<@*>
|
=head2 C<@*>
|
||||||
$rolepkg
|
$rolepkg
|
||||||
|
|
||||||
@@ -163,108 +161,104 @@ Requires:
|
|||||||
$role_reqs
|
$role_reqs
|
||||||
|
|
||||||
.
|
.
|
||||||
format ROLES_POD_CLOSE =
|
format ROLES_POD_CLOSE =
|
||||||
|
|
||||||
|
|
||||||
.
|
.
|
||||||
|
# ----- / format specs -----
|
||||||
# ----- / format specs -----
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub _printmethods {
|
sub _printmethods {
|
||||||
my ( $self, $how ) = @_;
|
my ($self, $how) = @_;
|
||||||
|
|
||||||
if ( $how eq 'narrow' ) {
|
if ($how eq 'narrow') {
|
||||||
print <<HEAD;
|
print <<HEAD;
|
||||||
METHODS
|
METHODS
|
||||||
-------
|
-------
|
||||||
HEAD
|
HEAD
|
||||||
}
|
}
|
||||||
elsif ( $how eq 'wide' ) {
|
elsif ($how eq 'wide') {
|
||||||
$~ = 'METHODHEAD';
|
$~ = 'METHODHEAD';
|
||||||
write;
|
write;
|
||||||
}
|
}
|
||||||
elsif ( $how eq 'pod' ) {
|
elsif ($how eq 'pod') {
|
||||||
$~ = 'METHODHEAD_POD';
|
$~ = 'METHODHEAD_POD';
|
||||||
write;
|
write;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
die "Don't know how to print '$how'";
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
$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 {
|
sub _printmethod {
|
||||||
my ( $self, $methodname, $how ) = @_;
|
my ($self, $methodname, $how) = @_;
|
||||||
return if $methodname =~ /^_/;
|
return if $methodname =~ /^_/;
|
||||||
return if $self->meta->has_attribute($methodname);
|
return if $self->meta->has_attribute($methodname);
|
||||||
my %internal = map { $_ => 1 }
|
my %internal = map {$_ => 1} qw(BUILD BUILDARGS meta can new DEMOLISHALL DESTROY
|
||||||
qw(BUILD BUILDARGS meta can new DEMOLISHALL DESTROY
|
DOES isa BUILDALL does VERSION dump
|
||||||
DOES isa BUILDALL does VERSION dump
|
);
|
||||||
);
|
return if $internal{$methodname};
|
||||||
return if $internal{$methodname};
|
my $method = $self->meta->get_method($methodname) or return; # symbols imported into namespaces i.e. not known by Moose
|
||||||
my $method = $self->meta->get_method($methodname)
|
|
||||||
or return; # symbols imported into namespaces i.e. not known by Moose
|
return if $method->original_package_name eq __PACKAGE__;
|
||||||
|
|
||||||
return if $method->original_package_name eq __PACKAGE__;
|
my $delegate_to = '';
|
||||||
|
my $via = '';
|
||||||
my $delegate_to = '';
|
my $on = '';
|
||||||
my $via = '';
|
my $doc = '';
|
||||||
my $on = '';
|
my $original_pkg = $method->original_package_name;
|
||||||
my $doc = '';
|
if ($method->can('associated_attribute')) {
|
||||||
my $original_pkg = $method->original_package_name;
|
$delegate_to = $method->delegate_to_method;
|
||||||
if ( $method->can('associated_attribute') ) {
|
my $aa = $method->associated_attribute;
|
||||||
$delegate_to = $method->delegate_to_method;
|
$on = $aa->{isa};
|
||||||
my $aa = $method->associated_attribute;
|
$via = $aa->{name};
|
||||||
$on = $aa->{isa};
|
$original_pkg = $on;
|
||||||
$via = $aa->{name};
|
$doc = $original_pkg->method_documentation->{$delegate_to}->{summary};
|
||||||
$original_pkg = $on;
|
}
|
||||||
$doc = $original_pkg->method_documentation->{$delegate_to}->{summary};
|
else {
|
||||||
}
|
$doc = $method->documentation;
|
||||||
else {
|
}
|
||||||
$doc = $method->documentation;
|
|
||||||
}
|
if ($how eq 'narrow') {
|
||||||
|
$~ = 'METHOD_NARROW';
|
||||||
if ( $how eq 'narrow' ) {
|
write;
|
||||||
$~ = 'METHOD_NARROW';
|
}
|
||||||
write;
|
elsif ($how eq 'pod' and $delegate_to) {
|
||||||
}
|
$~ = 'METHOD_POD_DELEGATED';
|
||||||
elsif ( $how eq 'pod' and $delegate_to ) {
|
write;
|
||||||
$~ = 'METHOD_POD_DELEGATED';
|
}
|
||||||
write;
|
elsif ($how eq 'pod') {
|
||||||
}
|
$~ = 'METHOD_POD';
|
||||||
elsif ( $how eq 'pod' ) {
|
write;
|
||||||
$~ = 'METHOD_POD';
|
}
|
||||||
write;
|
else {
|
||||||
}
|
$~ = 'METHOD';
|
||||||
else {
|
write;
|
||||||
$~ = 'METHOD';
|
}
|
||||||
write;
|
|
||||||
}
|
# ----- format specs -----
|
||||||
|
format METHODHEAD =
|
||||||
# ----- format specs -----
|
|
||||||
format METHODHEAD =
|
|
||||||
|
|
||||||
METHODS
|
METHODS
|
||||||
-------
|
-------
|
||||||
Name delegates to on via
|
Name delegates to on via
|
||||||
===========================================================================================================================================================================
|
===========================================================================================================================================================================
|
||||||
.
|
.
|
||||||
format METHOD =
|
format METHOD =
|
||||||
@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<... @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<... @<<<<<<<<<<<<<<<<...
|
@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<... @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<... @<<<<<<<<<<<<<<<<...
|
||||||
$methodname, $delegate_to, $on, $via
|
$methodname, $delegate_to, $on, $via
|
||||||
.
|
.
|
||||||
|
|
||||||
format METHOD_NARROW =
|
format METHOD_NARROW =
|
||||||
@*
|
@*
|
||||||
$methodname
|
$methodname
|
||||||
original pkg: @*
|
original pkg: @*
|
||||||
@@ -278,13 +272,13 @@ $methodname
|
|||||||
|
|
||||||
.
|
.
|
||||||
|
|
||||||
format METHODHEAD_POD =
|
format METHODHEAD_POD =
|
||||||
|
|
||||||
=head1 METHODS
|
=head1 METHODS
|
||||||
|
|
||||||
.
|
.
|
||||||
|
|
||||||
format METHOD_POD =
|
format METHOD_POD =
|
||||||
|
|
||||||
=head2 C<@*()>
|
=head2 C<@*()>
|
||||||
$methodname
|
$methodname
|
||||||
@@ -294,7 +288,7 @@ $methodname
|
|||||||
|
|
||||||
|
|
||||||
.
|
.
|
||||||
format METHOD_POD_DELEGATED =
|
format METHOD_POD_DELEGATED =
|
||||||
|
|
||||||
=head2 C<@*()>
|
=head2 C<@*()>
|
||||||
$methodname
|
$methodname
|
||||||
@@ -313,96 +307,90 @@ $methodname
|
|||||||
$via, $delegate_to
|
$via, $delegate_to
|
||||||
|
|
||||||
.
|
.
|
||||||
format METHOD_POD_CLOSE =
|
format METHOD_POD_CLOSE =
|
||||||
|
|
||||||
.
|
.
|
||||||
|
# ----- / format specs -----
|
||||||
# ----- / format specs -----
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub _printattrs {
|
sub _printattrs {
|
||||||
my ( $self, $how ) = @_;
|
my ($self, $how) = @_;
|
||||||
|
|
||||||
if ( $how eq 'narrow' ) {
|
if ($how eq 'narrow') {
|
||||||
print <<HEAD;
|
print <<HEAD;
|
||||||
ATTRIBUTES
|
ATTRIBUTES
|
||||||
----------
|
----------
|
||||||
HEAD
|
HEAD
|
||||||
}
|
}
|
||||||
elsif ( $how eq 'wide' ) {
|
elsif ($how eq 'wide') {
|
||||||
$~ = 'ATTRHEAD';
|
$~ = 'ATTRHEAD';
|
||||||
write;
|
write;
|
||||||
}
|
}
|
||||||
elsif ( $how eq 'pod' ) {
|
elsif ($how eq 'pod') {
|
||||||
$~ = 'ATTRHEAD_POD';
|
$~ = 'ATTRHEAD_POD';
|
||||||
write;
|
write;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
die "Don't know how to print attributes '$how'";
|
die "Don't know how to print attributes '$how'";
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->_printattr( $_, $how ) for sort $self->meta->get_attribute_list;
|
$self->_printattr($_, $how) for sort $self->meta->get_attribute_list;
|
||||||
|
|
||||||
if ( $how eq 'pod' ) {
|
if ($how eq 'pod') {
|
||||||
$~ = 'ATTR_POD_CLOSE';
|
$~ = 'ATTR_POD_CLOSE';
|
||||||
write;
|
write;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub _printattr {
|
sub _printattr {
|
||||||
my ( $self, $attrname, $how ) = @_;
|
my ($self, $attrname, $how) = @_;
|
||||||
return if $attrname =~ /^_/;
|
return if $attrname =~ /^_/;
|
||||||
my $attr = $self->meta->get_attribute($attrname)
|
my $attr = $self->meta->get_attribute($attrname) or die "No attr for $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 $is;
|
write;
|
||||||
$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 || '';
|
# ----- format specs -----
|
||||||
my $from = $attr->associated_class->name || '';
|
format ATTRHEAD =
|
||||||
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
|
ATTRIBUTES
|
||||||
----------
|
----------
|
||||||
Name is isa reqd lazy doc handles
|
Name is isa reqd lazy doc handles
|
||||||
==============================================================================================================
|
==============================================================================================================
|
||||||
.
|
.
|
||||||
format ATTR =
|
format ATTR =
|
||||||
@<<<<<<<<<<<<<<<<< @< @<<<<<<<<<<<<<<<<<<<<<<<< @<<< @<<< @<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
@<<<<<<<<<<<<<<<<< @< @<<<<<<<<<<<<<<<<<<<<<<<< @<<< @<<< @<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
||||||
$attrname, $is, $tc, $reqd, $lazy, $has_doc, $handles
|
$attrname, $is, $tc, $reqd, $lazy, $has_doc, $handles
|
||||||
^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ~~
|
^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ~~
|
||||||
$handles
|
$handles
|
||||||
.
|
.
|
||||||
|
|
||||||
format ATTR_NARROW =
|
format ATTR_NARROW =
|
||||||
@*
|
@*
|
||||||
$attrname
|
$attrname
|
||||||
is: @*
|
is: @*
|
||||||
@@ -421,11 +409,11 @@ $attrname
|
|||||||
$handles
|
$handles
|
||||||
|
|
||||||
.
|
.
|
||||||
format ATTRHEAD_POD =
|
format ATTRHEAD_POD =
|
||||||
=head1 ATTRIBUTES
|
=head1 ATTRIBUTES
|
||||||
|
|
||||||
.
|
.
|
||||||
format ATTR_POD =
|
format ATTR_POD =
|
||||||
|
|
||||||
=head2 C<@*>
|
=head2 C<@*>
|
||||||
$attrname
|
$attrname
|
||||||
@@ -446,12 +434,13 @@ $attrname
|
|||||||
$handles
|
$handles
|
||||||
|
|
||||||
.
|
.
|
||||||
format ATTR_POD_CLOSE =
|
format ATTR_POD_CLOSE =
|
||||||
|
|
||||||
|
|
||||||
.
|
.
|
||||||
|
# ----- / format specs -----
|
||||||
# ----- / format specs -----
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
=begin comment
|
=begin comment
|
||||||
|
|
||||||
OpenAPI Petstore
|
OpenAPI Petstore
|
||||||
@@ -23,7 +22,7 @@ package WWW::OpenAPIClient::StoreApi;
|
|||||||
require 5.6.0;
|
require 5.6.0;
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use utf8;
|
use utf8;
|
||||||
use Exporter;
|
use Exporter;
|
||||||
use Carp qw( croak );
|
use Carp qw( croak );
|
||||||
use Log::Any qw($log);
|
use Log::Any qw($log);
|
||||||
@@ -32,16 +31,15 @@ use WWW::OpenAPIClient::ApiClient;
|
|||||||
|
|
||||||
use base "Class::Data::Inheritable";
|
use base "Class::Data::Inheritable";
|
||||||
|
|
||||||
__PACKAGE__->mk_classdata( 'method_documentation' => {} );
|
__PACKAGE__->mk_classdata('method_documentation' => {});
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my $class = shift;
|
my $class = shift;
|
||||||
my $api_client;
|
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];
|
$api_client = $_[0];
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$api_client = WWW::OpenAPIClient::ApiClient->new(@_);
|
$api_client = WWW::OpenAPIClient::ApiClient->new(@_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,73 +47,67 @@ sub new {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# delete_order
|
# delete_order
|
||||||
#
|
#
|
||||||
# Delete purchase order by ID
|
# Delete purchase order by ID
|
||||||
#
|
#
|
||||||
# @param string $order_id ID of the order that needs to be deleted (required)
|
# @param string $order_id ID of the order that needs to be deleted (required)
|
||||||
{
|
{
|
||||||
my $params = {
|
my $params = {
|
||||||
'order_id' => {
|
'order_id' => {
|
||||||
data_type => 'string',
|
data_type => 'string',
|
||||||
description => 'ID of the order that needs to be deleted',
|
description => 'ID of the order that needs to be deleted',
|
||||||
required => '1',
|
required => '1',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
__PACKAGE__->method_documentation->{'delete_order'} = {
|
__PACKAGE__->method_documentation->{ 'delete_order' } = {
|
||||||
summary => 'Delete purchase order by ID',
|
summary => 'Delete purchase order by ID',
|
||||||
params => $params,
|
params => $params,
|
||||||
returns => undef,
|
returns => undef,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
# @return void
|
# @return void
|
||||||
#
|
#
|
||||||
sub delete_order {
|
sub delete_order {
|
||||||
my ( $self, %args ) = @_;
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
# verify the required parameter 'order_id' is set
|
# verify the required parameter 'order_id' is set
|
||||||
unless ( exists $args{'order_id'} ) {
|
unless (exists $args{'order_id'}) {
|
||||||
croak(
|
croak("Missing the required parameter 'order_id' when calling delete_order");
|
||||||
"Missing the required parameter 'order_id' when calling delete_order"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# parse inputs
|
# parse inputs
|
||||||
my $_resource_path = '/store/order/{order_id}';
|
my $_resource_path = '/store/order/{order_id}';
|
||||||
|
|
||||||
my $_method = 'DELETE';
|
my $_method = 'DELETE';
|
||||||
my $query_params = {};
|
my $query_params = {};
|
||||||
my $header_params = {};
|
my $header_params = {};
|
||||||
my $form_params = {};
|
my $form_params = {};
|
||||||
|
|
||||||
# 'Accept' and 'Content-Type' header
|
# 'Accept' and 'Content-Type' header
|
||||||
my $_header_accept = $self->{api_client}->select_header_accept();
|
my $_header_accept = $self->{api_client}->select_header_accept();
|
||||||
if ($_header_accept) {
|
if ($_header_accept) {
|
||||||
$header_params->{'Accept'} = $_header_accept;
|
$header_params->{'Accept'} = $_header_accept;
|
||||||
}
|
}
|
||||||
$header_params->{'Content-Type'} =
|
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||||
$self->{api_client}->select_header_content_type();
|
|
||||||
|
|
||||||
# path params
|
# path params
|
||||||
if ( exists $args{'order_id'} ) {
|
if ( exists $args{'order_id'}) {
|
||||||
my $_base_variable = "{" . "order_id" . "}";
|
my $_base_variable = "{" . "order_id" . "}";
|
||||||
my $_base_value =
|
my $_base_value = $self->{api_client}->to_path_value($args{'order_id'});
|
||||||
$self->{api_client}->to_path_value( $args{'order_id'} );
|
|
||||||
$_resource_path =~ s/$_base_variable/$_base_value/g;
|
$_resource_path =~ s/$_base_variable/$_base_value/g;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $_body_data;
|
my $_body_data;
|
||||||
|
|
||||||
# authentication setting, if any
|
# authentication setting, if any
|
||||||
my $auth_settings = [qw()];
|
my $auth_settings = [qw()];
|
||||||
|
|
||||||
# make the API Call
|
# make the API Call
|
||||||
$self->{api_client}->call_api(
|
$self->{api_client}->call_api($_resource_path, $_method,
|
||||||
$_resource_path, $_method, $query_params, $form_params,
|
$query_params, $form_params,
|
||||||
$header_params, $_body_data, $auth_settings
|
$header_params, $_body_data, $auth_settings);
|
||||||
);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,53 +115,48 @@ sub delete_order {
|
|||||||
# get_inventory
|
# get_inventory
|
||||||
#
|
#
|
||||||
# Returns pet inventories by status
|
# Returns pet inventories by status
|
||||||
#
|
#
|
||||||
{
|
{
|
||||||
my $params = {};
|
my $params = {
|
||||||
__PACKAGE__->method_documentation->{'get_inventory'} = {
|
|
||||||
summary => 'Returns pet inventories by status',
|
|
||||||
params => $params,
|
|
||||||
returns => 'HASH[string,int]',
|
|
||||||
};
|
};
|
||||||
|
__PACKAGE__->method_documentation->{ 'get_inventory' } = {
|
||||||
|
summary => 'Returns pet inventories by status',
|
||||||
|
params => $params,
|
||||||
|
returns => 'HASH[string,int]',
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
# @return HASH[string,int]
|
# @return HASH[string,int]
|
||||||
#
|
#
|
||||||
sub get_inventory {
|
sub get_inventory {
|
||||||
my ( $self, %args ) = @_;
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
# parse inputs
|
# parse inputs
|
||||||
my $_resource_path = '/store/inventory';
|
my $_resource_path = '/store/inventory';
|
||||||
|
|
||||||
my $_method = 'GET';
|
my $_method = 'GET';
|
||||||
my $query_params = {};
|
my $query_params = {};
|
||||||
my $header_params = {};
|
my $header_params = {};
|
||||||
my $form_params = {};
|
my $form_params = {};
|
||||||
|
|
||||||
# 'Accept' and 'Content-Type' header
|
# 'Accept' and 'Content-Type' header
|
||||||
my $_header_accept =
|
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
|
||||||
$self->{api_client}->select_header_accept('application/json');
|
|
||||||
if ($_header_accept) {
|
if ($_header_accept) {
|
||||||
$header_params->{'Accept'} = $_header_accept;
|
$header_params->{'Accept'} = $_header_accept;
|
||||||
}
|
}
|
||||||
$header_params->{'Content-Type'} =
|
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||||
$self->{api_client}->select_header_content_type();
|
|
||||||
|
|
||||||
my $_body_data;
|
my $_body_data;
|
||||||
|
|
||||||
# authentication setting, if any
|
# authentication setting, if any
|
||||||
my $auth_settings = [qw(api_key )];
|
my $auth_settings = [qw(api_key )];
|
||||||
|
|
||||||
# make the API Call
|
# make the API Call
|
||||||
my $response = $self->{api_client}->call_api(
|
my $response = $self->{api_client}->call_api($_resource_path, $_method,
|
||||||
$_resource_path, $_method, $query_params, $form_params,
|
$query_params, $form_params,
|
||||||
$header_params, $_body_data, $auth_settings
|
$header_params, $_body_data, $auth_settings);
|
||||||
);
|
if (!$response) {
|
||||||
if ( !$response ) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
my $_response_object =
|
my $_response_object = $self->{api_client}->deserialize('HASH[string,int]', $response);
|
||||||
$self->{api_client}->deserialize( 'HASH[string,int]', $response );
|
|
||||||
return $_response_object;
|
return $_response_object;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -177,75 +164,66 @@ sub get_inventory {
|
|||||||
# get_order_by_id
|
# get_order_by_id
|
||||||
#
|
#
|
||||||
# Find purchase order by ID
|
# Find purchase order by ID
|
||||||
#
|
#
|
||||||
# @param int $order_id ID of pet that needs to be fetched (required)
|
# @param int $order_id ID of pet that needs to be fetched (required)
|
||||||
{
|
{
|
||||||
my $params = {
|
my $params = {
|
||||||
'order_id' => {
|
'order_id' => {
|
||||||
data_type => 'int',
|
data_type => 'int',
|
||||||
description => 'ID of pet that needs to be fetched',
|
description => 'ID of pet that needs to be fetched',
|
||||||
required => '1',
|
required => '1',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
__PACKAGE__->method_documentation->{'get_order_by_id'} = {
|
__PACKAGE__->method_documentation->{ 'get_order_by_id' } = {
|
||||||
summary => 'Find purchase order by ID',
|
summary => 'Find purchase order by ID',
|
||||||
params => $params,
|
params => $params,
|
||||||
returns => 'Order',
|
returns => 'Order',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
# @return Order
|
# @return Order
|
||||||
#
|
#
|
||||||
sub get_order_by_id {
|
sub get_order_by_id {
|
||||||
my ( $self, %args ) = @_;
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
# verify the required parameter 'order_id' is set
|
# verify the required parameter 'order_id' is set
|
||||||
unless ( exists $args{'order_id'} ) {
|
unless (exists $args{'order_id'}) {
|
||||||
croak(
|
croak("Missing the required parameter 'order_id' when calling get_order_by_id");
|
||||||
"Missing the required parameter 'order_id' when calling get_order_by_id"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# parse inputs
|
# parse inputs
|
||||||
my $_resource_path = '/store/order/{order_id}';
|
my $_resource_path = '/store/order/{order_id}';
|
||||||
|
|
||||||
my $_method = 'GET';
|
my $_method = 'GET';
|
||||||
my $query_params = {};
|
my $query_params = {};
|
||||||
my $header_params = {};
|
my $header_params = {};
|
||||||
my $form_params = {};
|
my $form_params = {};
|
||||||
|
|
||||||
# 'Accept' and 'Content-Type' header
|
# 'Accept' and 'Content-Type' header
|
||||||
my $_header_accept = $self->{api_client}
|
my $_header_accept = $self->{api_client}->select_header_accept('application/xml', 'application/json');
|
||||||
->select_header_accept( 'application/xml', 'application/json' );
|
|
||||||
if ($_header_accept) {
|
if ($_header_accept) {
|
||||||
$header_params->{'Accept'} = $_header_accept;
|
$header_params->{'Accept'} = $_header_accept;
|
||||||
}
|
}
|
||||||
$header_params->{'Content-Type'} =
|
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||||
$self->{api_client}->select_header_content_type();
|
|
||||||
|
|
||||||
# path params
|
# path params
|
||||||
if ( exists $args{'order_id'} ) {
|
if ( exists $args{'order_id'}) {
|
||||||
my $_base_variable = "{" . "order_id" . "}";
|
my $_base_variable = "{" . "order_id" . "}";
|
||||||
my $_base_value =
|
my $_base_value = $self->{api_client}->to_path_value($args{'order_id'});
|
||||||
$self->{api_client}->to_path_value( $args{'order_id'} );
|
|
||||||
$_resource_path =~ s/$_base_variable/$_base_value/g;
|
$_resource_path =~ s/$_base_variable/$_base_value/g;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $_body_data;
|
my $_body_data;
|
||||||
|
|
||||||
# authentication setting, if any
|
# authentication setting, if any
|
||||||
my $auth_settings = [qw()];
|
my $auth_settings = [qw()];
|
||||||
|
|
||||||
# make the API Call
|
# make the API Call
|
||||||
my $response = $self->{api_client}->call_api(
|
my $response = $self->{api_client}->call_api($_resource_path, $_method,
|
||||||
$_resource_path, $_method, $query_params, $form_params,
|
$query_params, $form_params,
|
||||||
$header_params, $_body_data, $auth_settings
|
$header_params, $_body_data, $auth_settings);
|
||||||
);
|
if (!$response) {
|
||||||
if ( !$response ) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
my $_response_object =
|
my $_response_object = $self->{api_client}->deserialize('Order', $response);
|
||||||
$self->{api_client}->deserialize( 'Order', $response );
|
|
||||||
return $_response_object;
|
return $_response_object;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,55 +231,50 @@ sub get_order_by_id {
|
|||||||
# place_order
|
# place_order
|
||||||
#
|
#
|
||||||
# Place an order for a pet
|
# Place an order for a pet
|
||||||
#
|
#
|
||||||
# @param Order $order order placed for purchasing the pet (required)
|
# @param Order $order order placed for purchasing the pet (required)
|
||||||
{
|
{
|
||||||
my $params = {
|
my $params = {
|
||||||
'order' => {
|
'order' => {
|
||||||
data_type => 'Order',
|
data_type => 'Order',
|
||||||
description => 'order placed for purchasing the pet',
|
description => 'order placed for purchasing the pet',
|
||||||
required => '1',
|
required => '1',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
__PACKAGE__->method_documentation->{'place_order'} = {
|
__PACKAGE__->method_documentation->{ 'place_order' } = {
|
||||||
summary => 'Place an order for a pet',
|
summary => 'Place an order for a pet',
|
||||||
params => $params,
|
params => $params,
|
||||||
returns => 'Order',
|
returns => 'Order',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
# @return Order
|
# @return Order
|
||||||
#
|
#
|
||||||
sub place_order {
|
sub place_order {
|
||||||
my ( $self, %args ) = @_;
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
# verify the required parameter 'order' is set
|
# verify the required parameter 'order' is set
|
||||||
unless ( exists $args{'order'} ) {
|
unless (exists $args{'order'}) {
|
||||||
croak(
|
croak("Missing the required parameter 'order' when calling place_order");
|
||||||
"Missing the required parameter 'order' when calling place_order");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# parse inputs
|
# parse inputs
|
||||||
my $_resource_path = '/store/order';
|
my $_resource_path = '/store/order';
|
||||||
|
|
||||||
my $_method = 'POST';
|
my $_method = 'POST';
|
||||||
my $query_params = {};
|
my $query_params = {};
|
||||||
my $header_params = {};
|
my $header_params = {};
|
||||||
my $form_params = {};
|
my $form_params = {};
|
||||||
|
|
||||||
# 'Accept' and 'Content-Type' header
|
# 'Accept' and 'Content-Type' header
|
||||||
my $_header_accept = $self->{api_client}
|
my $_header_accept = $self->{api_client}->select_header_accept('application/xml', 'application/json');
|
||||||
->select_header_accept( 'application/xml', 'application/json' );
|
|
||||||
if ($_header_accept) {
|
if ($_header_accept) {
|
||||||
$header_params->{'Accept'} = $_header_accept;
|
$header_params->{'Accept'} = $_header_accept;
|
||||||
}
|
}
|
||||||
$header_params->{'Content-Type'} =
|
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||||
$self->{api_client}->select_header_content_type();
|
|
||||||
|
|
||||||
my $_body_data;
|
my $_body_data;
|
||||||
|
|
||||||
# body params
|
# body params
|
||||||
if ( exists $args{'order'} ) {
|
if ( exists $args{'order'}) {
|
||||||
$_body_data = $args{'order'};
|
$_body_data = $args{'order'};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -309,15 +282,13 @@ sub place_order {
|
|||||||
my $auth_settings = [qw()];
|
my $auth_settings = [qw()];
|
||||||
|
|
||||||
# make the API Call
|
# make the API Call
|
||||||
my $response = $self->{api_client}->call_api(
|
my $response = $self->{api_client}->call_api($_resource_path, $_method,
|
||||||
$_resource_path, $_method, $query_params, $form_params,
|
$query_params, $form_params,
|
||||||
$header_params, $_body_data, $auth_settings
|
$header_params, $_body_data, $auth_settings);
|
||||||
);
|
if (!$response) {
|
||||||
if ( !$response ) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
my $_response_object =
|
my $_response_object = $self->{api_client}->deserialize('Order', $response);
|
||||||
$self->{api_client}->deserialize( 'Order', $response );
|
|
||||||
return $_response_object;
|
return $_response_object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
=begin comment
|
=begin comment
|
||||||
|
|
||||||
OpenAPI Petstore
|
OpenAPI Petstore
|
||||||
@@ -23,7 +22,7 @@ package WWW::OpenAPIClient::UserApi;
|
|||||||
require 5.6.0;
|
require 5.6.0;
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use utf8;
|
use utf8;
|
||||||
use Exporter;
|
use Exporter;
|
||||||
use Carp qw( croak );
|
use Carp qw( croak );
|
||||||
use Log::Any qw($log);
|
use Log::Any qw($log);
|
||||||
@@ -32,16 +31,15 @@ use WWW::OpenAPIClient::ApiClient;
|
|||||||
|
|
||||||
use base "Class::Data::Inheritable";
|
use base "Class::Data::Inheritable";
|
||||||
|
|
||||||
__PACKAGE__->mk_classdata( 'method_documentation' => {} );
|
__PACKAGE__->mk_classdata('method_documentation' => {});
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my $class = shift;
|
my $class = shift;
|
||||||
my $api_client;
|
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];
|
$api_client = $_[0];
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$api_client = WWW::OpenAPIClient::ApiClient->new(@_);
|
$api_client = WWW::OpenAPIClient::ApiClient->new(@_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,57 +47,55 @@ sub new {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# create_user
|
# create_user
|
||||||
#
|
#
|
||||||
# Create user
|
# Create user
|
||||||
#
|
#
|
||||||
# @param User $user Created user object (required)
|
# @param User $user Created user object (required)
|
||||||
{
|
{
|
||||||
my $params = {
|
my $params = {
|
||||||
'user' => {
|
'user' => {
|
||||||
data_type => 'User',
|
data_type => 'User',
|
||||||
description => 'Created user object',
|
description => 'Created user object',
|
||||||
required => '1',
|
required => '1',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
__PACKAGE__->method_documentation->{'create_user'} = {
|
__PACKAGE__->method_documentation->{ 'create_user' } = {
|
||||||
summary => 'Create user',
|
summary => 'Create user',
|
||||||
params => $params,
|
params => $params,
|
||||||
returns => undef,
|
returns => undef,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
# @return void
|
# @return void
|
||||||
#
|
#
|
||||||
sub create_user {
|
sub create_user {
|
||||||
my ( $self, %args ) = @_;
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
# verify the required parameter 'user' is set
|
# verify the required parameter 'user' is set
|
||||||
unless ( exists $args{'user'} ) {
|
unless (exists $args{'user'}) {
|
||||||
croak("Missing the required parameter 'user' when calling create_user");
|
croak("Missing the required parameter 'user' when calling create_user");
|
||||||
}
|
}
|
||||||
|
|
||||||
# parse inputs
|
# parse inputs
|
||||||
my $_resource_path = '/user';
|
my $_resource_path = '/user';
|
||||||
|
|
||||||
my $_method = 'POST';
|
my $_method = 'POST';
|
||||||
my $query_params = {};
|
my $query_params = {};
|
||||||
my $header_params = {};
|
my $header_params = {};
|
||||||
my $form_params = {};
|
my $form_params = {};
|
||||||
|
|
||||||
# 'Accept' and 'Content-Type' header
|
# 'Accept' and 'Content-Type' header
|
||||||
my $_header_accept = $self->{api_client}->select_header_accept();
|
my $_header_accept = $self->{api_client}->select_header_accept();
|
||||||
if ($_header_accept) {
|
if ($_header_accept) {
|
||||||
$header_params->{'Accept'} = $_header_accept;
|
$header_params->{'Accept'} = $_header_accept;
|
||||||
}
|
}
|
||||||
$header_params->{'Content-Type'} =
|
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||||
$self->{api_client}->select_header_content_type();
|
|
||||||
|
|
||||||
my $_body_data;
|
my $_body_data;
|
||||||
|
|
||||||
# body params
|
# body params
|
||||||
if ( exists $args{'user'} ) {
|
if ( exists $args{'user'}) {
|
||||||
$_body_data = $args{'user'};
|
$_body_data = $args{'user'};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,10 +103,9 @@ sub create_user {
|
|||||||
my $auth_settings = [qw()];
|
my $auth_settings = [qw()];
|
||||||
|
|
||||||
# make the API Call
|
# make the API Call
|
||||||
$self->{api_client}->call_api(
|
$self->{api_client}->call_api($_resource_path, $_method,
|
||||||
$_resource_path, $_method, $query_params, $form_params,
|
$query_params, $form_params,
|
||||||
$header_params, $_body_data, $auth_settings
|
$header_params, $_body_data, $auth_settings);
|
||||||
);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,55 +113,50 @@ sub create_user {
|
|||||||
# create_users_with_array_input
|
# create_users_with_array_input
|
||||||
#
|
#
|
||||||
# Creates list of users with given input array
|
# Creates list of users with given input array
|
||||||
#
|
#
|
||||||
# @param ARRAY[User] $user List of user object (required)
|
# @param ARRAY[User] $user List of user object (required)
|
||||||
{
|
{
|
||||||
my $params = {
|
my $params = {
|
||||||
'user' => {
|
'user' => {
|
||||||
data_type => 'ARRAY[User]',
|
data_type => 'ARRAY[User]',
|
||||||
description => 'List of user object',
|
description => 'List of user object',
|
||||||
required => '1',
|
required => '1',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
__PACKAGE__->method_documentation->{'create_users_with_array_input'} = {
|
__PACKAGE__->method_documentation->{ 'create_users_with_array_input' } = {
|
||||||
summary => 'Creates list of users with given input array',
|
summary => 'Creates list of users with given input array',
|
||||||
params => $params,
|
params => $params,
|
||||||
returns => undef,
|
returns => undef,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
# @return void
|
# @return void
|
||||||
#
|
#
|
||||||
sub create_users_with_array_input {
|
sub create_users_with_array_input {
|
||||||
my ( $self, %args ) = @_;
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
# verify the required parameter 'user' is set
|
# verify the required parameter 'user' is set
|
||||||
unless ( exists $args{'user'} ) {
|
unless (exists $args{'user'}) {
|
||||||
croak(
|
croak("Missing the required parameter 'user' when calling create_users_with_array_input");
|
||||||
"Missing the required parameter 'user' when calling create_users_with_array_input"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# parse inputs
|
# parse inputs
|
||||||
my $_resource_path = '/user/createWithArray';
|
my $_resource_path = '/user/createWithArray';
|
||||||
|
|
||||||
my $_method = 'POST';
|
my $_method = 'POST';
|
||||||
my $query_params = {};
|
my $query_params = {};
|
||||||
my $header_params = {};
|
my $header_params = {};
|
||||||
my $form_params = {};
|
my $form_params = {};
|
||||||
|
|
||||||
# 'Accept' and 'Content-Type' header
|
# 'Accept' and 'Content-Type' header
|
||||||
my $_header_accept = $self->{api_client}->select_header_accept();
|
my $_header_accept = $self->{api_client}->select_header_accept();
|
||||||
if ($_header_accept) {
|
if ($_header_accept) {
|
||||||
$header_params->{'Accept'} = $_header_accept;
|
$header_params->{'Accept'} = $_header_accept;
|
||||||
}
|
}
|
||||||
$header_params->{'Content-Type'} =
|
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||||
$self->{api_client}->select_header_content_type();
|
|
||||||
|
|
||||||
my $_body_data;
|
my $_body_data;
|
||||||
|
|
||||||
# body params
|
# body params
|
||||||
if ( exists $args{'user'} ) {
|
if ( exists $args{'user'}) {
|
||||||
$_body_data = $args{'user'};
|
$_body_data = $args{'user'};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,10 +164,9 @@ sub create_users_with_array_input {
|
|||||||
my $auth_settings = [qw()];
|
my $auth_settings = [qw()];
|
||||||
|
|
||||||
# make the API Call
|
# make the API Call
|
||||||
$self->{api_client}->call_api(
|
$self->{api_client}->call_api($_resource_path, $_method,
|
||||||
$_resource_path, $_method, $query_params, $form_params,
|
$query_params, $form_params,
|
||||||
$header_params, $_body_data, $auth_settings
|
$header_params, $_body_data, $auth_settings);
|
||||||
);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,55 +174,50 @@ sub create_users_with_array_input {
|
|||||||
# create_users_with_list_input
|
# create_users_with_list_input
|
||||||
#
|
#
|
||||||
# Creates list of users with given input array
|
# Creates list of users with given input array
|
||||||
#
|
#
|
||||||
# @param ARRAY[User] $user List of user object (required)
|
# @param ARRAY[User] $user List of user object (required)
|
||||||
{
|
{
|
||||||
my $params = {
|
my $params = {
|
||||||
'user' => {
|
'user' => {
|
||||||
data_type => 'ARRAY[User]',
|
data_type => 'ARRAY[User]',
|
||||||
description => 'List of user object',
|
description => 'List of user object',
|
||||||
required => '1',
|
required => '1',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
__PACKAGE__->method_documentation->{'create_users_with_list_input'} = {
|
__PACKAGE__->method_documentation->{ 'create_users_with_list_input' } = {
|
||||||
summary => 'Creates list of users with given input array',
|
summary => 'Creates list of users with given input array',
|
||||||
params => $params,
|
params => $params,
|
||||||
returns => undef,
|
returns => undef,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
# @return void
|
# @return void
|
||||||
#
|
#
|
||||||
sub create_users_with_list_input {
|
sub create_users_with_list_input {
|
||||||
my ( $self, %args ) = @_;
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
# verify the required parameter 'user' is set
|
# verify the required parameter 'user' is set
|
||||||
unless ( exists $args{'user'} ) {
|
unless (exists $args{'user'}) {
|
||||||
croak(
|
croak("Missing the required parameter 'user' when calling create_users_with_list_input");
|
||||||
"Missing the required parameter 'user' when calling create_users_with_list_input"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# parse inputs
|
# parse inputs
|
||||||
my $_resource_path = '/user/createWithList';
|
my $_resource_path = '/user/createWithList';
|
||||||
|
|
||||||
my $_method = 'POST';
|
my $_method = 'POST';
|
||||||
my $query_params = {};
|
my $query_params = {};
|
||||||
my $header_params = {};
|
my $header_params = {};
|
||||||
my $form_params = {};
|
my $form_params = {};
|
||||||
|
|
||||||
# 'Accept' and 'Content-Type' header
|
# 'Accept' and 'Content-Type' header
|
||||||
my $_header_accept = $self->{api_client}->select_header_accept();
|
my $_header_accept = $self->{api_client}->select_header_accept();
|
||||||
if ($_header_accept) {
|
if ($_header_accept) {
|
||||||
$header_params->{'Accept'} = $_header_accept;
|
$header_params->{'Accept'} = $_header_accept;
|
||||||
}
|
}
|
||||||
$header_params->{'Content-Type'} =
|
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||||
$self->{api_client}->select_header_content_type();
|
|
||||||
|
|
||||||
my $_body_data;
|
my $_body_data;
|
||||||
|
|
||||||
# body params
|
# body params
|
||||||
if ( exists $args{'user'} ) {
|
if ( exists $args{'user'}) {
|
||||||
$_body_data = $args{'user'};
|
$_body_data = $args{'user'};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,10 +225,9 @@ sub create_users_with_list_input {
|
|||||||
my $auth_settings = [qw()];
|
my $auth_settings = [qw()];
|
||||||
|
|
||||||
# make the API Call
|
# make the API Call
|
||||||
$self->{api_client}->call_api(
|
$self->{api_client}->call_api($_resource_path, $_method,
|
||||||
$_resource_path, $_method, $query_params, $form_params,
|
$query_params, $form_params,
|
||||||
$header_params, $_body_data, $auth_settings
|
$header_params, $_body_data, $auth_settings);
|
||||||
);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,69 +235,62 @@ sub create_users_with_list_input {
|
|||||||
# delete_user
|
# delete_user
|
||||||
#
|
#
|
||||||
# Delete user
|
# Delete user
|
||||||
#
|
#
|
||||||
# @param string $username The name that needs to be deleted (required)
|
# @param string $username The name that needs to be deleted (required)
|
||||||
{
|
{
|
||||||
my $params = {
|
my $params = {
|
||||||
'username' => {
|
'username' => {
|
||||||
data_type => 'string',
|
data_type => 'string',
|
||||||
description => 'The name that needs to be deleted',
|
description => 'The name that needs to be deleted',
|
||||||
required => '1',
|
required => '1',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
__PACKAGE__->method_documentation->{'delete_user'} = {
|
__PACKAGE__->method_documentation->{ 'delete_user' } = {
|
||||||
summary => 'Delete user',
|
summary => 'Delete user',
|
||||||
params => $params,
|
params => $params,
|
||||||
returns => undef,
|
returns => undef,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
# @return void
|
# @return void
|
||||||
#
|
#
|
||||||
sub delete_user {
|
sub delete_user {
|
||||||
my ( $self, %args ) = @_;
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
# verify the required parameter 'username' is set
|
# verify the required parameter 'username' is set
|
||||||
unless ( exists $args{'username'} ) {
|
unless (exists $args{'username'}) {
|
||||||
croak(
|
croak("Missing the required parameter 'username' when calling delete_user");
|
||||||
"Missing the required parameter 'username' when calling delete_user"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# parse inputs
|
# parse inputs
|
||||||
my $_resource_path = '/user/{username}';
|
my $_resource_path = '/user/{username}';
|
||||||
|
|
||||||
my $_method = 'DELETE';
|
my $_method = 'DELETE';
|
||||||
my $query_params = {};
|
my $query_params = {};
|
||||||
my $header_params = {};
|
my $header_params = {};
|
||||||
my $form_params = {};
|
my $form_params = {};
|
||||||
|
|
||||||
# 'Accept' and 'Content-Type' header
|
# 'Accept' and 'Content-Type' header
|
||||||
my $_header_accept = $self->{api_client}->select_header_accept();
|
my $_header_accept = $self->{api_client}->select_header_accept();
|
||||||
if ($_header_accept) {
|
if ($_header_accept) {
|
||||||
$header_params->{'Accept'} = $_header_accept;
|
$header_params->{'Accept'} = $_header_accept;
|
||||||
}
|
}
|
||||||
$header_params->{'Content-Type'} =
|
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||||
$self->{api_client}->select_header_content_type();
|
|
||||||
|
|
||||||
# path params
|
# path params
|
||||||
if ( exists $args{'username'} ) {
|
if ( exists $args{'username'}) {
|
||||||
my $_base_variable = "{" . "username" . "}";
|
my $_base_variable = "{" . "username" . "}";
|
||||||
my $_base_value =
|
my $_base_value = $self->{api_client}->to_path_value($args{'username'});
|
||||||
$self->{api_client}->to_path_value( $args{'username'} );
|
|
||||||
$_resource_path =~ s/$_base_variable/$_base_value/g;
|
$_resource_path =~ s/$_base_variable/$_base_value/g;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $_body_data;
|
my $_body_data;
|
||||||
|
|
||||||
# authentication setting, if any
|
# authentication setting, if any
|
||||||
my $auth_settings = [qw()];
|
my $auth_settings = [qw()];
|
||||||
|
|
||||||
# make the API Call
|
# make the API Call
|
||||||
$self->{api_client}->call_api(
|
$self->{api_client}->call_api($_resource_path, $_method,
|
||||||
$_resource_path, $_method, $query_params, $form_params,
|
$query_params, $form_params,
|
||||||
$header_params, $_body_data, $auth_settings
|
$header_params, $_body_data, $auth_settings);
|
||||||
);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -322,76 +298,66 @@ sub delete_user {
|
|||||||
# get_user_by_name
|
# get_user_by_name
|
||||||
#
|
#
|
||||||
# Get user by user name
|
# Get user by user name
|
||||||
#
|
#
|
||||||
# @param string $username The name that needs to be fetched. Use user1 for testing. (required)
|
# @param string $username The name that needs to be fetched. Use user1 for testing. (required)
|
||||||
{
|
{
|
||||||
my $params = {
|
my $params = {
|
||||||
'username' => {
|
'username' => {
|
||||||
data_type => 'string',
|
data_type => 'string',
|
||||||
description =>
|
description => 'The name that needs to be fetched. Use user1 for testing.',
|
||||||
'The name that needs to be fetched. Use user1 for testing.',
|
required => '1',
|
||||||
required => '1',
|
},
|
||||||
},
|
|
||||||
};
|
};
|
||||||
__PACKAGE__->method_documentation->{'get_user_by_name'} = {
|
__PACKAGE__->method_documentation->{ 'get_user_by_name' } = {
|
||||||
summary => 'Get user by user name',
|
summary => 'Get user by user name',
|
||||||
params => $params,
|
params => $params,
|
||||||
returns => 'User',
|
returns => 'User',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
# @return User
|
# @return User
|
||||||
#
|
#
|
||||||
sub get_user_by_name {
|
sub get_user_by_name {
|
||||||
my ( $self, %args ) = @_;
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
# verify the required parameter 'username' is set
|
# verify the required parameter 'username' is set
|
||||||
unless ( exists $args{'username'} ) {
|
unless (exists $args{'username'}) {
|
||||||
croak(
|
croak("Missing the required parameter 'username' when calling get_user_by_name");
|
||||||
"Missing the required parameter 'username' when calling get_user_by_name"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# parse inputs
|
# parse inputs
|
||||||
my $_resource_path = '/user/{username}';
|
my $_resource_path = '/user/{username}';
|
||||||
|
|
||||||
my $_method = 'GET';
|
my $_method = 'GET';
|
||||||
my $query_params = {};
|
my $query_params = {};
|
||||||
my $header_params = {};
|
my $header_params = {};
|
||||||
my $form_params = {};
|
my $form_params = {};
|
||||||
|
|
||||||
# 'Accept' and 'Content-Type' header
|
# 'Accept' and 'Content-Type' header
|
||||||
my $_header_accept = $self->{api_client}
|
my $_header_accept = $self->{api_client}->select_header_accept('application/xml', 'application/json');
|
||||||
->select_header_accept( 'application/xml', 'application/json' );
|
|
||||||
if ($_header_accept) {
|
if ($_header_accept) {
|
||||||
$header_params->{'Accept'} = $_header_accept;
|
$header_params->{'Accept'} = $_header_accept;
|
||||||
}
|
}
|
||||||
$header_params->{'Content-Type'} =
|
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||||
$self->{api_client}->select_header_content_type();
|
|
||||||
|
|
||||||
# path params
|
# path params
|
||||||
if ( exists $args{'username'} ) {
|
if ( exists $args{'username'}) {
|
||||||
my $_base_variable = "{" . "username" . "}";
|
my $_base_variable = "{" . "username" . "}";
|
||||||
my $_base_value =
|
my $_base_value = $self->{api_client}->to_path_value($args{'username'});
|
||||||
$self->{api_client}->to_path_value( $args{'username'} );
|
|
||||||
$_resource_path =~ s/$_base_variable/$_base_value/g;
|
$_resource_path =~ s/$_base_variable/$_base_value/g;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $_body_data;
|
my $_body_data;
|
||||||
|
|
||||||
# authentication setting, if any
|
# authentication setting, if any
|
||||||
my $auth_settings = [qw()];
|
my $auth_settings = [qw()];
|
||||||
|
|
||||||
# make the API Call
|
# make the API Call
|
||||||
my $response = $self->{api_client}->call_api(
|
my $response = $self->{api_client}->call_api($_resource_path, $_method,
|
||||||
$_resource_path, $_method, $query_params, $form_params,
|
$query_params, $form_params,
|
||||||
$header_params, $_body_data, $auth_settings
|
$header_params, $_body_data, $auth_settings);
|
||||||
);
|
if (!$response) {
|
||||||
if ( !$response ) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
my $_response_object =
|
my $_response_object = $self->{api_client}->deserialize('User', $response);
|
||||||
$self->{api_client}->deserialize( 'User', $response );
|
|
||||||
return $_response_object;
|
return $_response_object;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -399,92 +365,80 @@ sub get_user_by_name {
|
|||||||
# login_user
|
# login_user
|
||||||
#
|
#
|
||||||
# Logs user into the system
|
# Logs user into the system
|
||||||
#
|
#
|
||||||
# @param string $username The user name for login (required)
|
# @param string $username The user name for login (required)
|
||||||
# @param string $password The password for login in clear text (required)
|
# @param string $password The password for login in clear text (required)
|
||||||
{
|
{
|
||||||
my $params = {
|
my $params = {
|
||||||
'username' => {
|
'username' => {
|
||||||
data_type => 'string',
|
data_type => 'string',
|
||||||
description => 'The user name for login',
|
description => 'The user name for login',
|
||||||
required => '1',
|
required => '1',
|
||||||
},
|
},
|
||||||
'password' => {
|
'password' => {
|
||||||
data_type => 'string',
|
data_type => 'string',
|
||||||
description => 'The password for login in clear text',
|
description => 'The password for login in clear text',
|
||||||
required => '1',
|
required => '1',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
__PACKAGE__->method_documentation->{'login_user'} = {
|
__PACKAGE__->method_documentation->{ 'login_user' } = {
|
||||||
summary => 'Logs user into the system',
|
summary => 'Logs user into the system',
|
||||||
params => $params,
|
params => $params,
|
||||||
returns => 'string',
|
returns => 'string',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
# @return string
|
# @return string
|
||||||
#
|
#
|
||||||
sub login_user {
|
sub login_user {
|
||||||
my ( $self, %args ) = @_;
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
# verify the required parameter 'username' is set
|
# verify the required parameter 'username' is set
|
||||||
unless ( exists $args{'username'} ) {
|
unless (exists $args{'username'}) {
|
||||||
croak(
|
croak("Missing the required parameter 'username' when calling login_user");
|
||||||
"Missing the required parameter 'username' when calling login_user"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# verify the required parameter 'password' is set
|
# verify the required parameter 'password' is set
|
||||||
unless ( exists $args{'password'} ) {
|
unless (exists $args{'password'}) {
|
||||||
croak(
|
croak("Missing the required parameter 'password' when calling login_user");
|
||||||
"Missing the required parameter 'password' when calling login_user"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# parse inputs
|
# parse inputs
|
||||||
my $_resource_path = '/user/login';
|
my $_resource_path = '/user/login';
|
||||||
|
|
||||||
my $_method = 'GET';
|
my $_method = 'GET';
|
||||||
my $query_params = {};
|
my $query_params = {};
|
||||||
my $header_params = {};
|
my $header_params = {};
|
||||||
my $form_params = {};
|
my $form_params = {};
|
||||||
|
|
||||||
# 'Accept' and 'Content-Type' header
|
# 'Accept' and 'Content-Type' header
|
||||||
my $_header_accept = $self->{api_client}
|
my $_header_accept = $self->{api_client}->select_header_accept('application/xml', 'application/json');
|
||||||
->select_header_accept( 'application/xml', 'application/json' );
|
|
||||||
if ($_header_accept) {
|
if ($_header_accept) {
|
||||||
$header_params->{'Accept'} = $_header_accept;
|
$header_params->{'Accept'} = $_header_accept;
|
||||||
}
|
}
|
||||||
$header_params->{'Content-Type'} =
|
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||||
$self->{api_client}->select_header_content_type();
|
|
||||||
|
|
||||||
# query params
|
# query params
|
||||||
if ( exists $args{'username'} ) {
|
if ( exists $args{'username'}) {
|
||||||
$query_params->{'username'} =
|
$query_params->{'username'} = $self->{api_client}->to_query_value($args{'username'});
|
||||||
$self->{api_client}->to_query_value( $args{'username'} );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# query params
|
# query params
|
||||||
if ( exists $args{'password'} ) {
|
if ( exists $args{'password'}) {
|
||||||
$query_params->{'password'} =
|
$query_params->{'password'} = $self->{api_client}->to_query_value($args{'password'});
|
||||||
$self->{api_client}->to_query_value( $args{'password'} );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
my $_body_data;
|
my $_body_data;
|
||||||
|
|
||||||
# authentication setting, if any
|
# authentication setting, if any
|
||||||
my $auth_settings = [qw()];
|
my $auth_settings = [qw()];
|
||||||
|
|
||||||
# make the API Call
|
# make the API Call
|
||||||
my $response = $self->{api_client}->call_api(
|
my $response = $self->{api_client}->call_api($_resource_path, $_method,
|
||||||
$_resource_path, $_method, $query_params, $form_params,
|
$query_params, $form_params,
|
||||||
$header_params, $_body_data, $auth_settings
|
$header_params, $_body_data, $auth_settings);
|
||||||
);
|
if (!$response) {
|
||||||
if ( !$response ) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
my $_response_object =
|
my $_response_object = $self->{api_client}->deserialize('string', $response);
|
||||||
$self->{api_client}->deserialize( 'string', $response );
|
|
||||||
return $_response_object;
|
return $_response_object;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -492,47 +446,44 @@ sub login_user {
|
|||||||
# logout_user
|
# logout_user
|
||||||
#
|
#
|
||||||
# Logs out current logged in user session
|
# Logs out current logged in user session
|
||||||
#
|
#
|
||||||
{
|
{
|
||||||
my $params = {};
|
my $params = {
|
||||||
__PACKAGE__->method_documentation->{'logout_user'} = {
|
|
||||||
summary => 'Logs out current logged in user session',
|
|
||||||
params => $params,
|
|
||||||
returns => undef,
|
|
||||||
};
|
};
|
||||||
|
__PACKAGE__->method_documentation->{ 'logout_user' } = {
|
||||||
|
summary => 'Logs out current logged in user session',
|
||||||
|
params => $params,
|
||||||
|
returns => undef,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
# @return void
|
# @return void
|
||||||
#
|
#
|
||||||
sub logout_user {
|
sub logout_user {
|
||||||
my ( $self, %args ) = @_;
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
# parse inputs
|
# parse inputs
|
||||||
my $_resource_path = '/user/logout';
|
my $_resource_path = '/user/logout';
|
||||||
|
|
||||||
my $_method = 'GET';
|
my $_method = 'GET';
|
||||||
my $query_params = {};
|
my $query_params = {};
|
||||||
my $header_params = {};
|
my $header_params = {};
|
||||||
my $form_params = {};
|
my $form_params = {};
|
||||||
|
|
||||||
# 'Accept' and 'Content-Type' header
|
# 'Accept' and 'Content-Type' header
|
||||||
my $_header_accept = $self->{api_client}->select_header_accept();
|
my $_header_accept = $self->{api_client}->select_header_accept();
|
||||||
if ($_header_accept) {
|
if ($_header_accept) {
|
||||||
$header_params->{'Accept'} = $_header_accept;
|
$header_params->{'Accept'} = $_header_accept;
|
||||||
}
|
}
|
||||||
$header_params->{'Content-Type'} =
|
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||||
$self->{api_client}->select_header_content_type();
|
|
||||||
|
|
||||||
my $_body_data;
|
my $_body_data;
|
||||||
|
|
||||||
# authentication setting, if any
|
# authentication setting, if any
|
||||||
my $auth_settings = [qw()];
|
my $auth_settings = [qw()];
|
||||||
|
|
||||||
# make the API Call
|
# make the API Call
|
||||||
$self->{api_client}->call_api(
|
$self->{api_client}->call_api($_resource_path, $_method,
|
||||||
$_resource_path, $_method, $query_params, $form_params,
|
$query_params, $form_params,
|
||||||
$header_params, $_body_data, $auth_settings
|
$header_params, $_body_data, $auth_settings);
|
||||||
);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -540,74 +491,68 @@ sub logout_user {
|
|||||||
# update_user
|
# update_user
|
||||||
#
|
#
|
||||||
# Updated user
|
# Updated user
|
||||||
#
|
#
|
||||||
# @param string $username name that need to be deleted (required)
|
# @param string $username name that need to be deleted (required)
|
||||||
# @param User $user Updated user object (required)
|
# @param User $user Updated user object (required)
|
||||||
{
|
{
|
||||||
my $params = {
|
my $params = {
|
||||||
'username' => {
|
'username' => {
|
||||||
data_type => 'string',
|
data_type => 'string',
|
||||||
description => 'name that need to be deleted',
|
description => 'name that need to be deleted',
|
||||||
required => '1',
|
required => '1',
|
||||||
},
|
},
|
||||||
'user' => {
|
'user' => {
|
||||||
data_type => 'User',
|
data_type => 'User',
|
||||||
description => 'Updated user object',
|
description => 'Updated user object',
|
||||||
required => '1',
|
required => '1',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
__PACKAGE__->method_documentation->{'update_user'} = {
|
__PACKAGE__->method_documentation->{ 'update_user' } = {
|
||||||
summary => 'Updated user',
|
summary => 'Updated user',
|
||||||
params => $params,
|
params => $params,
|
||||||
returns => undef,
|
returns => undef,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
# @return void
|
# @return void
|
||||||
#
|
#
|
||||||
sub update_user {
|
sub update_user {
|
||||||
my ( $self, %args ) = @_;
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
# verify the required parameter 'username' is set
|
# verify the required parameter 'username' is set
|
||||||
unless ( exists $args{'username'} ) {
|
unless (exists $args{'username'}) {
|
||||||
croak(
|
croak("Missing the required parameter 'username' when calling update_user");
|
||||||
"Missing the required parameter 'username' when calling update_user"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# verify the required parameter 'user' is set
|
# verify the required parameter 'user' is set
|
||||||
unless ( exists $args{'user'} ) {
|
unless (exists $args{'user'}) {
|
||||||
croak("Missing the required parameter 'user' when calling update_user");
|
croak("Missing the required parameter 'user' when calling update_user");
|
||||||
}
|
}
|
||||||
|
|
||||||
# parse inputs
|
# parse inputs
|
||||||
my $_resource_path = '/user/{username}';
|
my $_resource_path = '/user/{username}';
|
||||||
|
|
||||||
my $_method = 'PUT';
|
my $_method = 'PUT';
|
||||||
my $query_params = {};
|
my $query_params = {};
|
||||||
my $header_params = {};
|
my $header_params = {};
|
||||||
my $form_params = {};
|
my $form_params = {};
|
||||||
|
|
||||||
# 'Accept' and 'Content-Type' header
|
# 'Accept' and 'Content-Type' header
|
||||||
my $_header_accept = $self->{api_client}->select_header_accept();
|
my $_header_accept = $self->{api_client}->select_header_accept();
|
||||||
if ($_header_accept) {
|
if ($_header_accept) {
|
||||||
$header_params->{'Accept'} = $_header_accept;
|
$header_params->{'Accept'} = $_header_accept;
|
||||||
}
|
}
|
||||||
$header_params->{'Content-Type'} =
|
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
|
||||||
$self->{api_client}->select_header_content_type();
|
|
||||||
|
|
||||||
# path params
|
# path params
|
||||||
if ( exists $args{'username'} ) {
|
if ( exists $args{'username'}) {
|
||||||
my $_base_variable = "{" . "username" . "}";
|
my $_base_variable = "{" . "username" . "}";
|
||||||
my $_base_value =
|
my $_base_value = $self->{api_client}->to_path_value($args{'username'});
|
||||||
$self->{api_client}->to_path_value( $args{'username'} );
|
|
||||||
$_resource_path =~ s/$_base_variable/$_base_value/g;
|
$_resource_path =~ s/$_base_variable/$_base_value/g;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $_body_data;
|
my $_body_data;
|
||||||
|
|
||||||
# body params
|
# body params
|
||||||
if ( exists $args{'user'} ) {
|
if ( exists $args{'user'}) {
|
||||||
$_body_data = $args{'user'};
|
$_body_data = $args{'user'};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -615,10 +560,9 @@ sub update_user {
|
|||||||
my $auth_settings = [qw()];
|
my $auth_settings = [qw()];
|
||||||
|
|
||||||
# make the API Call
|
# make the API Call
|
||||||
$self->{api_client}->call_api(
|
$self->{api_client}->call_api($_resource_path, $_method,
|
||||||
$_resource_path, $_method, $query_params, $form_params,
|
$query_params, $form_params,
|
||||||
$header_params, $_body_data, $auth_settings
|
$header_params, $_body_data, $auth_settings);
|
||||||
);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -78,6 +78,19 @@
|
|||||||
</arguments>
|
</arguments>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
|
<!--<execution>
|
||||||
|
<id>Test::More for Inheritance</id>
|
||||||
|
<phase>integration-test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>exec</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<executable>perl</executable>
|
||||||
|
<arguments>
|
||||||
|
<argument>tests/06_inheritance.t</argument>
|
||||||
|
</arguments>
|
||||||
|
</configuration>
|
||||||
|
</execution>-->
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
|
|||||||
33
samples/client/petstore/perl/t/AdultTest.t
Normal file
33
samples/client/petstore/perl/t/AdultTest.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::Adult');
|
||||||
|
|
||||||
|
my $instance = WWW::OpenAPIClient::Object::Adult->new();
|
||||||
|
|
||||||
|
isa_ok($instance, 'WWW::OpenAPIClient::Object::Adult');
|
||||||
|
|
||||||
33
samples/client/petstore/perl/t/ChildTest.t
Normal file
33
samples/client/petstore/perl/t/ChildTest.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::Child');
|
||||||
|
|
||||||
|
my $instance = WWW::OpenAPIClient::Object::Child->new();
|
||||||
|
|
||||||
|
isa_ok($instance, 'WWW::OpenAPIClient::Object::Child');
|
||||||
|
|
||||||
40
samples/client/petstore/perl/t/DefaultApiTest.t
Normal file
40
samples/client/petstore/perl/t/DefaultApiTest.t
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
=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
|
||||||
|
# Please update the test cases below to test the API endpoints.
|
||||||
|
# Ref: https://openapi-generator.tech
|
||||||
|
#
|
||||||
|
use Test::More tests => 1; #TODO update number of test cases
|
||||||
|
use Test::Exception;
|
||||||
|
|
||||||
|
use lib 'lib';
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
|
use_ok('WWW::OpenAPIClient::DefaultApi');
|
||||||
|
|
||||||
|
my $api = WWW::OpenAPIClient::DefaultApi->new();
|
||||||
|
isa_ok($api, 'WWW::OpenAPIClient::DefaultApi');
|
||||||
|
|
||||||
|
#
|
||||||
|
# foo_get test
|
||||||
|
#
|
||||||
|
{
|
||||||
|
my $result = $api->foo_get();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
1;
|
||||||
33
samples/client/petstore/perl/t/FooTest.t
Normal file
33
samples/client/petstore/perl/t/FooTest.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::Foo');
|
||||||
|
|
||||||
|
my $instance = WWW::OpenAPIClient::Object::Foo->new();
|
||||||
|
|
||||||
|
isa_ok($instance, 'WWW::OpenAPIClient::Object::Foo');
|
||||||
|
|
||||||
33
samples/client/petstore/perl/t/HumanTest.t
Normal file
33
samples/client/petstore/perl/t/HumanTest.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::Human');
|
||||||
|
|
||||||
|
my $instance = WWW::OpenAPIClient::Object::Human->new();
|
||||||
|
|
||||||
|
isa_ok($instance, 'WWW::OpenAPIClient::Object::Human');
|
||||||
|
|
||||||
33
samples/client/petstore/perl/t/InlineObject1Test.t
Normal file
33
samples/client/petstore/perl/t/InlineObject1Test.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::InlineObject1');
|
||||||
|
|
||||||
|
my $instance = WWW::OpenAPIClient::Object::InlineObject1->new();
|
||||||
|
|
||||||
|
isa_ok($instance, 'WWW::OpenAPIClient::Object::InlineObject1');
|
||||||
|
|
||||||
33
samples/client/petstore/perl/t/InlineObject2Test.t
Normal file
33
samples/client/petstore/perl/t/InlineObject2Test.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::InlineObject2');
|
||||||
|
|
||||||
|
my $instance = WWW::OpenAPIClient::Object::InlineObject2->new();
|
||||||
|
|
||||||
|
isa_ok($instance, 'WWW::OpenAPIClient::Object::InlineObject2');
|
||||||
|
|
||||||
33
samples/client/petstore/perl/t/InlineObject3Test.t
Normal file
33
samples/client/petstore/perl/t/InlineObject3Test.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::InlineObject3');
|
||||||
|
|
||||||
|
my $instance = WWW::OpenAPIClient::Object::InlineObject3->new();
|
||||||
|
|
||||||
|
isa_ok($instance, 'WWW::OpenAPIClient::Object::InlineObject3');
|
||||||
|
|
||||||
33
samples/client/petstore/perl/t/InlineObject4Test.t
Normal file
33
samples/client/petstore/perl/t/InlineObject4Test.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::InlineObject4');
|
||||||
|
|
||||||
|
my $instance = WWW::OpenAPIClient::Object::InlineObject4->new();
|
||||||
|
|
||||||
|
isa_ok($instance, 'WWW::OpenAPIClient::Object::InlineObject4');
|
||||||
|
|
||||||
33
samples/client/petstore/perl/t/InlineObject5Test.t
Normal file
33
samples/client/petstore/perl/t/InlineObject5Test.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::InlineObject5');
|
||||||
|
|
||||||
|
my $instance = WWW::OpenAPIClient::Object::InlineObject5->new();
|
||||||
|
|
||||||
|
isa_ok($instance, 'WWW::OpenAPIClient::Object::InlineObject5');
|
||||||
|
|
||||||
33
samples/client/petstore/perl/t/InlineObjectTest.t
Normal file
33
samples/client/petstore/perl/t/InlineObjectTest.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::InlineObject');
|
||||||
|
|
||||||
|
my $instance = WWW::OpenAPIClient::Object::InlineObject->new();
|
||||||
|
|
||||||
|
isa_ok($instance, 'WWW::OpenAPIClient::Object::InlineObject');
|
||||||
|
|
||||||
33
samples/client/petstore/perl/t/InlineResponseDefaultTest.t
Normal file
33
samples/client/petstore/perl/t/InlineResponseDefaultTest.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::InlineResponseDefault');
|
||||||
|
|
||||||
|
my $instance = WWW::OpenAPIClient::Object::InlineResponseDefault->new();
|
||||||
|
|
||||||
|
isa_ok($instance, 'WWW::OpenAPIClient::Object::InlineResponseDefault');
|
||||||
|
|
||||||
33
samples/client/petstore/perl/t/PersonTest.t
Normal file
33
samples/client/petstore/perl/t/PersonTest.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::Person');
|
||||||
|
|
||||||
|
my $instance = WWW::OpenAPIClient::Object::Person->new();
|
||||||
|
|
||||||
|
isa_ok($instance, 'WWW::OpenAPIClient::Object::Person');
|
||||||
|
|
||||||
64
samples/client/petstore/perl/tests/06_inheritance.t
Normal file
64
samples/client/petstore/perl/tests/06_inheritance.t
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
use Test::More tests => 37;
|
||||||
|
use Test::Exception;
|
||||||
|
|
||||||
|
use lib 'lib';
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
|
use_ok('WWW::OpenAPIClient::Object::Adult');
|
||||||
|
use_ok('WWW::OpenAPIClient::Object::Person');
|
||||||
|
use_ok('WWW::OpenAPIClient::Object::Human');
|
||||||
|
|
||||||
|
my $pet_id = 10008;
|
||||||
|
|
||||||
|
my $adult = WWW::OpenAPIClient::Object::Adult->new('duplicated_optional' => 22,
|
||||||
|
'duplicated_required' => 11,
|
||||||
|
'children' => [],
|
||||||
|
'adult_required' => 1);
|
||||||
|
my $child = WWW::OpenAPIClient::Object::Child->new('age' => 11, 'first_name' => 'William');
|
||||||
|
my $human = WWW::OpenAPIClient::Object::Human->new('___type' => $pet_id, 'body' => 'perl test');
|
||||||
|
|
||||||
|
isa_ok($adult, 'WWW::OpenAPIClient::Object::Adult');
|
||||||
|
isa_ok($child, 'WWW::OpenAPIClient::Object::Child');
|
||||||
|
isa_ok($human, 'WWW::OpenAPIClient::Object::Human');
|
||||||
|
|
||||||
|
#my $pet_hash = $pet->to_hash;
|
||||||
|
#
|
||||||
|
#is $pet_hash->{category}->{id}, '22', 'get the proper category id';
|
||||||
|
#is $pet_hash->{category}->{name}, 'perl', 'get the proper category name';
|
||||||
|
#is $pet_hash->{tags}[0]->{name}, 'just kidding', 'get the proper tag name';
|
||||||
|
#is $pet_hash->{tags}[0]->{id}, '11', 'get the proper tag id';
|
||||||
|
#
|
||||||
|
#my $add_pet = $api->add_pet(pet => $pet);
|
||||||
|
#
|
||||||
|
#my $get_pet = $api->get_pet_by_id(pet_id => $pet_id);
|
||||||
|
#my $get_pet_hash = $get_pet->to_hash;
|
||||||
|
#is $get_pet_hash->{name}, 'perl test', 'get the proper pet name from get_pet_by_id';
|
||||||
|
#is $get_pet_hash->{id}, '10008', 'get the proper pet id from get_pet_by_id';
|
||||||
|
#is $get_pet_hash->{category}->{name}, 'perl', 'get the proper category name from get_pet_by_id';
|
||||||
|
#is $get_pet_hash->{category}->{id}, '22', 'get the proper category id from get_pet_by_id';
|
||||||
|
#is $get_pet_hash->{category}->{name}, 'perl', 'get the proper category from get_pet_by_id';
|
||||||
|
#is $get_pet_hash->{tags}[0]->{name}, 'just kidding', 'get the proper tag from get_pet_by_id';
|
||||||
|
#is $get_pet_hash->{tags}[0]->{id}, '11', 'get the proper tag id from get_pet_by_id';
|
||||||
|
#is $get_pet_hash->{photoUrls}->[0], '123', 'get the proper photoUrl from get_pet_by_id';
|
||||||
|
#is $get_pet_hash->{photoUrls}->[1], 'oop', 'get the proper photoUrl from get_pet_by_id';
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#my $update_pet_with_form = $api->update_pet_with_form(pet_id => $pet_id, name => 'test_name', status => 'sold');
|
||||||
|
#is $update_pet_with_form, undef, 'get the null response from update_pet_wth_form';
|
||||||
|
#
|
||||||
|
#my $get_pet_after_update = $api->get_pet_by_id(pet_id => $pet_id);
|
||||||
|
#is $get_pet_after_update->{status}, 'sold', 'get the updated status after update_pet_with_form';
|
||||||
|
#
|
||||||
|
#my $upload_pet = $api->upload_file(pet_id => $pet_id, additional_metadata => 'testabc', file => 'test.pl');
|
||||||
|
#isa_ok($upload_pet, 'WWW::OpenAPIClient::Object::ApiResponse');
|
||||||
|
#
|
||||||
|
#my $delete_pet = $api->delete_pet(pet_id => $pet_id);
|
||||||
|
#is $delete_pet, undef, 'get the null response from delete_pet';
|
||||||
|
#throws_ok{$api->get_pet_by_id(pet_id => $pet_id)} qr/API Exception\(404\): Not Found/, "throw 404 error about pet not found after delete";
|
||||||
|
##is $get_pet_after_delete->{status}, undef, 'get the updated status after update_pet_with_form';
|
||||||
|
#
|
||||||
|
#my $pets;
|
||||||
|
#lives_ok {$pets = $api->find_pets_by_status(status => [qw(sold available)])} 'array query param processed correctly';
|
||||||
|
#isa_ok($pets->[0], 'WWW::OpenAPIClient::Object::Pet');
|
||||||
|
#
|
||||||
Reference in New Issue
Block a user