forked from loafle/openapi-generator-original
add back ruby client folders
This commit is contained in:
parent
0d91be3a72
commit
661fb42a06
@ -0,0 +1,17 @@
|
||||
# Petstore::AdditionalPropertiesAnyType
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**name** | **String** | | [optional]
|
||||
|
||||
## Code Sample
|
||||
|
||||
```ruby
|
||||
require 'Petstore'
|
||||
|
||||
instance = Petstore::AdditionalPropertiesAnyType.new(name: null)
|
||||
```
|
||||
|
||||
|
@ -0,0 +1,17 @@
|
||||
# Petstore::AdditionalPropertiesArray
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**name** | **String** | | [optional]
|
||||
|
||||
## Code Sample
|
||||
|
||||
```ruby
|
||||
require 'Petstore'
|
||||
|
||||
instance = Petstore::AdditionalPropertiesArray.new(name: null)
|
||||
```
|
||||
|
||||
|
@ -0,0 +1,17 @@
|
||||
# Petstore::AdditionalPropertiesBoolean
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**name** | **String** | | [optional]
|
||||
|
||||
## Code Sample
|
||||
|
||||
```ruby
|
||||
require 'Petstore'
|
||||
|
||||
instance = Petstore::AdditionalPropertiesBoolean.new(name: null)
|
||||
```
|
||||
|
||||
|
@ -0,0 +1,37 @@
|
||||
# Petstore::AdditionalPropertiesClass
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**map_string** | **Hash<String, String>** | | [optional]
|
||||
**map_number** | **Hash<String, Float>** | | [optional]
|
||||
**map_integer** | **Hash<String, Integer>** | | [optional]
|
||||
**map_boolean** | **Hash<String, Boolean>** | | [optional]
|
||||
**map_array_integer** | **Hash<String, Array<Integer>>** | | [optional]
|
||||
**map_array_anytype** | **Hash<String, Array<Object>>** | | [optional]
|
||||
**map_map_string** | **Hash<String, Hash<String, String>>** | | [optional]
|
||||
**map_map_anytype** | **Hash<String, Hash<String, Object>>** | | [optional]
|
||||
**anytype_1** | [**Object**](.md) | | [optional]
|
||||
**anytype_2** | [**Object**](.md) | | [optional]
|
||||
**anytype_3** | [**Object**](.md) | | [optional]
|
||||
|
||||
## Code Sample
|
||||
|
||||
```ruby
|
||||
require 'Petstore'
|
||||
|
||||
instance = Petstore::AdditionalPropertiesClass.new(map_string: null,
|
||||
map_number: null,
|
||||
map_integer: null,
|
||||
map_boolean: null,
|
||||
map_array_integer: null,
|
||||
map_array_anytype: null,
|
||||
map_map_string: null,
|
||||
map_map_anytype: null,
|
||||
anytype_1: null,
|
||||
anytype_2: null,
|
||||
anytype_3: null)
|
||||
```
|
||||
|
||||
|
@ -0,0 +1,17 @@
|
||||
# Petstore::AdditionalPropertiesInteger
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**name** | **String** | | [optional]
|
||||
|
||||
## Code Sample
|
||||
|
||||
```ruby
|
||||
require 'Petstore'
|
||||
|
||||
instance = Petstore::AdditionalPropertiesInteger.new(name: null)
|
||||
```
|
||||
|
||||
|
@ -0,0 +1,17 @@
|
||||
# Petstore::AdditionalPropertiesNumber
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**name** | **String** | | [optional]
|
||||
|
||||
## Code Sample
|
||||
|
||||
```ruby
|
||||
require 'Petstore'
|
||||
|
||||
instance = Petstore::AdditionalPropertiesNumber.new(name: null)
|
||||
```
|
||||
|
||||
|
@ -0,0 +1,17 @@
|
||||
# Petstore::AdditionalPropertiesObject
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**name** | **String** | | [optional]
|
||||
|
||||
## Code Sample
|
||||
|
||||
```ruby
|
||||
require 'Petstore'
|
||||
|
||||
instance = Petstore::AdditionalPropertiesObject.new(name: null)
|
||||
```
|
||||
|
||||
|
@ -0,0 +1,17 @@
|
||||
# Petstore::AdditionalPropertiesString
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**name** | **String** | | [optional]
|
||||
|
||||
## Code Sample
|
||||
|
||||
```ruby
|
||||
require 'Petstore'
|
||||
|
||||
instance = Petstore::AdditionalPropertiesString.new(name: null)
|
||||
```
|
||||
|
||||
|
19
samples/client/petstore/ruby/docs/Animal.md
Normal file
19
samples/client/petstore/ruby/docs/Animal.md
Normal file
@ -0,0 +1,19 @@
|
||||
# Petstore::Animal
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**class_name** | **String** | |
|
||||
**color** | **String** | | [optional] [default to 'red']
|
||||
|
||||
## Code Sample
|
||||
|
||||
```ruby
|
||||
require 'Petstore'
|
||||
|
||||
instance = Petstore::Animal.new(class_name: null,
|
||||
color: null)
|
||||
```
|
||||
|
||||
|
56
samples/client/petstore/ruby/docs/AnotherFakeApi.md
Normal file
56
samples/client/petstore/ruby/docs/AnotherFakeApi.md
Normal file
@ -0,0 +1,56 @@
|
||||
# Petstore::AnotherFakeApi
|
||||
|
||||
All URIs are relative to *http://petstore.swagger.io:80/v2*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
[**call_123_test_special_tags**](AnotherFakeApi.md#call_123_test_special_tags) | **PATCH** /another-fake/dummy | To test special tags
|
||||
|
||||
|
||||
|
||||
## call_123_test_special_tags
|
||||
|
||||
> Client call_123_test_special_tags(body)
|
||||
|
||||
To test special tags
|
||||
|
||||
To test special tags and operation ID starting with number
|
||||
|
||||
### Example
|
||||
|
||||
```ruby
|
||||
# load the gem
|
||||
require 'petstore'
|
||||
|
||||
api_instance = Petstore::AnotherFakeApi.new
|
||||
body = Petstore::Client.new # Client | client model
|
||||
|
||||
begin
|
||||
#To test special tags
|
||||
result = api_instance.call_123_test_special_tags(body)
|
||||
p result
|
||||
rescue Petstore::ApiError => e
|
||||
puts "Exception when calling AnotherFakeApi->call_123_test_special_tags: #{e}"
|
||||
end
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**body** | [**Client**](Client.md)| client model |
|
||||
|
||||
### Return type
|
||||
|
||||
[**Client**](Client.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json
|
||||
- **Accept**: application/json
|
||||
|
21
samples/client/petstore/ruby/docs/ApiResponse.md
Normal file
21
samples/client/petstore/ruby/docs/ApiResponse.md
Normal file
@ -0,0 +1,21 @@
|
||||
# Petstore::ApiResponse
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**code** | **Integer** | | [optional]
|
||||
**type** | **String** | | [optional]
|
||||
**message** | **String** | | [optional]
|
||||
|
||||
## Code Sample
|
||||
|
||||
```ruby
|
||||
require 'Petstore'
|
||||
|
||||
instance = Petstore::ApiResponse.new(code: null,
|
||||
type: null,
|
||||
message: null)
|
||||
```
|
||||
|
||||
|
@ -0,0 +1,17 @@
|
||||
# Petstore::ArrayOfArrayOfNumberOnly
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**array_array_number** | **Array<Array<Float>>** | | [optional]
|
||||
|
||||
## Code Sample
|
||||
|
||||
```ruby
|
||||
require 'Petstore'
|
||||
|
||||
instance = Petstore::ArrayOfArrayOfNumberOnly.new(array_array_number: null)
|
||||
```
|
||||
|
||||
|
17
samples/client/petstore/ruby/docs/ArrayOfNumberOnly.md
Normal file
17
samples/client/petstore/ruby/docs/ArrayOfNumberOnly.md
Normal file
@ -0,0 +1,17 @@
|
||||
# Petstore::ArrayOfNumberOnly
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**array_number** | **Array<Float>** | | [optional]
|
||||
|
||||
## Code Sample
|
||||
|
||||
```ruby
|
||||
require 'Petstore'
|
||||
|
||||
instance = Petstore::ArrayOfNumberOnly.new(array_number: null)
|
||||
```
|
||||
|
||||
|
21
samples/client/petstore/ruby/docs/ArrayTest.md
Normal file
21
samples/client/petstore/ruby/docs/ArrayTest.md
Normal file
@ -0,0 +1,21 @@
|
||||
# Petstore::ArrayTest
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**array_of_string** | **Array<String>** | | [optional]
|
||||
**array_array_of_integer** | **Array<Array<Integer>>** | | [optional]
|
||||
**array_array_of_model** | **Array<Array<ReadOnlyFirst>>** | | [optional]
|
||||
|
||||
## Code Sample
|
||||
|
||||
```ruby
|
||||
require 'Petstore'
|
||||
|
||||
instance = Petstore::ArrayTest.new(array_of_string: null,
|
||||
array_array_of_integer: null,
|
||||
array_array_of_model: null)
|
||||
```
|
||||
|
||||
|
27
samples/client/petstore/ruby/docs/Capitalization.md
Normal file
27
samples/client/petstore/ruby/docs/Capitalization.md
Normal file
@ -0,0 +1,27 @@
|
||||
# Petstore::Capitalization
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**small_camel** | **String** | | [optional]
|
||||
**capital_camel** | **String** | | [optional]
|
||||
**small_snake** | **String** | | [optional]
|
||||
**capital_snake** | **String** | | [optional]
|
||||
**sca_eth_flow_points** | **String** | | [optional]
|
||||
**att_name** | **String** | Name of the pet | [optional]
|
||||
|
||||
## Code Sample
|
||||
|
||||
```ruby
|
||||
require 'Petstore'
|
||||
|
||||
instance = Petstore::Capitalization.new(small_camel: null,
|
||||
capital_camel: null,
|
||||
small_snake: null,
|
||||
capital_snake: null,
|
||||
sca_eth_flow_points: null,
|
||||
att_name: null)
|
||||
```
|
||||
|
||||
|
17
samples/client/petstore/ruby/docs/Cat.md
Normal file
17
samples/client/petstore/ruby/docs/Cat.md
Normal file
@ -0,0 +1,17 @@
|
||||
# Petstore::Cat
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**declawed** | **Boolean** | | [optional]
|
||||
|
||||
## Code Sample
|
||||
|
||||
```ruby
|
||||
require 'Petstore'
|
||||
|
||||
instance = Petstore::Cat.new(declawed: null)
|
||||
```
|
||||
|
||||
|
17
samples/client/petstore/ruby/docs/CatAllOf.md
Normal file
17
samples/client/petstore/ruby/docs/CatAllOf.md
Normal file
@ -0,0 +1,17 @@
|
||||
# Petstore::CatAllOf
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**declawed** | **Boolean** | | [optional]
|
||||
|
||||
## Code Sample
|
||||
|
||||
```ruby
|
||||
require 'Petstore'
|
||||
|
||||
instance = Petstore::CatAllOf.new(declawed: null)
|
||||
```
|
||||
|
||||
|
19
samples/client/petstore/ruby/docs/Category.md
Normal file
19
samples/client/petstore/ruby/docs/Category.md
Normal file
@ -0,0 +1,19 @@
|
||||
# Petstore::Category
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**id** | **Integer** | | [optional]
|
||||
**name** | **String** | | [default to 'default-name']
|
||||
|
||||
## Code Sample
|
||||
|
||||
```ruby
|
||||
require 'Petstore'
|
||||
|
||||
instance = Petstore::Category.new(id: null,
|
||||
name: null)
|
||||
```
|
||||
|
||||
|
17
samples/client/petstore/ruby/docs/ClassModel.md
Normal file
17
samples/client/petstore/ruby/docs/ClassModel.md
Normal file
@ -0,0 +1,17 @@
|
||||
# Petstore::ClassModel
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**_class** | **String** | | [optional]
|
||||
|
||||
## Code Sample
|
||||
|
||||
```ruby
|
||||
require 'Petstore'
|
||||
|
||||
instance = Petstore::ClassModel.new(_class: null)
|
||||
```
|
||||
|
||||
|
17
samples/client/petstore/ruby/docs/Client.md
Normal file
17
samples/client/petstore/ruby/docs/Client.md
Normal file
@ -0,0 +1,17 @@
|
||||
# Petstore::Client
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**client** | **String** | | [optional]
|
||||
|
||||
## Code Sample
|
||||
|
||||
```ruby
|
||||
require 'Petstore'
|
||||
|
||||
instance = Petstore::Client.new(client: null)
|
||||
```
|
||||
|
||||
|
17
samples/client/petstore/ruby/docs/Dog.md
Normal file
17
samples/client/petstore/ruby/docs/Dog.md
Normal file
@ -0,0 +1,17 @@
|
||||
# Petstore::Dog
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**breed** | **String** | | [optional]
|
||||
|
||||
## Code Sample
|
||||
|
||||
```ruby
|
||||
require 'Petstore'
|
||||
|
||||
instance = Petstore::Dog.new(breed: null)
|
||||
```
|
||||
|
||||
|
17
samples/client/petstore/ruby/docs/DogAllOf.md
Normal file
17
samples/client/petstore/ruby/docs/DogAllOf.md
Normal file
@ -0,0 +1,17 @@
|
||||
# Petstore::DogAllOf
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**breed** | **String** | | [optional]
|
||||
|
||||
## Code Sample
|
||||
|
||||
```ruby
|
||||
require 'Petstore'
|
||||
|
||||
instance = Petstore::DogAllOf.new(breed: null)
|
||||
```
|
||||
|
||||
|
19
samples/client/petstore/ruby/docs/EnumArrays.md
Normal file
19
samples/client/petstore/ruby/docs/EnumArrays.md
Normal file
@ -0,0 +1,19 @@
|
||||
# Petstore::EnumArrays
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**just_symbol** | **String** | | [optional]
|
||||
**array_enum** | **Array<String>** | | [optional]
|
||||
|
||||
## Code Sample
|
||||
|
||||
```ruby
|
||||
require 'Petstore'
|
||||
|
||||
instance = Petstore::EnumArrays.new(just_symbol: null,
|
||||
array_enum: null)
|
||||
```
|
||||
|
||||
|
16
samples/client/petstore/ruby/docs/EnumClass.md
Normal file
16
samples/client/petstore/ruby/docs/EnumClass.md
Normal file
@ -0,0 +1,16 @@
|
||||
# Petstore::EnumClass
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
|
||||
## Code Sample
|
||||
|
||||
```ruby
|
||||
require 'Petstore'
|
||||
|
||||
instance = Petstore::EnumClass.new()
|
||||
```
|
||||
|
||||
|
25
samples/client/petstore/ruby/docs/EnumTest.md
Normal file
25
samples/client/petstore/ruby/docs/EnumTest.md
Normal file
@ -0,0 +1,25 @@
|
||||
# Petstore::EnumTest
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**enum_string** | **String** | | [optional]
|
||||
**enum_string_required** | **String** | |
|
||||
**enum_integer** | **Integer** | | [optional]
|
||||
**enum_number** | **Float** | | [optional]
|
||||
**outer_enum** | [**OuterEnum**](OuterEnum.md) | | [optional]
|
||||
|
||||
## Code Sample
|
||||
|
||||
```ruby
|
||||
require 'Petstore'
|
||||
|
||||
instance = Petstore::EnumTest.new(enum_string: null,
|
||||
enum_string_required: null,
|
||||
enum_integer: null,
|
||||
enum_number: null,
|
||||
outer_enum: null)
|
||||
```
|
||||
|
||||
|
740
samples/client/petstore/ruby/docs/FakeApi.md
Normal file
740
samples/client/petstore/ruby/docs/FakeApi.md
Normal file
@ -0,0 +1,740 @@
|
||||
# Petstore::FakeApi
|
||||
|
||||
All URIs are relative to *http://petstore.swagger.io:80/v2*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
[**create_xml_item**](FakeApi.md#create_xml_item) | **POST** /fake/create_xml_item | creates an XmlItem
|
||||
[**fake_outer_boolean_serialize**](FakeApi.md#fake_outer_boolean_serialize) | **POST** /fake/outer/boolean |
|
||||
[**fake_outer_composite_serialize**](FakeApi.md#fake_outer_composite_serialize) | **POST** /fake/outer/composite |
|
||||
[**fake_outer_number_serialize**](FakeApi.md#fake_outer_number_serialize) | **POST** /fake/outer/number |
|
||||
[**fake_outer_string_serialize**](FakeApi.md#fake_outer_string_serialize) | **POST** /fake/outer/string |
|
||||
[**test_body_with_file_schema**](FakeApi.md#test_body_with_file_schema) | **PUT** /fake/body-with-file-schema |
|
||||
[**test_body_with_query_params**](FakeApi.md#test_body_with_query_params) | **PUT** /fake/body-with-query-params |
|
||||
[**test_client_model**](FakeApi.md#test_client_model) | **PATCH** /fake | To test \"client\" model
|
||||
[**test_endpoint_parameters**](FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
[**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_json_form_data**](FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data
|
||||
[**test_query_parameter_collection_format**](FakeApi.md#test_query_parameter_collection_format) | **PUT** /fake/test-query-paramters |
|
||||
|
||||
|
||||
|
||||
## create_xml_item
|
||||
|
||||
> create_xml_item(xml_item)
|
||||
|
||||
creates an XmlItem
|
||||
|
||||
this route creates an XmlItem
|
||||
|
||||
### Example
|
||||
|
||||
```ruby
|
||||
# load the gem
|
||||
require 'petstore'
|
||||
|
||||
api_instance = Petstore::FakeApi.new
|
||||
xml_item = Petstore::XmlItem.new # XmlItem | XmlItem Body
|
||||
|
||||
begin
|
||||
#creates an XmlItem
|
||||
api_instance.create_xml_item(xml_item)
|
||||
rescue Petstore::ApiError => e
|
||||
puts "Exception when calling FakeApi->create_xml_item: #{e}"
|
||||
end
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**xml_item** | [**XmlItem**](XmlItem.md)| XmlItem Body |
|
||||
|
||||
### Return type
|
||||
|
||||
nil (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/xml, application/xml; charset=utf-8, application/xml; charset=utf-16, text/xml, text/xml; charset=utf-8, text/xml; charset=utf-16
|
||||
- **Accept**: Not defined
|
||||
|
||||
|
||||
## fake_outer_boolean_serialize
|
||||
|
||||
> Boolean fake_outer_boolean_serialize(opts)
|
||||
|
||||
|
||||
|
||||
Test serialization of outer boolean types
|
||||
|
||||
### Example
|
||||
|
||||
```ruby
|
||||
# load the gem
|
||||
require 'petstore'
|
||||
|
||||
api_instance = Petstore::FakeApi.new
|
||||
opts = {
|
||||
body: true # Boolean | Input boolean as post body
|
||||
}
|
||||
|
||||
begin
|
||||
result = api_instance.fake_outer_boolean_serialize(opts)
|
||||
p result
|
||||
rescue Petstore::ApiError => e
|
||||
puts "Exception when calling FakeApi->fake_outer_boolean_serialize: #{e}"
|
||||
end
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**body** | **Boolean**| Input boolean as post body | [optional]
|
||||
|
||||
### Return type
|
||||
|
||||
**Boolean**
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: */*
|
||||
|
||||
|
||||
## fake_outer_composite_serialize
|
||||
|
||||
> OuterComposite fake_outer_composite_serialize(opts)
|
||||
|
||||
|
||||
|
||||
Test serialization of object with outer number type
|
||||
|
||||
### Example
|
||||
|
||||
```ruby
|
||||
# load the gem
|
||||
require 'petstore'
|
||||
|
||||
api_instance = Petstore::FakeApi.new
|
||||
opts = {
|
||||
body: Petstore::OuterComposite.new # OuterComposite | Input composite as post body
|
||||
}
|
||||
|
||||
begin
|
||||
result = api_instance.fake_outer_composite_serialize(opts)
|
||||
p result
|
||||
rescue Petstore::ApiError => e
|
||||
puts "Exception when calling FakeApi->fake_outer_composite_serialize: #{e}"
|
||||
end
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**body** | [**OuterComposite**](OuterComposite.md)| Input composite as post body | [optional]
|
||||
|
||||
### Return type
|
||||
|
||||
[**OuterComposite**](OuterComposite.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: */*
|
||||
|
||||
|
||||
## fake_outer_number_serialize
|
||||
|
||||
> Float fake_outer_number_serialize(opts)
|
||||
|
||||
|
||||
|
||||
Test serialization of outer number types
|
||||
|
||||
### Example
|
||||
|
||||
```ruby
|
||||
# load the gem
|
||||
require 'petstore'
|
||||
|
||||
api_instance = Petstore::FakeApi.new
|
||||
opts = {
|
||||
body: 3.4 # Float | Input number as post body
|
||||
}
|
||||
|
||||
begin
|
||||
result = api_instance.fake_outer_number_serialize(opts)
|
||||
p result
|
||||
rescue Petstore::ApiError => e
|
||||
puts "Exception when calling FakeApi->fake_outer_number_serialize: #{e}"
|
||||
end
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**body** | **Float**| Input number as post body | [optional]
|
||||
|
||||
### Return type
|
||||
|
||||
**Float**
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: */*
|
||||
|
||||
|
||||
## fake_outer_string_serialize
|
||||
|
||||
> String fake_outer_string_serialize(opts)
|
||||
|
||||
|
||||
|
||||
Test serialization of outer string types
|
||||
|
||||
### Example
|
||||
|
||||
```ruby
|
||||
# load the gem
|
||||
require 'petstore'
|
||||
|
||||
api_instance = Petstore::FakeApi.new
|
||||
opts = {
|
||||
body: 'body_example' # String | Input string as post body
|
||||
}
|
||||
|
||||
begin
|
||||
result = api_instance.fake_outer_string_serialize(opts)
|
||||
p result
|
||||
rescue Petstore::ApiError => e
|
||||
puts "Exception when calling FakeApi->fake_outer_string_serialize: #{e}"
|
||||
end
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**body** | **String**| Input string as post body | [optional]
|
||||
|
||||
### Return type
|
||||
|
||||
**String**
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: */*
|
||||
|
||||
|
||||
## test_body_with_file_schema
|
||||
|
||||
> test_body_with_file_schema(body)
|
||||
|
||||
|
||||
|
||||
For this test, the body for this request much reference a schema named `File`.
|
||||
|
||||
### Example
|
||||
|
||||
```ruby
|
||||
# load the gem
|
||||
require 'petstore'
|
||||
|
||||
api_instance = Petstore::FakeApi.new
|
||||
body = Petstore::FileSchemaTestClass.new # FileSchemaTestClass |
|
||||
|
||||
begin
|
||||
api_instance.test_body_with_file_schema(body)
|
||||
rescue Petstore::ApiError => e
|
||||
puts "Exception when calling FakeApi->test_body_with_file_schema: #{e}"
|
||||
end
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**body** | [**FileSchemaTestClass**](FileSchemaTestClass.md)| |
|
||||
|
||||
### Return type
|
||||
|
||||
nil (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json
|
||||
- **Accept**: Not defined
|
||||
|
||||
|
||||
## test_body_with_query_params
|
||||
|
||||
> test_body_with_query_params(query, body)
|
||||
|
||||
|
||||
|
||||
### Example
|
||||
|
||||
```ruby
|
||||
# load the gem
|
||||
require 'petstore'
|
||||
|
||||
api_instance = Petstore::FakeApi.new
|
||||
query = 'query_example' # String |
|
||||
body = Petstore::User.new # User |
|
||||
|
||||
begin
|
||||
api_instance.test_body_with_query_params(query, body)
|
||||
rescue Petstore::ApiError => e
|
||||
puts "Exception when calling FakeApi->test_body_with_query_params: #{e}"
|
||||
end
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**query** | **String**| |
|
||||
**body** | [**User**](User.md)| |
|
||||
|
||||
### Return type
|
||||
|
||||
nil (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json
|
||||
- **Accept**: Not defined
|
||||
|
||||
|
||||
## test_client_model
|
||||
|
||||
> Client test_client_model(body)
|
||||
|
||||
To test \"client\" model
|
||||
|
||||
To test \"client\" model
|
||||
|
||||
### Example
|
||||
|
||||
```ruby
|
||||
# load the gem
|
||||
require 'petstore'
|
||||
|
||||
api_instance = Petstore::FakeApi.new
|
||||
body = Petstore::Client.new # Client | client model
|
||||
|
||||
begin
|
||||
#To test \"client\" model
|
||||
result = api_instance.test_client_model(body)
|
||||
p result
|
||||
rescue Petstore::ApiError => e
|
||||
puts "Exception when calling FakeApi->test_client_model: #{e}"
|
||||
end
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**body** | [**Client**](Client.md)| client model |
|
||||
|
||||
### Return type
|
||||
|
||||
[**Client**](Client.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json
|
||||
- **Accept**: application/json
|
||||
|
||||
|
||||
## test_endpoint_parameters
|
||||
|
||||
> test_endpoint_parameters(number, double, pattern_without_delimiter, byte, opts)
|
||||
|
||||
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
|
||||
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
|
||||
### Example
|
||||
|
||||
```ruby
|
||||
# load the gem
|
||||
require 'petstore'
|
||||
# setup authorization
|
||||
Petstore.configure do |config|
|
||||
# Configure HTTP basic authorization: http_basic_test
|
||||
config.username = 'YOUR USERNAME'
|
||||
config.password = 'YOUR PASSWORD'
|
||||
end
|
||||
|
||||
api_instance = Petstore::FakeApi.new
|
||||
number = 3.4 # Float | None
|
||||
double = 3.4 # Float | None
|
||||
pattern_without_delimiter = 'pattern_without_delimiter_example' # String | None
|
||||
byte = 'byte_example' # String | None
|
||||
opts = {
|
||||
integer: 56, # Integer | None
|
||||
int32: 56, # Integer | None
|
||||
int64: 56, # Integer | None
|
||||
float: 3.4, # Float | None
|
||||
string: 'string_example', # String | None
|
||||
binary: File.new('/path/to/file'), # File | None
|
||||
date: Date.parse('2013-10-20'), # Date | None
|
||||
date_time: DateTime.parse('2013-10-20T19:20:30+01:00'), # DateTime | None
|
||||
password: 'password_example', # String | None
|
||||
callback: 'callback_example' # String | None
|
||||
}
|
||||
|
||||
begin
|
||||
#Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
api_instance.test_endpoint_parameters(number, double, pattern_without_delimiter, byte, opts)
|
||||
rescue Petstore::ApiError => e
|
||||
puts "Exception when calling FakeApi->test_endpoint_parameters: #{e}"
|
||||
end
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**number** | **Float**| None |
|
||||
**double** | **Float**| None |
|
||||
**pattern_without_delimiter** | **String**| None |
|
||||
**byte** | **String**| None |
|
||||
**integer** | **Integer**| None | [optional]
|
||||
**int32** | **Integer**| None | [optional]
|
||||
**int64** | **Integer**| None | [optional]
|
||||
**float** | **Float**| None | [optional]
|
||||
**string** | **String**| None | [optional]
|
||||
**binary** | **File**| None | [optional]
|
||||
**date** | **Date**| None | [optional]
|
||||
**date_time** | **DateTime**| None | [optional]
|
||||
**password** | **String**| None | [optional]
|
||||
**callback** | **String**| None | [optional]
|
||||
|
||||
### Return type
|
||||
|
||||
nil (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
[http_basic_test](../README.md#http_basic_test)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/x-www-form-urlencoded
|
||||
- **Accept**: Not defined
|
||||
|
||||
|
||||
## test_enum_parameters
|
||||
|
||||
> test_enum_parameters(opts)
|
||||
|
||||
To test enum parameters
|
||||
|
||||
To test enum parameters
|
||||
|
||||
### Example
|
||||
|
||||
```ruby
|
||||
# load the gem
|
||||
require 'petstore'
|
||||
|
||||
api_instance = Petstore::FakeApi.new
|
||||
opts = {
|
||||
enum_header_string_array: ['enum_header_string_array_example'], # Array<String> | Header parameter enum test (string array)
|
||||
enum_header_string: '-efg', # String | Header parameter enum test (string)
|
||||
enum_query_string_array: ['enum_query_string_array_example'], # Array<String> | Query parameter enum test (string array)
|
||||
enum_query_string: '-efg', # String | Query parameter enum test (string)
|
||||
enum_query_integer: 56, # Integer | Query parameter enum test (double)
|
||||
enum_query_double: 3.4, # Float | Query parameter enum test (double)
|
||||
enum_form_string_array: '$', # Array<String> | Form parameter enum test (string array)
|
||||
enum_form_string: '-efg' # String | Form parameter enum test (string)
|
||||
}
|
||||
|
||||
begin
|
||||
#To test enum parameters
|
||||
api_instance.test_enum_parameters(opts)
|
||||
rescue Petstore::ApiError => e
|
||||
puts "Exception when calling FakeApi->test_enum_parameters: #{e}"
|
||||
end
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**enum_header_string_array** | [**Array<String>**](String.md)| Header parameter enum test (string array) | [optional]
|
||||
**enum_header_string** | **String**| Header parameter enum test (string) | [optional] [default to '-efg']
|
||||
**enum_query_string_array** | [**Array<String>**](String.md)| Query parameter enum test (string array) | [optional]
|
||||
**enum_query_string** | **String**| Query parameter enum test (string) | [optional] [default to '-efg']
|
||||
**enum_query_integer** | **Integer**| Query parameter enum test (double) | [optional]
|
||||
**enum_query_double** | **Float**| Query parameter enum test (double) | [optional]
|
||||
**enum_form_string_array** | [**Array<String>**](String.md)| Form parameter enum test (string array) | [optional] [default to '$']
|
||||
**enum_form_string** | **String**| Form parameter enum test (string) | [optional] [default to '-efg']
|
||||
|
||||
### Return type
|
||||
|
||||
nil (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/x-www-form-urlencoded
|
||||
- **Accept**: Not defined
|
||||
|
||||
|
||||
## test_group_parameters
|
||||
|
||||
> test_group_parameters(required_string_group, required_boolean_group, required_int64_group, opts)
|
||||
|
||||
Fake endpoint to test group parameters (optional)
|
||||
|
||||
Fake endpoint to test group parameters (optional)
|
||||
|
||||
### Example
|
||||
|
||||
```ruby
|
||||
# load the gem
|
||||
require 'petstore'
|
||||
|
||||
api_instance = Petstore::FakeApi.new
|
||||
required_string_group = 56 # Integer | Required String in group parameters
|
||||
required_boolean_group = true # Boolean | Required Boolean in group parameters
|
||||
required_int64_group = 56 # Integer | Required Integer in group parameters
|
||||
opts = {
|
||||
string_group: 56, # Integer | String in group parameters
|
||||
boolean_group: true, # Boolean | Boolean in group parameters
|
||||
int64_group: 56 # Integer | Integer in group parameters
|
||||
}
|
||||
|
||||
begin
|
||||
#Fake endpoint to test group parameters (optional)
|
||||
api_instance.test_group_parameters(required_string_group, required_boolean_group, required_int64_group, opts)
|
||||
rescue Petstore::ApiError => e
|
||||
puts "Exception when calling FakeApi->test_group_parameters: #{e}"
|
||||
end
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**required_string_group** | **Integer**| Required String in group parameters |
|
||||
**required_boolean_group** | **Boolean**| Required Boolean in group parameters |
|
||||
**required_int64_group** | **Integer**| Required Integer in group parameters |
|
||||
**string_group** | **Integer**| String in group parameters | [optional]
|
||||
**boolean_group** | **Boolean**| Boolean in group parameters | [optional]
|
||||
**int64_group** | **Integer**| Integer in group parameters | [optional]
|
||||
|
||||
### Return type
|
||||
|
||||
nil (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: Not defined
|
||||
|
||||
|
||||
## test_inline_additional_properties
|
||||
|
||||
> test_inline_additional_properties(param)
|
||||
|
||||
test inline additionalProperties
|
||||
|
||||
### Example
|
||||
|
||||
```ruby
|
||||
# load the gem
|
||||
require 'petstore'
|
||||
|
||||
api_instance = Petstore::FakeApi.new
|
||||
param = {'key' => 'param_example'} # Hash<String, String> | request body
|
||||
|
||||
begin
|
||||
#test inline additionalProperties
|
||||
api_instance.test_inline_additional_properties(param)
|
||||
rescue Petstore::ApiError => e
|
||||
puts "Exception when calling FakeApi->test_inline_additional_properties: #{e}"
|
||||
end
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**param** | [**Hash<String, String>**](String.md)| request body |
|
||||
|
||||
### Return type
|
||||
|
||||
nil (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json
|
||||
- **Accept**: Not defined
|
||||
|
||||
|
||||
## test_json_form_data
|
||||
|
||||
> test_json_form_data(param, param2)
|
||||
|
||||
test json serialization of form data
|
||||
|
||||
### Example
|
||||
|
||||
```ruby
|
||||
# load the gem
|
||||
require 'petstore'
|
||||
|
||||
api_instance = Petstore::FakeApi.new
|
||||
param = 'param_example' # String | field1
|
||||
param2 = 'param2_example' # String | field2
|
||||
|
||||
begin
|
||||
#test json serialization of form data
|
||||
api_instance.test_json_form_data(param, param2)
|
||||
rescue Petstore::ApiError => e
|
||||
puts "Exception when calling FakeApi->test_json_form_data: #{e}"
|
||||
end
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**param** | **String**| field1 |
|
||||
**param2** | **String**| field2 |
|
||||
|
||||
### Return type
|
||||
|
||||
nil (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/x-www-form-urlencoded
|
||||
- **Accept**: Not defined
|
||||
|
||||
|
||||
## test_query_parameter_collection_format
|
||||
|
||||
> test_query_parameter_collection_format(pipe, ioutil, http, url, context)
|
||||
|
||||
|
||||
|
||||
To test the collection format in query parameters
|
||||
|
||||
### Example
|
||||
|
||||
```ruby
|
||||
# load the gem
|
||||
require 'petstore'
|
||||
|
||||
api_instance = Petstore::FakeApi.new
|
||||
pipe = ['pipe_example'] # Array<String> |
|
||||
ioutil = ['ioutil_example'] # Array<String> |
|
||||
http = ['http_example'] # Array<String> |
|
||||
url = ['url_example'] # Array<String> |
|
||||
context = ['context_example'] # Array<String> |
|
||||
|
||||
begin
|
||||
api_instance.test_query_parameter_collection_format(pipe, ioutil, http, url, context)
|
||||
rescue Petstore::ApiError => e
|
||||
puts "Exception when calling FakeApi->test_query_parameter_collection_format: #{e}"
|
||||
end
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**pipe** | [**Array<String>**](String.md)| |
|
||||
**ioutil** | [**Array<String>**](String.md)| |
|
||||
**http** | [**Array<String>**](String.md)| |
|
||||
**url** | [**Array<String>**](String.md)| |
|
||||
**context** | [**Array<String>**](String.md)| |
|
||||
|
||||
### Return type
|
||||
|
||||
nil (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: Not defined
|
||||
|
63
samples/client/petstore/ruby/docs/FakeClassnameTags123Api.md
Normal file
63
samples/client/petstore/ruby/docs/FakeClassnameTags123Api.md
Normal file
@ -0,0 +1,63 @@
|
||||
# Petstore::FakeClassnameTags123Api
|
||||
|
||||
All URIs are relative to *http://petstore.swagger.io:80/v2*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
[**test_classname**](FakeClassnameTags123Api.md#test_classname) | **PATCH** /fake_classname_test | To test class name in snake case
|
||||
|
||||
|
||||
|
||||
## test_classname
|
||||
|
||||
> Client test_classname(body)
|
||||
|
||||
To test class name in snake case
|
||||
|
||||
To test class name in snake case
|
||||
|
||||
### Example
|
||||
|
||||
```ruby
|
||||
# load the gem
|
||||
require 'petstore'
|
||||
# setup authorization
|
||||
Petstore.configure do |config|
|
||||
# Configure API key authorization: api_key_query
|
||||
config.api_key['api_key_query'] = 'YOUR API KEY'
|
||||
# Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
|
||||
#config.api_key_prefix['api_key_query'] = 'Bearer'
|
||||
end
|
||||
|
||||
api_instance = Petstore::FakeClassnameTags123Api.new
|
||||
body = Petstore::Client.new # Client | client model
|
||||
|
||||
begin
|
||||
#To test class name in snake case
|
||||
result = api_instance.test_classname(body)
|
||||
p result
|
||||
rescue Petstore::ApiError => e
|
||||
puts "Exception when calling FakeClassnameTags123Api->test_classname: #{e}"
|
||||
end
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**body** | [**Client**](Client.md)| client model |
|
||||
|
||||
### Return type
|
||||
|
||||
[**Client**](Client.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
[api_key_query](../README.md#api_key_query)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json
|
||||
- **Accept**: application/json
|
||||
|
17
samples/client/petstore/ruby/docs/File.md
Normal file
17
samples/client/petstore/ruby/docs/File.md
Normal file
@ -0,0 +1,17 @@
|
||||
# Petstore::File
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**source_uri** | **String** | Test capitalization | [optional]
|
||||
|
||||
## Code Sample
|
||||
|
||||
```ruby
|
||||
require 'Petstore'
|
||||
|
||||
instance = Petstore::File.new(source_uri: null)
|
||||
```
|
||||
|
||||
|
19
samples/client/petstore/ruby/docs/FileSchemaTestClass.md
Normal file
19
samples/client/petstore/ruby/docs/FileSchemaTestClass.md
Normal file
@ -0,0 +1,19 @@
|
||||
# Petstore::FileSchemaTestClass
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**file** | **File** | | [optional]
|
||||
**files** | **Array<File>** | | [optional]
|
||||
|
||||
## Code Sample
|
||||
|
||||
```ruby
|
||||
require 'Petstore'
|
||||
|
||||
instance = Petstore::FileSchemaTestClass.new(file: null,
|
||||
files: null)
|
||||
```
|
||||
|
||||
|
43
samples/client/petstore/ruby/docs/FormatTest.md
Normal file
43
samples/client/petstore/ruby/docs/FormatTest.md
Normal file
@ -0,0 +1,43 @@
|
||||
# Petstore::FormatTest
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**integer** | **Integer** | | [optional]
|
||||
**int32** | **Integer** | | [optional]
|
||||
**int64** | **Integer** | | [optional]
|
||||
**number** | **Float** | |
|
||||
**float** | **Float** | | [optional]
|
||||
**double** | **Float** | | [optional]
|
||||
**string** | **String** | | [optional]
|
||||
**byte** | **String** | |
|
||||
**binary** | **File** | | [optional]
|
||||
**date** | **Date** | |
|
||||
**date_time** | **DateTime** | | [optional]
|
||||
**uuid** | **String** | | [optional]
|
||||
**password** | **String** | |
|
||||
**big_decimal** | [**BigDecimal**](BigDecimal.md) | | [optional]
|
||||
|
||||
## Code Sample
|
||||
|
||||
```ruby
|
||||
require 'Petstore'
|
||||
|
||||
instance = Petstore::FormatTest.new(integer: null,
|
||||
int32: null,
|
||||
int64: null,
|
||||
number: null,
|
||||
float: null,
|
||||
double: null,
|
||||
string: null,
|
||||
byte: null,
|
||||
binary: null,
|
||||
date: null,
|
||||
date_time: null,
|
||||
uuid: 72f98069-206d-4f12-9f12-3d1e525a8e84,
|
||||
password: null,
|
||||
big_decimal: null)
|
||||
```
|
||||
|
||||
|
19
samples/client/petstore/ruby/docs/HasOnlyReadOnly.md
Normal file
19
samples/client/petstore/ruby/docs/HasOnlyReadOnly.md
Normal file
@ -0,0 +1,19 @@
|
||||
# Petstore::HasOnlyReadOnly
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**bar** | **String** | | [optional] [readonly]
|
||||
**foo** | **String** | | [optional] [readonly]
|
||||
|
||||
## Code Sample
|
||||
|
||||
```ruby
|
||||
require 'Petstore'
|
||||
|
||||
instance = Petstore::HasOnlyReadOnly.new(bar: null,
|
||||
foo: null)
|
||||
```
|
||||
|
||||
|
17
samples/client/petstore/ruby/docs/List.md
Normal file
17
samples/client/petstore/ruby/docs/List.md
Normal file
@ -0,0 +1,17 @@
|
||||
# Petstore::List
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**_123_list** | **String** | | [optional]
|
||||
|
||||
## Code Sample
|
||||
|
||||
```ruby
|
||||
require 'Petstore'
|
||||
|
||||
instance = Petstore::List.new(_123_list: null)
|
||||
```
|
||||
|
||||
|
23
samples/client/petstore/ruby/docs/MapTest.md
Normal file
23
samples/client/petstore/ruby/docs/MapTest.md
Normal file
@ -0,0 +1,23 @@
|
||||
# Petstore::MapTest
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**map_map_of_string** | **Hash<String, Hash<String, String>>** | | [optional]
|
||||
**map_of_enum_string** | **Hash<String, String>** | | [optional]
|
||||
**direct_map** | **Hash<String, Boolean>** | | [optional]
|
||||
**indirect_map** | **Hash<String, Boolean>** | | [optional]
|
||||
|
||||
## Code Sample
|
||||
|
||||
```ruby
|
||||
require 'Petstore'
|
||||
|
||||
instance = Petstore::MapTest.new(map_map_of_string: null,
|
||||
map_of_enum_string: null,
|
||||
direct_map: null,
|
||||
indirect_map: null)
|
||||
```
|
||||
|
||||
|
@ -0,0 +1,21 @@
|
||||
# Petstore::MixedPropertiesAndAdditionalPropertiesClass
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**uuid** | **String** | | [optional]
|
||||
**date_time** | **DateTime** | | [optional]
|
||||
**map** | [**Hash<String, Animal>**](Animal.md) | | [optional]
|
||||
|
||||
## Code Sample
|
||||
|
||||
```ruby
|
||||
require 'Petstore'
|
||||
|
||||
instance = Petstore::MixedPropertiesAndAdditionalPropertiesClass.new(uuid: null,
|
||||
date_time: null,
|
||||
map: null)
|
||||
```
|
||||
|
||||
|
19
samples/client/petstore/ruby/docs/Model200Response.md
Normal file
19
samples/client/petstore/ruby/docs/Model200Response.md
Normal file
@ -0,0 +1,19 @@
|
||||
# Petstore::Model200Response
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**name** | **Integer** | | [optional]
|
||||
**_class** | **String** | | [optional]
|
||||
|
||||
## Code Sample
|
||||
|
||||
```ruby
|
||||
require 'Petstore'
|
||||
|
||||
instance = Petstore::Model200Response.new(name: null,
|
||||
_class: null)
|
||||
```
|
||||
|
||||
|
17
samples/client/petstore/ruby/docs/ModelReturn.md
Normal file
17
samples/client/petstore/ruby/docs/ModelReturn.md
Normal file
@ -0,0 +1,17 @@
|
||||
# Petstore::ModelReturn
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**_return** | **Integer** | | [optional]
|
||||
|
||||
## Code Sample
|
||||
|
||||
```ruby
|
||||
require 'Petstore'
|
||||
|
||||
instance = Petstore::ModelReturn.new(_return: null)
|
||||
```
|
||||
|
||||
|
23
samples/client/petstore/ruby/docs/Name.md
Normal file
23
samples/client/petstore/ruby/docs/Name.md
Normal file
@ -0,0 +1,23 @@
|
||||
# Petstore::Name
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**name** | **Integer** | |
|
||||
**snake_case** | **Integer** | | [optional] [readonly]
|
||||
**property** | **String** | | [optional]
|
||||
**_123_number** | **Integer** | | [optional] [readonly]
|
||||
|
||||
## Code Sample
|
||||
|
||||
```ruby
|
||||
require 'Petstore'
|
||||
|
||||
instance = Petstore::Name.new(name: null,
|
||||
snake_case: null,
|
||||
property: null,
|
||||
_123_number: null)
|
||||
```
|
||||
|
||||
|
17
samples/client/petstore/ruby/docs/NumberOnly.md
Normal file
17
samples/client/petstore/ruby/docs/NumberOnly.md
Normal file
@ -0,0 +1,17 @@
|
||||
# Petstore::NumberOnly
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**just_number** | **Float** | | [optional]
|
||||
|
||||
## Code Sample
|
||||
|
||||
```ruby
|
||||
require 'Petstore'
|
||||
|
||||
instance = Petstore::NumberOnly.new(just_number: null)
|
||||
```
|
||||
|
||||
|
27
samples/client/petstore/ruby/docs/Order.md
Normal file
27
samples/client/petstore/ruby/docs/Order.md
Normal file
@ -0,0 +1,27 @@
|
||||
# Petstore::Order
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**id** | **Integer** | | [optional]
|
||||
**pet_id** | **Integer** | | [optional]
|
||||
**quantity** | **Integer** | | [optional]
|
||||
**ship_date** | **DateTime** | | [optional]
|
||||
**status** | **String** | Order Status | [optional]
|
||||
**complete** | **Boolean** | | [optional] [default to false]
|
||||
|
||||
## Code Sample
|
||||
|
||||
```ruby
|
||||
require 'Petstore'
|
||||
|
||||
instance = Petstore::Order.new(id: null,
|
||||
pet_id: null,
|
||||
quantity: null,
|
||||
ship_date: null,
|
||||
status: null,
|
||||
complete: null)
|
||||
```
|
||||
|
||||
|
21
samples/client/petstore/ruby/docs/OuterComposite.md
Normal file
21
samples/client/petstore/ruby/docs/OuterComposite.md
Normal file
@ -0,0 +1,21 @@
|
||||
# Petstore::OuterComposite
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**my_number** | **Float** | | [optional]
|
||||
**my_string** | **String** | | [optional]
|
||||
**my_boolean** | **Boolean** | | [optional]
|
||||
|
||||
## Code Sample
|
||||
|
||||
```ruby
|
||||
require 'Petstore'
|
||||
|
||||
instance = Petstore::OuterComposite.new(my_number: null,
|
||||
my_string: null,
|
||||
my_boolean: null)
|
||||
```
|
||||
|
||||
|
16
samples/client/petstore/ruby/docs/OuterEnum.md
Normal file
16
samples/client/petstore/ruby/docs/OuterEnum.md
Normal file
@ -0,0 +1,16 @@
|
||||
# Petstore::OuterEnum
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
|
||||
## Code Sample
|
||||
|
||||
```ruby
|
||||
require 'Petstore'
|
||||
|
||||
instance = Petstore::OuterEnum.new()
|
||||
```
|
||||
|
||||
|
27
samples/client/petstore/ruby/docs/Pet.md
Normal file
27
samples/client/petstore/ruby/docs/Pet.md
Normal file
@ -0,0 +1,27 @@
|
||||
# Petstore::Pet
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**id** | **Integer** | | [optional]
|
||||
**category** | [**Category**](Category.md) | | [optional]
|
||||
**name** | **String** | |
|
||||
**photo_urls** | **Array<String>** | |
|
||||
**tags** | [**Array<Tag>**](Tag.md) | | [optional]
|
||||
**status** | **String** | pet status in the store | [optional]
|
||||
|
||||
## Code Sample
|
||||
|
||||
```ruby
|
||||
require 'Petstore'
|
||||
|
||||
instance = Petstore::Pet.new(id: null,
|
||||
category: null,
|
||||
name: doggie,
|
||||
photo_urls: null,
|
||||
tags: null,
|
||||
status: null)
|
||||
```
|
||||
|
||||
|
493
samples/client/petstore/ruby/docs/PetApi.md
Normal file
493
samples/client/petstore/ruby/docs/PetApi.md
Normal file
@ -0,0 +1,493 @@
|
||||
# Petstore::PetApi
|
||||
|
||||
All URIs are relative to *http://petstore.swagger.io:80/v2*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
[**add_pet**](PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store
|
||||
[**delete_pet**](PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet
|
||||
[**find_pets_by_status**](PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status
|
||||
[**find_pets_by_tags**](PetApi.md#find_pets_by_tags) | **GET** /pet/findByTags | Finds Pets by tags
|
||||
[**get_pet_by_id**](PetApi.md#get_pet_by_id) | **GET** /pet/{petId} | Find pet by ID
|
||||
[**update_pet**](PetApi.md#update_pet) | **PUT** /pet | Update an existing pet
|
||||
[**update_pet_with_form**](PetApi.md#update_pet_with_form) | **POST** /pet/{petId} | Updates a pet in the store with form data
|
||||
[**upload_file**](PetApi.md#upload_file) | **POST** /pet/{petId}/uploadImage | uploads an image
|
||||
[**upload_file_with_required_file**](PetApi.md#upload_file_with_required_file) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required)
|
||||
|
||||
|
||||
|
||||
## add_pet
|
||||
|
||||
> add_pet(body)
|
||||
|
||||
Add a new pet to the store
|
||||
|
||||
### Example
|
||||
|
||||
```ruby
|
||||
# load the gem
|
||||
require 'petstore'
|
||||
# setup authorization
|
||||
Petstore.configure do |config|
|
||||
# Configure OAuth2 access token for authorization: petstore_auth
|
||||
config.access_token = 'YOUR ACCESS TOKEN'
|
||||
end
|
||||
|
||||
api_instance = Petstore::PetApi.new
|
||||
body = Petstore::Pet.new # Pet | Pet object that needs to be added to the store
|
||||
|
||||
begin
|
||||
#Add a new pet to the store
|
||||
api_instance.add_pet(body)
|
||||
rescue Petstore::ApiError => e
|
||||
puts "Exception when calling PetApi->add_pet: #{e}"
|
||||
end
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store |
|
||||
|
||||
### Return type
|
||||
|
||||
nil (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
[petstore_auth](../README.md#petstore_auth)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json, application/xml
|
||||
- **Accept**: Not defined
|
||||
|
||||
|
||||
## delete_pet
|
||||
|
||||
> delete_pet(pet_id, opts)
|
||||
|
||||
Deletes a pet
|
||||
|
||||
### Example
|
||||
|
||||
```ruby
|
||||
# load the gem
|
||||
require 'petstore'
|
||||
# setup authorization
|
||||
Petstore.configure do |config|
|
||||
# Configure OAuth2 access token for authorization: petstore_auth
|
||||
config.access_token = 'YOUR ACCESS TOKEN'
|
||||
end
|
||||
|
||||
api_instance = Petstore::PetApi.new
|
||||
pet_id = 56 # Integer | Pet id to delete
|
||||
opts = {
|
||||
api_key: 'api_key_example' # String |
|
||||
}
|
||||
|
||||
begin
|
||||
#Deletes a pet
|
||||
api_instance.delete_pet(pet_id, opts)
|
||||
rescue Petstore::ApiError => e
|
||||
puts "Exception when calling PetApi->delete_pet: #{e}"
|
||||
end
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**pet_id** | **Integer**| Pet id to delete |
|
||||
**api_key** | **String**| | [optional]
|
||||
|
||||
### Return type
|
||||
|
||||
nil (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
[petstore_auth](../README.md#petstore_auth)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: Not defined
|
||||
|
||||
|
||||
## find_pets_by_status
|
||||
|
||||
> Array<Pet> find_pets_by_status(status)
|
||||
|
||||
Finds Pets by status
|
||||
|
||||
Multiple status values can be provided with comma separated strings
|
||||
|
||||
### Example
|
||||
|
||||
```ruby
|
||||
# load the gem
|
||||
require 'petstore'
|
||||
# setup authorization
|
||||
Petstore.configure do |config|
|
||||
# Configure OAuth2 access token for authorization: petstore_auth
|
||||
config.access_token = 'YOUR ACCESS TOKEN'
|
||||
end
|
||||
|
||||
api_instance = Petstore::PetApi.new
|
||||
status = ['status_example'] # Array<String> | Status values that need to be considered for filter
|
||||
|
||||
begin
|
||||
#Finds Pets by status
|
||||
result = api_instance.find_pets_by_status(status)
|
||||
p result
|
||||
rescue Petstore::ApiError => e
|
||||
puts "Exception when calling PetApi->find_pets_by_status: #{e}"
|
||||
end
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**status** | [**Array<String>**](String.md)| Status values that need to be considered for filter |
|
||||
|
||||
### Return type
|
||||
|
||||
[**Array<Pet>**](Pet.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
[petstore_auth](../README.md#petstore_auth)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/xml, application/json
|
||||
|
||||
|
||||
## find_pets_by_tags
|
||||
|
||||
> Array<Pet> find_pets_by_tags(tags)
|
||||
|
||||
Finds Pets by tags
|
||||
|
||||
Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||
|
||||
### Example
|
||||
|
||||
```ruby
|
||||
# load the gem
|
||||
require 'petstore'
|
||||
# setup authorization
|
||||
Petstore.configure do |config|
|
||||
# Configure OAuth2 access token for authorization: petstore_auth
|
||||
config.access_token = 'YOUR ACCESS TOKEN'
|
||||
end
|
||||
|
||||
api_instance = Petstore::PetApi.new
|
||||
tags = ['tags_example'] # Array<String> | Tags to filter by
|
||||
|
||||
begin
|
||||
#Finds Pets by tags
|
||||
result = api_instance.find_pets_by_tags(tags)
|
||||
p result
|
||||
rescue Petstore::ApiError => e
|
||||
puts "Exception when calling PetApi->find_pets_by_tags: #{e}"
|
||||
end
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**tags** | [**Array<String>**](String.md)| Tags to filter by |
|
||||
|
||||
### Return type
|
||||
|
||||
[**Array<Pet>**](Pet.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
[petstore_auth](../README.md#petstore_auth)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/xml, application/json
|
||||
|
||||
|
||||
## get_pet_by_id
|
||||
|
||||
> Pet get_pet_by_id(pet_id)
|
||||
|
||||
Find pet by ID
|
||||
|
||||
Returns a single pet
|
||||
|
||||
### Example
|
||||
|
||||
```ruby
|
||||
# load the gem
|
||||
require 'petstore'
|
||||
# setup authorization
|
||||
Petstore.configure do |config|
|
||||
# Configure API key authorization: api_key
|
||||
config.api_key['api_key'] = 'YOUR API KEY'
|
||||
# Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
|
||||
#config.api_key_prefix['api_key'] = 'Bearer'
|
||||
end
|
||||
|
||||
api_instance = Petstore::PetApi.new
|
||||
pet_id = 56 # Integer | ID of pet to return
|
||||
|
||||
begin
|
||||
#Find pet by ID
|
||||
result = api_instance.get_pet_by_id(pet_id)
|
||||
p result
|
||||
rescue Petstore::ApiError => e
|
||||
puts "Exception when calling PetApi->get_pet_by_id: #{e}"
|
||||
end
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**pet_id** | **Integer**| ID of pet to return |
|
||||
|
||||
### Return type
|
||||
|
||||
[**Pet**](Pet.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
[api_key](../README.md#api_key)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/xml, application/json
|
||||
|
||||
|
||||
## update_pet
|
||||
|
||||
> update_pet(body)
|
||||
|
||||
Update an existing pet
|
||||
|
||||
### Example
|
||||
|
||||
```ruby
|
||||
# load the gem
|
||||
require 'petstore'
|
||||
# setup authorization
|
||||
Petstore.configure do |config|
|
||||
# Configure OAuth2 access token for authorization: petstore_auth
|
||||
config.access_token = 'YOUR ACCESS TOKEN'
|
||||
end
|
||||
|
||||
api_instance = Petstore::PetApi.new
|
||||
body = Petstore::Pet.new # Pet | Pet object that needs to be added to the store
|
||||
|
||||
begin
|
||||
#Update an existing pet
|
||||
api_instance.update_pet(body)
|
||||
rescue Petstore::ApiError => e
|
||||
puts "Exception when calling PetApi->update_pet: #{e}"
|
||||
end
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store |
|
||||
|
||||
### Return type
|
||||
|
||||
nil (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
[petstore_auth](../README.md#petstore_auth)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json, application/xml
|
||||
- **Accept**: Not defined
|
||||
|
||||
|
||||
## update_pet_with_form
|
||||
|
||||
> update_pet_with_form(pet_id, opts)
|
||||
|
||||
Updates a pet in the store with form data
|
||||
|
||||
### Example
|
||||
|
||||
```ruby
|
||||
# load the gem
|
||||
require 'petstore'
|
||||
# setup authorization
|
||||
Petstore.configure do |config|
|
||||
# Configure OAuth2 access token for authorization: petstore_auth
|
||||
config.access_token = 'YOUR ACCESS TOKEN'
|
||||
end
|
||||
|
||||
api_instance = Petstore::PetApi.new
|
||||
pet_id = 56 # Integer | ID of pet that needs to be updated
|
||||
opts = {
|
||||
name: 'name_example', # String | Updated name of the pet
|
||||
status: 'status_example' # String | Updated status of the pet
|
||||
}
|
||||
|
||||
begin
|
||||
#Updates a pet in the store with form data
|
||||
api_instance.update_pet_with_form(pet_id, opts)
|
||||
rescue Petstore::ApiError => e
|
||||
puts "Exception when calling PetApi->update_pet_with_form: #{e}"
|
||||
end
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**pet_id** | **Integer**| ID of pet that needs to be updated |
|
||||
**name** | **String**| Updated name of the pet | [optional]
|
||||
**status** | **String**| Updated status of the pet | [optional]
|
||||
|
||||
### Return type
|
||||
|
||||
nil (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
[petstore_auth](../README.md#petstore_auth)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/x-www-form-urlencoded
|
||||
- **Accept**: Not defined
|
||||
|
||||
|
||||
## upload_file
|
||||
|
||||
> ApiResponse upload_file(pet_id, opts)
|
||||
|
||||
uploads an image
|
||||
|
||||
### Example
|
||||
|
||||
```ruby
|
||||
# load the gem
|
||||
require 'petstore'
|
||||
# setup authorization
|
||||
Petstore.configure do |config|
|
||||
# Configure OAuth2 access token for authorization: petstore_auth
|
||||
config.access_token = 'YOUR ACCESS TOKEN'
|
||||
end
|
||||
|
||||
api_instance = Petstore::PetApi.new
|
||||
pet_id = 56 # Integer | ID of pet to update
|
||||
opts = {
|
||||
additional_metadata: 'additional_metadata_example', # String | Additional data to pass to server
|
||||
file: File.new('/path/to/file') # File | file to upload
|
||||
}
|
||||
|
||||
begin
|
||||
#uploads an image
|
||||
result = api_instance.upload_file(pet_id, opts)
|
||||
p result
|
||||
rescue Petstore::ApiError => e
|
||||
puts "Exception when calling PetApi->upload_file: #{e}"
|
||||
end
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**pet_id** | **Integer**| ID of pet to update |
|
||||
**additional_metadata** | **String**| Additional data to pass to server | [optional]
|
||||
**file** | **File**| file to upload | [optional]
|
||||
|
||||
### Return type
|
||||
|
||||
[**ApiResponse**](ApiResponse.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
[petstore_auth](../README.md#petstore_auth)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: multipart/form-data
|
||||
- **Accept**: application/json
|
||||
|
||||
|
||||
## upload_file_with_required_file
|
||||
|
||||
> ApiResponse upload_file_with_required_file(pet_id, required_file, opts)
|
||||
|
||||
uploads an image (required)
|
||||
|
||||
### Example
|
||||
|
||||
```ruby
|
||||
# load the gem
|
||||
require 'petstore'
|
||||
# setup authorization
|
||||
Petstore.configure do |config|
|
||||
# Configure OAuth2 access token for authorization: petstore_auth
|
||||
config.access_token = 'YOUR ACCESS TOKEN'
|
||||
end
|
||||
|
||||
api_instance = Petstore::PetApi.new
|
||||
pet_id = 56 # Integer | ID of pet to update
|
||||
required_file = File.new('/path/to/file') # File | file to upload
|
||||
opts = {
|
||||
additional_metadata: 'additional_metadata_example' # String | Additional data to pass to server
|
||||
}
|
||||
|
||||
begin
|
||||
#uploads an image (required)
|
||||
result = api_instance.upload_file_with_required_file(pet_id, required_file, opts)
|
||||
p result
|
||||
rescue Petstore::ApiError => e
|
||||
puts "Exception when calling PetApi->upload_file_with_required_file: #{e}"
|
||||
end
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**pet_id** | **Integer**| ID of pet to update |
|
||||
**required_file** | **File**| file to upload |
|
||||
**additional_metadata** | **String**| Additional data to pass to server | [optional]
|
||||
|
||||
### Return type
|
||||
|
||||
[**ApiResponse**](ApiResponse.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
[petstore_auth](../README.md#petstore_auth)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: multipart/form-data
|
||||
- **Accept**: application/json
|
||||
|
19
samples/client/petstore/ruby/docs/ReadOnlyFirst.md
Normal file
19
samples/client/petstore/ruby/docs/ReadOnlyFirst.md
Normal file
@ -0,0 +1,19 @@
|
||||
# Petstore::ReadOnlyFirst
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**bar** | **String** | | [optional] [readonly]
|
||||
**baz** | **String** | | [optional]
|
||||
|
||||
## Code Sample
|
||||
|
||||
```ruby
|
||||
require 'Petstore'
|
||||
|
||||
instance = Petstore::ReadOnlyFirst.new(bar: null,
|
||||
baz: null)
|
||||
```
|
||||
|
||||
|
17
samples/client/petstore/ruby/docs/SpecialModelName.md
Normal file
17
samples/client/petstore/ruby/docs/SpecialModelName.md
Normal file
@ -0,0 +1,17 @@
|
||||
# Petstore::SpecialModelName
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**special_property_name** | **Integer** | | [optional]
|
||||
|
||||
## Code Sample
|
||||
|
||||
```ruby
|
||||
require 'Petstore'
|
||||
|
||||
instance = Petstore::SpecialModelName.new(special_property_name: null)
|
||||
```
|
||||
|
||||
|
200
samples/client/petstore/ruby/docs/StoreApi.md
Normal file
200
samples/client/petstore/ruby/docs/StoreApi.md
Normal file
@ -0,0 +1,200 @@
|
||||
# Petstore::StoreApi
|
||||
|
||||
All URIs are relative to *http://petstore.swagger.io:80/v2*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
[**delete_order**](StoreApi.md#delete_order) | **DELETE** /store/order/{order_id} | Delete purchase order by ID
|
||||
[**get_inventory**](StoreApi.md#get_inventory) | **GET** /store/inventory | Returns pet inventories by status
|
||||
[**get_order_by_id**](StoreApi.md#get_order_by_id) | **GET** /store/order/{order_id} | Find purchase order by ID
|
||||
[**place_order**](StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet
|
||||
|
||||
|
||||
|
||||
## delete_order
|
||||
|
||||
> delete_order(order_id)
|
||||
|
||||
Delete purchase order by ID
|
||||
|
||||
For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
|
||||
### Example
|
||||
|
||||
```ruby
|
||||
# load the gem
|
||||
require 'petstore'
|
||||
|
||||
api_instance = Petstore::StoreApi.new
|
||||
order_id = 'order_id_example' # String | ID of the order that needs to be deleted
|
||||
|
||||
begin
|
||||
#Delete purchase order by ID
|
||||
api_instance.delete_order(order_id)
|
||||
rescue Petstore::ApiError => e
|
||||
puts "Exception when calling StoreApi->delete_order: #{e}"
|
||||
end
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**order_id** | **String**| ID of the order that needs to be deleted |
|
||||
|
||||
### Return type
|
||||
|
||||
nil (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: Not defined
|
||||
|
||||
|
||||
## get_inventory
|
||||
|
||||
> Hash<String, Integer> get_inventory
|
||||
|
||||
Returns pet inventories by status
|
||||
|
||||
Returns a map of status codes to quantities
|
||||
|
||||
### Example
|
||||
|
||||
```ruby
|
||||
# load the gem
|
||||
require 'petstore'
|
||||
# setup authorization
|
||||
Petstore.configure do |config|
|
||||
# Configure API key authorization: api_key
|
||||
config.api_key['api_key'] = 'YOUR API KEY'
|
||||
# Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
|
||||
#config.api_key_prefix['api_key'] = 'Bearer'
|
||||
end
|
||||
|
||||
api_instance = Petstore::StoreApi.new
|
||||
|
||||
begin
|
||||
#Returns pet inventories by status
|
||||
result = api_instance.get_inventory
|
||||
p result
|
||||
rescue Petstore::ApiError => e
|
||||
puts "Exception when calling StoreApi->get_inventory: #{e}"
|
||||
end
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
This endpoint does not need any parameter.
|
||||
|
||||
### Return type
|
||||
|
||||
**Hash<String, Integer>**
|
||||
|
||||
### Authorization
|
||||
|
||||
[api_key](../README.md#api_key)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/json
|
||||
|
||||
|
||||
## get_order_by_id
|
||||
|
||||
> Order get_order_by_id(order_id)
|
||||
|
||||
Find purchase order by ID
|
||||
|
||||
For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
|
||||
### Example
|
||||
|
||||
```ruby
|
||||
# load the gem
|
||||
require 'petstore'
|
||||
|
||||
api_instance = Petstore::StoreApi.new
|
||||
order_id = 56 # Integer | ID of pet that needs to be fetched
|
||||
|
||||
begin
|
||||
#Find purchase order by ID
|
||||
result = api_instance.get_order_by_id(order_id)
|
||||
p result
|
||||
rescue Petstore::ApiError => e
|
||||
puts "Exception when calling StoreApi->get_order_by_id: #{e}"
|
||||
end
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**order_id** | **Integer**| ID of pet that needs to be fetched |
|
||||
|
||||
### Return type
|
||||
|
||||
[**Order**](Order.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/xml, application/json
|
||||
|
||||
|
||||
## place_order
|
||||
|
||||
> Order place_order(body)
|
||||
|
||||
Place an order for a pet
|
||||
|
||||
### Example
|
||||
|
||||
```ruby
|
||||
# load the gem
|
||||
require 'petstore'
|
||||
|
||||
api_instance = Petstore::StoreApi.new
|
||||
body = Petstore::Order.new # Order | order placed for purchasing the pet
|
||||
|
||||
begin
|
||||
#Place an order for a pet
|
||||
result = api_instance.place_order(body)
|
||||
p result
|
||||
rescue Petstore::ApiError => e
|
||||
puts "Exception when calling StoreApi->place_order: #{e}"
|
||||
end
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**body** | [**Order**](Order.md)| order placed for purchasing the pet |
|
||||
|
||||
### Return type
|
||||
|
||||
[**Order**](Order.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/xml, application/json
|
||||
|
19
samples/client/petstore/ruby/docs/Tag.md
Normal file
19
samples/client/petstore/ruby/docs/Tag.md
Normal file
@ -0,0 +1,19 @@
|
||||
# Petstore::Tag
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**id** | **Integer** | | [optional]
|
||||
**name** | **String** | | [optional]
|
||||
|
||||
## Code Sample
|
||||
|
||||
```ruby
|
||||
require 'Petstore'
|
||||
|
||||
instance = Petstore::Tag.new(id: null,
|
||||
name: null)
|
||||
```
|
||||
|
||||
|
25
samples/client/petstore/ruby/docs/TypeHolderDefault.md
Normal file
25
samples/client/petstore/ruby/docs/TypeHolderDefault.md
Normal file
@ -0,0 +1,25 @@
|
||||
# Petstore::TypeHolderDefault
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**string_item** | **String** | | [default to 'what']
|
||||
**number_item** | **Float** | |
|
||||
**integer_item** | **Integer** | |
|
||||
**bool_item** | **Boolean** | | [default to true]
|
||||
**array_item** | **Array<Integer>** | |
|
||||
|
||||
## Code Sample
|
||||
|
||||
```ruby
|
||||
require 'Petstore'
|
||||
|
||||
instance = Petstore::TypeHolderDefault.new(string_item: null,
|
||||
number_item: null,
|
||||
integer_item: null,
|
||||
bool_item: null,
|
||||
array_item: null)
|
||||
```
|
||||
|
||||
|
27
samples/client/petstore/ruby/docs/TypeHolderExample.md
Normal file
27
samples/client/petstore/ruby/docs/TypeHolderExample.md
Normal file
@ -0,0 +1,27 @@
|
||||
# Petstore::TypeHolderExample
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**string_item** | **String** | |
|
||||
**number_item** | **Float** | |
|
||||
**float_item** | **Float** | |
|
||||
**integer_item** | **Integer** | |
|
||||
**bool_item** | **Boolean** | |
|
||||
**array_item** | **Array<Integer>** | |
|
||||
|
||||
## Code Sample
|
||||
|
||||
```ruby
|
||||
require 'Petstore'
|
||||
|
||||
instance = Petstore::TypeHolderExample.new(string_item: what,
|
||||
number_item: 1.234,
|
||||
float_item: 1.234,
|
||||
integer_item: -2,
|
||||
bool_item: true,
|
||||
array_item: [0, 1, 2, 3])
|
||||
```
|
||||
|
||||
|
31
samples/client/petstore/ruby/docs/User.md
Normal file
31
samples/client/petstore/ruby/docs/User.md
Normal file
@ -0,0 +1,31 @@
|
||||
# Petstore::User
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**id** | **Integer** | | [optional]
|
||||
**username** | **String** | | [optional]
|
||||
**first_name** | **String** | | [optional]
|
||||
**last_name** | **String** | | [optional]
|
||||
**email** | **String** | | [optional]
|
||||
**password** | **String** | | [optional]
|
||||
**phone** | **String** | | [optional]
|
||||
**user_status** | **Integer** | User Status | [optional]
|
||||
|
||||
## Code Sample
|
||||
|
||||
```ruby
|
||||
require 'Petstore'
|
||||
|
||||
instance = Petstore::User.new(id: null,
|
||||
username: null,
|
||||
first_name: null,
|
||||
last_name: null,
|
||||
email: null,
|
||||
password: null,
|
||||
phone: null,
|
||||
user_status: null)
|
||||
```
|
||||
|
||||
|
376
samples/client/petstore/ruby/docs/UserApi.md
Normal file
376
samples/client/petstore/ruby/docs/UserApi.md
Normal file
@ -0,0 +1,376 @@
|
||||
# Petstore::UserApi
|
||||
|
||||
All URIs are relative to *http://petstore.swagger.io:80/v2*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
[**create_user**](UserApi.md#create_user) | **POST** /user | Create user
|
||||
[**create_users_with_array_input**](UserApi.md#create_users_with_array_input) | **POST** /user/createWithArray | Creates list of users with given input array
|
||||
[**create_users_with_list_input**](UserApi.md#create_users_with_list_input) | **POST** /user/createWithList | Creates list of users with given input array
|
||||
[**delete_user**](UserApi.md#delete_user) | **DELETE** /user/{username} | Delete user
|
||||
[**get_user_by_name**](UserApi.md#get_user_by_name) | **GET** /user/{username} | Get user by user name
|
||||
[**login_user**](UserApi.md#login_user) | **GET** /user/login | Logs user into the system
|
||||
[**logout_user**](UserApi.md#logout_user) | **GET** /user/logout | Logs out current logged in user session
|
||||
[**update_user**](UserApi.md#update_user) | **PUT** /user/{username} | Updated user
|
||||
|
||||
|
||||
|
||||
## create_user
|
||||
|
||||
> create_user(body)
|
||||
|
||||
Create user
|
||||
|
||||
This can only be done by the logged in user.
|
||||
|
||||
### Example
|
||||
|
||||
```ruby
|
||||
# load the gem
|
||||
require 'petstore'
|
||||
|
||||
api_instance = Petstore::UserApi.new
|
||||
body = Petstore::User.new # User | Created user object
|
||||
|
||||
begin
|
||||
#Create user
|
||||
api_instance.create_user(body)
|
||||
rescue Petstore::ApiError => e
|
||||
puts "Exception when calling UserApi->create_user: #{e}"
|
||||
end
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**body** | [**User**](User.md)| Created user object |
|
||||
|
||||
### Return type
|
||||
|
||||
nil (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: Not defined
|
||||
|
||||
|
||||
## create_users_with_array_input
|
||||
|
||||
> create_users_with_array_input(body)
|
||||
|
||||
Creates list of users with given input array
|
||||
|
||||
### Example
|
||||
|
||||
```ruby
|
||||
# load the gem
|
||||
require 'petstore'
|
||||
|
||||
api_instance = Petstore::UserApi.new
|
||||
body = [Petstore::User.new] # Array<User> | List of user object
|
||||
|
||||
begin
|
||||
#Creates list of users with given input array
|
||||
api_instance.create_users_with_array_input(body)
|
||||
rescue Petstore::ApiError => e
|
||||
puts "Exception when calling UserApi->create_users_with_array_input: #{e}"
|
||||
end
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**body** | [**Array<User>**](User.md)| List of user object |
|
||||
|
||||
### Return type
|
||||
|
||||
nil (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: Not defined
|
||||
|
||||
|
||||
## create_users_with_list_input
|
||||
|
||||
> create_users_with_list_input(body)
|
||||
|
||||
Creates list of users with given input array
|
||||
|
||||
### Example
|
||||
|
||||
```ruby
|
||||
# load the gem
|
||||
require 'petstore'
|
||||
|
||||
api_instance = Petstore::UserApi.new
|
||||
body = [Petstore::User.new] # Array<User> | List of user object
|
||||
|
||||
begin
|
||||
#Creates list of users with given input array
|
||||
api_instance.create_users_with_list_input(body)
|
||||
rescue Petstore::ApiError => e
|
||||
puts "Exception when calling UserApi->create_users_with_list_input: #{e}"
|
||||
end
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**body** | [**Array<User>**](User.md)| List of user object |
|
||||
|
||||
### Return type
|
||||
|
||||
nil (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: Not defined
|
||||
|
||||
|
||||
## delete_user
|
||||
|
||||
> delete_user(username)
|
||||
|
||||
Delete user
|
||||
|
||||
This can only be done by the logged in user.
|
||||
|
||||
### Example
|
||||
|
||||
```ruby
|
||||
# load the gem
|
||||
require 'petstore'
|
||||
|
||||
api_instance = Petstore::UserApi.new
|
||||
username = 'username_example' # String | The name that needs to be deleted
|
||||
|
||||
begin
|
||||
#Delete user
|
||||
api_instance.delete_user(username)
|
||||
rescue Petstore::ApiError => e
|
||||
puts "Exception when calling UserApi->delete_user: #{e}"
|
||||
end
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**username** | **String**| The name that needs to be deleted |
|
||||
|
||||
### Return type
|
||||
|
||||
nil (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: Not defined
|
||||
|
||||
|
||||
## get_user_by_name
|
||||
|
||||
> User get_user_by_name(username)
|
||||
|
||||
Get user by user name
|
||||
|
||||
### Example
|
||||
|
||||
```ruby
|
||||
# load the gem
|
||||
require 'petstore'
|
||||
|
||||
api_instance = Petstore::UserApi.new
|
||||
username = 'username_example' # String | The name that needs to be fetched. Use user1 for testing.
|
||||
|
||||
begin
|
||||
#Get user by user name
|
||||
result = api_instance.get_user_by_name(username)
|
||||
p result
|
||||
rescue Petstore::ApiError => e
|
||||
puts "Exception when calling UserApi->get_user_by_name: #{e}"
|
||||
end
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**username** | **String**| The name that needs to be fetched. Use user1 for testing. |
|
||||
|
||||
### Return type
|
||||
|
||||
[**User**](User.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/xml, application/json
|
||||
|
||||
|
||||
## login_user
|
||||
|
||||
> String login_user(username, password)
|
||||
|
||||
Logs user into the system
|
||||
|
||||
### Example
|
||||
|
||||
```ruby
|
||||
# load the gem
|
||||
require 'petstore'
|
||||
|
||||
api_instance = Petstore::UserApi.new
|
||||
username = 'username_example' # String | The user name for login
|
||||
password = 'password_example' # String | The password for login in clear text
|
||||
|
||||
begin
|
||||
#Logs user into the system
|
||||
result = api_instance.login_user(username, password)
|
||||
p result
|
||||
rescue Petstore::ApiError => e
|
||||
puts "Exception when calling UserApi->login_user: #{e}"
|
||||
end
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**username** | **String**| The user name for login |
|
||||
**password** | **String**| The password for login in clear text |
|
||||
|
||||
### Return type
|
||||
|
||||
**String**
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/xml, application/json
|
||||
|
||||
|
||||
## logout_user
|
||||
|
||||
> logout_user
|
||||
|
||||
Logs out current logged in user session
|
||||
|
||||
### Example
|
||||
|
||||
```ruby
|
||||
# load the gem
|
||||
require 'petstore'
|
||||
|
||||
api_instance = Petstore::UserApi.new
|
||||
|
||||
begin
|
||||
#Logs out current logged in user session
|
||||
api_instance.logout_user
|
||||
rescue Petstore::ApiError => e
|
||||
puts "Exception when calling UserApi->logout_user: #{e}"
|
||||
end
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
This endpoint does not need any parameter.
|
||||
|
||||
### Return type
|
||||
|
||||
nil (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: Not defined
|
||||
|
||||
|
||||
## update_user
|
||||
|
||||
> update_user(username, body)
|
||||
|
||||
Updated user
|
||||
|
||||
This can only be done by the logged in user.
|
||||
|
||||
### Example
|
||||
|
||||
```ruby
|
||||
# load the gem
|
||||
require 'petstore'
|
||||
|
||||
api_instance = Petstore::UserApi.new
|
||||
username = 'username_example' # String | name that need to be deleted
|
||||
body = Petstore::User.new # User | Updated user object
|
||||
|
||||
begin
|
||||
#Updated user
|
||||
api_instance.update_user(username, body)
|
||||
rescue Petstore::ApiError => e
|
||||
puts "Exception when calling UserApi->update_user: #{e}"
|
||||
end
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**username** | **String**| name that need to be deleted |
|
||||
**body** | [**User**](User.md)| Updated user object |
|
||||
|
||||
### Return type
|
||||
|
||||
nil (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: Not defined
|
||||
|
73
samples/client/petstore/ruby/docs/XmlItem.md
Normal file
73
samples/client/petstore/ruby/docs/XmlItem.md
Normal file
@ -0,0 +1,73 @@
|
||||
# Petstore::XmlItem
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**attribute_string** | **String** | | [optional]
|
||||
**attribute_number** | **Float** | | [optional]
|
||||
**attribute_integer** | **Integer** | | [optional]
|
||||
**attribute_boolean** | **Boolean** | | [optional]
|
||||
**wrapped_array** | **Array<Integer>** | | [optional]
|
||||
**name_string** | **String** | | [optional]
|
||||
**name_number** | **Float** | | [optional]
|
||||
**name_integer** | **Integer** | | [optional]
|
||||
**name_boolean** | **Boolean** | | [optional]
|
||||
**name_array** | **Array<Integer>** | | [optional]
|
||||
**name_wrapped_array** | **Array<Integer>** | | [optional]
|
||||
**prefix_string** | **String** | | [optional]
|
||||
**prefix_number** | **Float** | | [optional]
|
||||
**prefix_integer** | **Integer** | | [optional]
|
||||
**prefix_boolean** | **Boolean** | | [optional]
|
||||
**prefix_array** | **Array<Integer>** | | [optional]
|
||||
**prefix_wrapped_array** | **Array<Integer>** | | [optional]
|
||||
**namespace_string** | **String** | | [optional]
|
||||
**namespace_number** | **Float** | | [optional]
|
||||
**namespace_integer** | **Integer** | | [optional]
|
||||
**namespace_boolean** | **Boolean** | | [optional]
|
||||
**namespace_array** | **Array<Integer>** | | [optional]
|
||||
**namespace_wrapped_array** | **Array<Integer>** | | [optional]
|
||||
**prefix_ns_string** | **String** | | [optional]
|
||||
**prefix_ns_number** | **Float** | | [optional]
|
||||
**prefix_ns_integer** | **Integer** | | [optional]
|
||||
**prefix_ns_boolean** | **Boolean** | | [optional]
|
||||
**prefix_ns_array** | **Array<Integer>** | | [optional]
|
||||
**prefix_ns_wrapped_array** | **Array<Integer>** | | [optional]
|
||||
|
||||
## Code Sample
|
||||
|
||||
```ruby
|
||||
require 'Petstore'
|
||||
|
||||
instance = Petstore::XmlItem.new(attribute_string: string,
|
||||
attribute_number: 1.234,
|
||||
attribute_integer: -2,
|
||||
attribute_boolean: true,
|
||||
wrapped_array: null,
|
||||
name_string: string,
|
||||
name_number: 1.234,
|
||||
name_integer: -2,
|
||||
name_boolean: true,
|
||||
name_array: null,
|
||||
name_wrapped_array: null,
|
||||
prefix_string: string,
|
||||
prefix_number: 1.234,
|
||||
prefix_integer: -2,
|
||||
prefix_boolean: true,
|
||||
prefix_array: null,
|
||||
prefix_wrapped_array: null,
|
||||
namespace_string: string,
|
||||
namespace_number: 1.234,
|
||||
namespace_integer: -2,
|
||||
namespace_boolean: true,
|
||||
namespace_array: null,
|
||||
namespace_wrapped_array: null,
|
||||
prefix_ns_string: string,
|
||||
prefix_ns_number: 1.234,
|
||||
prefix_ns_integer: -2,
|
||||
prefix_ns_boolean: true,
|
||||
prefix_ns_array: null,
|
||||
prefix_ns_wrapped_array: null)
|
||||
```
|
||||
|
||||
|
91
samples/client/petstore/ruby/lib/petstore.rb
Normal file
91
samples/client/petstore/ruby/lib/petstore.rb
Normal file
@ -0,0 +1,91 @@
|
||||
=begin
|
||||
#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: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
Generated by: https://openapi-generator.tech
|
||||
OpenAPI Generator version: 4.2.0-SNAPSHOT
|
||||
|
||||
=end
|
||||
|
||||
# Common files
|
||||
require 'petstore/api_client'
|
||||
require 'petstore/api_error'
|
||||
require 'petstore/version'
|
||||
require 'petstore/configuration'
|
||||
|
||||
# Models
|
||||
require 'petstore/models/additional_properties_any_type'
|
||||
require 'petstore/models/additional_properties_array'
|
||||
require 'petstore/models/additional_properties_boolean'
|
||||
require 'petstore/models/additional_properties_class'
|
||||
require 'petstore/models/additional_properties_integer'
|
||||
require 'petstore/models/additional_properties_number'
|
||||
require 'petstore/models/additional_properties_object'
|
||||
require 'petstore/models/additional_properties_string'
|
||||
require 'petstore/models/animal'
|
||||
require 'petstore/models/api_response'
|
||||
require 'petstore/models/array_of_array_of_number_only'
|
||||
require 'petstore/models/array_of_number_only'
|
||||
require 'petstore/models/array_test'
|
||||
require 'petstore/models/capitalization'
|
||||
require 'petstore/models/cat'
|
||||
require 'petstore/models/cat_all_of'
|
||||
require 'petstore/models/category'
|
||||
require 'petstore/models/class_model'
|
||||
require 'petstore/models/client'
|
||||
require 'petstore/models/dog'
|
||||
require 'petstore/models/dog_all_of'
|
||||
require 'petstore/models/enum_arrays'
|
||||
require 'petstore/models/enum_class'
|
||||
require 'petstore/models/enum_test'
|
||||
require 'petstore/models/file'
|
||||
require 'petstore/models/file_schema_test_class'
|
||||
require 'petstore/models/format_test'
|
||||
require 'petstore/models/has_only_read_only'
|
||||
require 'petstore/models/list'
|
||||
require 'petstore/models/map_test'
|
||||
require 'petstore/models/mixed_properties_and_additional_properties_class'
|
||||
require 'petstore/models/model200_response'
|
||||
require 'petstore/models/model_return'
|
||||
require 'petstore/models/name'
|
||||
require 'petstore/models/number_only'
|
||||
require 'petstore/models/order'
|
||||
require 'petstore/models/outer_composite'
|
||||
require 'petstore/models/outer_enum'
|
||||
require 'petstore/models/pet'
|
||||
require 'petstore/models/read_only_first'
|
||||
require 'petstore/models/special_model_name'
|
||||
require 'petstore/models/tag'
|
||||
require 'petstore/models/type_holder_default'
|
||||
require 'petstore/models/type_holder_example'
|
||||
require 'petstore/models/user'
|
||||
require 'petstore/models/xml_item'
|
||||
|
||||
# APIs
|
||||
require 'petstore/api/another_fake_api'
|
||||
require 'petstore/api/fake_api'
|
||||
require 'petstore/api/fake_classname_tags123_api'
|
||||
require 'petstore/api/pet_api'
|
||||
require 'petstore/api/store_api'
|
||||
require 'petstore/api/user_api'
|
||||
|
||||
module Petstore
|
||||
class << self
|
||||
# Customize default settings for the SDK using block.
|
||||
# Petstore.configure do |config|
|
||||
# config.username = "xxx"
|
||||
# config.password = "xxx"
|
||||
# end
|
||||
# If no block given, return the default Configuration object.
|
||||
def configure
|
||||
if block_given?
|
||||
yield(Configuration.default)
|
||||
else
|
||||
Configuration.default
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,86 @@
|
||||
=begin
|
||||
#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: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
Generated by: https://openapi-generator.tech
|
||||
OpenAPI Generator version: 4.2.0-SNAPSHOT
|
||||
|
||||
=end
|
||||
|
||||
require 'cgi'
|
||||
|
||||
module Petstore
|
||||
class AnotherFakeApi
|
||||
attr_accessor :api_client
|
||||
|
||||
def initialize(api_client = ApiClient.default)
|
||||
@api_client = api_client
|
||||
end
|
||||
# To test special tags
|
||||
# To test special tags and operation ID starting with number
|
||||
# @param body [Client] client model
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [Client]
|
||||
def call_123_test_special_tags(body, opts = {})
|
||||
data, _status_code, _headers = call_123_test_special_tags_with_http_info(body, opts)
|
||||
data
|
||||
end
|
||||
|
||||
# To test special tags
|
||||
# To test special tags and operation ID starting with number
|
||||
# @param body [Client] client model
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [Array<(Client, Integer, Hash)>] Client data, response status code and response headers
|
||||
def call_123_test_special_tags_with_http_info(body, opts = {})
|
||||
if @api_client.config.debugging
|
||||
@api_client.config.logger.debug 'Calling API: AnotherFakeApi.call_123_test_special_tags ...'
|
||||
end
|
||||
# verify the required parameter 'body' is set
|
||||
if @api_client.config.client_side_validation && body.nil?
|
||||
fail ArgumentError, "Missing the required parameter 'body' when calling AnotherFakeApi.call_123_test_special_tags"
|
||||
end
|
||||
# resource path
|
||||
local_var_path = '/another-fake/dummy'
|
||||
|
||||
# query parameters
|
||||
query_params = opts[:query_params] || {}
|
||||
|
||||
# header parameters
|
||||
header_params = opts[:header_params] || {}
|
||||
# HTTP header 'Accept' (if needed)
|
||||
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
||||
# HTTP header 'Content-Type'
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
|
||||
|
||||
# form parameters
|
||||
form_params = opts[:form_params] || {}
|
||||
|
||||
# http body (model)
|
||||
post_body = opts[:body] || @api_client.object_to_http_body(body)
|
||||
|
||||
# return_type
|
||||
return_type = opts[:return_type] || 'Client'
|
||||
|
||||
# auth_names
|
||||
auth_names = opts[:auth_names] || []
|
||||
|
||||
new_options = opts.merge(
|
||||
:header_params => header_params,
|
||||
:query_params => query_params,
|
||||
:form_params => form_params,
|
||||
:body => post_body,
|
||||
:auth_names => auth_names,
|
||||
:return_type => return_type
|
||||
)
|
||||
|
||||
data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)
|
||||
if @api_client.config.debugging
|
||||
@api_client.config.logger.debug "API called: AnotherFakeApi#call_123_test_special_tags\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
||||
end
|
||||
return data, status_code, headers
|
||||
end
|
||||
end
|
||||
end
|
1076
samples/client/petstore/ruby/lib/petstore/api/fake_api.rb
Normal file
1076
samples/client/petstore/ruby/lib/petstore/api/fake_api.rb
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,86 @@
|
||||
=begin
|
||||
#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: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
Generated by: https://openapi-generator.tech
|
||||
OpenAPI Generator version: 4.2.0-SNAPSHOT
|
||||
|
||||
=end
|
||||
|
||||
require 'cgi'
|
||||
|
||||
module Petstore
|
||||
class FakeClassnameTags123Api
|
||||
attr_accessor :api_client
|
||||
|
||||
def initialize(api_client = ApiClient.default)
|
||||
@api_client = api_client
|
||||
end
|
||||
# To test class name in snake case
|
||||
# To test class name in snake case
|
||||
# @param body [Client] client model
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [Client]
|
||||
def test_classname(body, opts = {})
|
||||
data, _status_code, _headers = test_classname_with_http_info(body, opts)
|
||||
data
|
||||
end
|
||||
|
||||
# To test class name in snake case
|
||||
# To test class name in snake case
|
||||
# @param body [Client] client model
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [Array<(Client, Integer, Hash)>] Client data, response status code and response headers
|
||||
def test_classname_with_http_info(body, opts = {})
|
||||
if @api_client.config.debugging
|
||||
@api_client.config.logger.debug 'Calling API: FakeClassnameTags123Api.test_classname ...'
|
||||
end
|
||||
# verify the required parameter 'body' is set
|
||||
if @api_client.config.client_side_validation && body.nil?
|
||||
fail ArgumentError, "Missing the required parameter 'body' when calling FakeClassnameTags123Api.test_classname"
|
||||
end
|
||||
# resource path
|
||||
local_var_path = '/fake_classname_test'
|
||||
|
||||
# query parameters
|
||||
query_params = opts[:query_params] || {}
|
||||
|
||||
# header parameters
|
||||
header_params = opts[:header_params] || {}
|
||||
# HTTP header 'Accept' (if needed)
|
||||
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
||||
# HTTP header 'Content-Type'
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
|
||||
|
||||
# form parameters
|
||||
form_params = opts[:form_params] || {}
|
||||
|
||||
# http body (model)
|
||||
post_body = opts[:body] || @api_client.object_to_http_body(body)
|
||||
|
||||
# return_type
|
||||
return_type = opts[:return_type] || 'Client'
|
||||
|
||||
# auth_names
|
||||
auth_names = opts[:auth_names] || ['api_key_query']
|
||||
|
||||
new_options = opts.merge(
|
||||
:header_params => header_params,
|
||||
:query_params => query_params,
|
||||
:form_params => form_params,
|
||||
:body => post_body,
|
||||
:auth_names => auth_names,
|
||||
:return_type => return_type
|
||||
)
|
||||
|
||||
data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)
|
||||
if @api_client.config.debugging
|
||||
@api_client.config.logger.debug "API called: FakeClassnameTags123Api#test_classname\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
||||
end
|
||||
return data, status_code, headers
|
||||
end
|
||||
end
|
||||
end
|
597
samples/client/petstore/ruby/lib/petstore/api/pet_api.rb
Normal file
597
samples/client/petstore/ruby/lib/petstore/api/pet_api.rb
Normal file
@ -0,0 +1,597 @@
|
||||
=begin
|
||||
#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: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
Generated by: https://openapi-generator.tech
|
||||
OpenAPI Generator version: 4.2.0-SNAPSHOT
|
||||
|
||||
=end
|
||||
|
||||
require 'cgi'
|
||||
|
||||
module Petstore
|
||||
class PetApi
|
||||
attr_accessor :api_client
|
||||
|
||||
def initialize(api_client = ApiClient.default)
|
||||
@api_client = api_client
|
||||
end
|
||||
# Add a new pet to the store
|
||||
# @param body [Pet] Pet object that needs to be added to the store
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [nil]
|
||||
def add_pet(body, opts = {})
|
||||
add_pet_with_http_info(body, opts)
|
||||
nil
|
||||
end
|
||||
|
||||
# Add a new pet to the store
|
||||
# @param body [Pet] Pet object that needs to be added to the store
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
|
||||
def add_pet_with_http_info(body, opts = {})
|
||||
if @api_client.config.debugging
|
||||
@api_client.config.logger.debug 'Calling API: PetApi.add_pet ...'
|
||||
end
|
||||
# verify the required parameter 'body' is set
|
||||
if @api_client.config.client_side_validation && body.nil?
|
||||
fail ArgumentError, "Missing the required parameter 'body' when calling PetApi.add_pet"
|
||||
end
|
||||
# resource path
|
||||
local_var_path = '/pet'
|
||||
|
||||
# query parameters
|
||||
query_params = opts[:query_params] || {}
|
||||
|
||||
# header parameters
|
||||
header_params = opts[:header_params] || {}
|
||||
# HTTP header 'Content-Type'
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'application/xml'])
|
||||
|
||||
# form parameters
|
||||
form_params = opts[:form_params] || {}
|
||||
|
||||
# http body (model)
|
||||
post_body = opts[:body] || @api_client.object_to_http_body(body)
|
||||
|
||||
# return_type
|
||||
return_type = opts[:return_type]
|
||||
|
||||
# auth_names
|
||||
auth_names = opts[:auth_names] || ['petstore_auth']
|
||||
|
||||
new_options = opts.merge(
|
||||
:header_params => header_params,
|
||||
:query_params => query_params,
|
||||
:form_params => form_params,
|
||||
:body => post_body,
|
||||
:auth_names => auth_names,
|
||||
:return_type => return_type
|
||||
)
|
||||
|
||||
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
|
||||
if @api_client.config.debugging
|
||||
@api_client.config.logger.debug "API called: PetApi#add_pet\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
||||
end
|
||||
return data, status_code, headers
|
||||
end
|
||||
|
||||
# Deletes a pet
|
||||
# @param pet_id [Integer] Pet id to delete
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @option opts [String] :api_key
|
||||
# @return [nil]
|
||||
def delete_pet(pet_id, opts = {})
|
||||
delete_pet_with_http_info(pet_id, opts)
|
||||
nil
|
||||
end
|
||||
|
||||
# Deletes a pet
|
||||
# @param pet_id [Integer] Pet id to delete
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @option opts [String] :api_key
|
||||
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
|
||||
def delete_pet_with_http_info(pet_id, opts = {})
|
||||
if @api_client.config.debugging
|
||||
@api_client.config.logger.debug 'Calling API: PetApi.delete_pet ...'
|
||||
end
|
||||
# verify the required parameter 'pet_id' is set
|
||||
if @api_client.config.client_side_validation && pet_id.nil?
|
||||
fail ArgumentError, "Missing the required parameter 'pet_id' when calling PetApi.delete_pet"
|
||||
end
|
||||
# resource path
|
||||
local_var_path = '/pet/{petId}'.sub('{' + 'petId' + '}', CGI.escape(pet_id.to_s).gsub('%2F', '/'))
|
||||
|
||||
# query parameters
|
||||
query_params = opts[:query_params] || {}
|
||||
|
||||
# header parameters
|
||||
header_params = opts[:header_params] || {}
|
||||
header_params[:'api_key'] = opts[:'api_key'] if !opts[:'api_key'].nil?
|
||||
|
||||
# form parameters
|
||||
form_params = opts[:form_params] || {}
|
||||
|
||||
# http body (model)
|
||||
post_body = opts[:body]
|
||||
|
||||
# return_type
|
||||
return_type = opts[:return_type]
|
||||
|
||||
# auth_names
|
||||
auth_names = opts[:auth_names] || ['petstore_auth']
|
||||
|
||||
new_options = opts.merge(
|
||||
:header_params => header_params,
|
||||
:query_params => query_params,
|
||||
:form_params => form_params,
|
||||
:body => post_body,
|
||||
:auth_names => auth_names,
|
||||
:return_type => return_type
|
||||
)
|
||||
|
||||
data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
|
||||
if @api_client.config.debugging
|
||||
@api_client.config.logger.debug "API called: PetApi#delete_pet\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
||||
end
|
||||
return data, status_code, headers
|
||||
end
|
||||
|
||||
# Finds Pets by status
|
||||
# Multiple status values can be provided with comma separated strings
|
||||
# @param status [Array<String>] Status values that need to be considered for filter
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [Array<Pet>]
|
||||
def find_pets_by_status(status, opts = {})
|
||||
data, _status_code, _headers = find_pets_by_status_with_http_info(status, opts)
|
||||
data
|
||||
end
|
||||
|
||||
# Finds Pets by status
|
||||
# Multiple status values can be provided with comma separated strings
|
||||
# @param status [Array<String>] Status values that need to be considered for filter
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [Array<(Array<Pet>, Integer, Hash)>] Array<Pet> data, response status code and response headers
|
||||
def find_pets_by_status_with_http_info(status, opts = {})
|
||||
if @api_client.config.debugging
|
||||
@api_client.config.logger.debug 'Calling API: PetApi.find_pets_by_status ...'
|
||||
end
|
||||
# verify the required parameter 'status' is set
|
||||
if @api_client.config.client_side_validation && status.nil?
|
||||
fail ArgumentError, "Missing the required parameter 'status' when calling PetApi.find_pets_by_status"
|
||||
end
|
||||
# resource path
|
||||
local_var_path = '/pet/findByStatus'
|
||||
|
||||
# query parameters
|
||||
query_params = opts[:query_params] || {}
|
||||
query_params[:'status'] = @api_client.build_collection_param(status, :csv)
|
||||
|
||||
# header parameters
|
||||
header_params = opts[:header_params] || {}
|
||||
# HTTP header 'Accept' (if needed)
|
||||
header_params['Accept'] = @api_client.select_header_accept(['application/xml', 'application/json'])
|
||||
|
||||
# form parameters
|
||||
form_params = opts[:form_params] || {}
|
||||
|
||||
# http body (model)
|
||||
post_body = opts[:body]
|
||||
|
||||
# return_type
|
||||
return_type = opts[:return_type] || 'Array<Pet>'
|
||||
|
||||
# auth_names
|
||||
auth_names = opts[:auth_names] || ['petstore_auth']
|
||||
|
||||
new_options = opts.merge(
|
||||
:header_params => header_params,
|
||||
:query_params => query_params,
|
||||
:form_params => form_params,
|
||||
:body => post_body,
|
||||
:auth_names => auth_names,
|
||||
:return_type => return_type
|
||||
)
|
||||
|
||||
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
|
||||
if @api_client.config.debugging
|
||||
@api_client.config.logger.debug "API called: PetApi#find_pets_by_status\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
||||
end
|
||||
return data, status_code, headers
|
||||
end
|
||||
|
||||
# Finds Pets by tags
|
||||
# Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||
# @param tags [Array<String>] Tags to filter by
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [Array<Pet>]
|
||||
def find_pets_by_tags(tags, opts = {})
|
||||
data, _status_code, _headers = find_pets_by_tags_with_http_info(tags, opts)
|
||||
data
|
||||
end
|
||||
|
||||
# Finds Pets by tags
|
||||
# Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||
# @param tags [Array<String>] Tags to filter by
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [Array<(Array<Pet>, Integer, Hash)>] Array<Pet> data, response status code and response headers
|
||||
def find_pets_by_tags_with_http_info(tags, opts = {})
|
||||
if @api_client.config.debugging
|
||||
@api_client.config.logger.debug 'Calling API: PetApi.find_pets_by_tags ...'
|
||||
end
|
||||
# verify the required parameter 'tags' is set
|
||||
if @api_client.config.client_side_validation && tags.nil?
|
||||
fail ArgumentError, "Missing the required parameter 'tags' when calling PetApi.find_pets_by_tags"
|
||||
end
|
||||
# resource path
|
||||
local_var_path = '/pet/findByTags'
|
||||
|
||||
# query parameters
|
||||
query_params = opts[:query_params] || {}
|
||||
query_params[:'tags'] = @api_client.build_collection_param(tags, :csv)
|
||||
|
||||
# header parameters
|
||||
header_params = opts[:header_params] || {}
|
||||
# HTTP header 'Accept' (if needed)
|
||||
header_params['Accept'] = @api_client.select_header_accept(['application/xml', 'application/json'])
|
||||
|
||||
# form parameters
|
||||
form_params = opts[:form_params] || {}
|
||||
|
||||
# http body (model)
|
||||
post_body = opts[:body]
|
||||
|
||||
# return_type
|
||||
return_type = opts[:return_type] || 'Array<Pet>'
|
||||
|
||||
# auth_names
|
||||
auth_names = opts[:auth_names] || ['petstore_auth']
|
||||
|
||||
new_options = opts.merge(
|
||||
:header_params => header_params,
|
||||
:query_params => query_params,
|
||||
:form_params => form_params,
|
||||
:body => post_body,
|
||||
:auth_names => auth_names,
|
||||
:return_type => return_type
|
||||
)
|
||||
|
||||
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
|
||||
if @api_client.config.debugging
|
||||
@api_client.config.logger.debug "API called: PetApi#find_pets_by_tags\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
||||
end
|
||||
return data, status_code, headers
|
||||
end
|
||||
|
||||
# Find pet by ID
|
||||
# Returns a single pet
|
||||
# @param pet_id [Integer] ID of pet to return
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [Pet]
|
||||
def get_pet_by_id(pet_id, opts = {})
|
||||
data, _status_code, _headers = get_pet_by_id_with_http_info(pet_id, opts)
|
||||
data
|
||||
end
|
||||
|
||||
# Find pet by ID
|
||||
# Returns a single pet
|
||||
# @param pet_id [Integer] ID of pet to return
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [Array<(Pet, Integer, Hash)>] Pet data, response status code and response headers
|
||||
def get_pet_by_id_with_http_info(pet_id, opts = {})
|
||||
if @api_client.config.debugging
|
||||
@api_client.config.logger.debug 'Calling API: PetApi.get_pet_by_id ...'
|
||||
end
|
||||
# verify the required parameter 'pet_id' is set
|
||||
if @api_client.config.client_side_validation && pet_id.nil?
|
||||
fail ArgumentError, "Missing the required parameter 'pet_id' when calling PetApi.get_pet_by_id"
|
||||
end
|
||||
# resource path
|
||||
local_var_path = '/pet/{petId}'.sub('{' + 'petId' + '}', CGI.escape(pet_id.to_s).gsub('%2F', '/'))
|
||||
|
||||
# query parameters
|
||||
query_params = opts[:query_params] || {}
|
||||
|
||||
# header parameters
|
||||
header_params = opts[:header_params] || {}
|
||||
# HTTP header 'Accept' (if needed)
|
||||
header_params['Accept'] = @api_client.select_header_accept(['application/xml', 'application/json'])
|
||||
|
||||
# form parameters
|
||||
form_params = opts[:form_params] || {}
|
||||
|
||||
# http body (model)
|
||||
post_body = opts[:body]
|
||||
|
||||
# return_type
|
||||
return_type = opts[:return_type] || 'Pet'
|
||||
|
||||
# auth_names
|
||||
auth_names = opts[:auth_names] || ['api_key']
|
||||
|
||||
new_options = opts.merge(
|
||||
:header_params => header_params,
|
||||
:query_params => query_params,
|
||||
:form_params => form_params,
|
||||
:body => post_body,
|
||||
:auth_names => auth_names,
|
||||
:return_type => return_type
|
||||
)
|
||||
|
||||
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
|
||||
if @api_client.config.debugging
|
||||
@api_client.config.logger.debug "API called: PetApi#get_pet_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
||||
end
|
||||
return data, status_code, headers
|
||||
end
|
||||
|
||||
# Update an existing pet
|
||||
# @param body [Pet] Pet object that needs to be added to the store
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [nil]
|
||||
def update_pet(body, opts = {})
|
||||
update_pet_with_http_info(body, opts)
|
||||
nil
|
||||
end
|
||||
|
||||
# Update an existing pet
|
||||
# @param body [Pet] Pet object that needs to be added to the store
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
|
||||
def update_pet_with_http_info(body, opts = {})
|
||||
if @api_client.config.debugging
|
||||
@api_client.config.logger.debug 'Calling API: PetApi.update_pet ...'
|
||||
end
|
||||
# verify the required parameter 'body' is set
|
||||
if @api_client.config.client_side_validation && body.nil?
|
||||
fail ArgumentError, "Missing the required parameter 'body' when calling PetApi.update_pet"
|
||||
end
|
||||
# resource path
|
||||
local_var_path = '/pet'
|
||||
|
||||
# query parameters
|
||||
query_params = opts[:query_params] || {}
|
||||
|
||||
# header parameters
|
||||
header_params = opts[:header_params] || {}
|
||||
# HTTP header 'Content-Type'
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'application/xml'])
|
||||
|
||||
# form parameters
|
||||
form_params = opts[:form_params] || {}
|
||||
|
||||
# http body (model)
|
||||
post_body = opts[:body] || @api_client.object_to_http_body(body)
|
||||
|
||||
# return_type
|
||||
return_type = opts[:return_type]
|
||||
|
||||
# auth_names
|
||||
auth_names = opts[:auth_names] || ['petstore_auth']
|
||||
|
||||
new_options = opts.merge(
|
||||
:header_params => header_params,
|
||||
:query_params => query_params,
|
||||
:form_params => form_params,
|
||||
:body => post_body,
|
||||
:auth_names => auth_names,
|
||||
:return_type => return_type
|
||||
)
|
||||
|
||||
data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)
|
||||
if @api_client.config.debugging
|
||||
@api_client.config.logger.debug "API called: PetApi#update_pet\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
||||
end
|
||||
return data, status_code, headers
|
||||
end
|
||||
|
||||
# Updates a pet in the store with form data
|
||||
# @param pet_id [Integer] ID of pet that needs to be updated
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @option opts [String] :name Updated name of the pet
|
||||
# @option opts [String] :status Updated status of the pet
|
||||
# @return [nil]
|
||||
def update_pet_with_form(pet_id, opts = {})
|
||||
update_pet_with_form_with_http_info(pet_id, opts)
|
||||
nil
|
||||
end
|
||||
|
||||
# Updates a pet in the store with form data
|
||||
# @param pet_id [Integer] ID of pet that needs to be updated
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @option opts [String] :name Updated name of the pet
|
||||
# @option opts [String] :status Updated status of the pet
|
||||
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
|
||||
def update_pet_with_form_with_http_info(pet_id, opts = {})
|
||||
if @api_client.config.debugging
|
||||
@api_client.config.logger.debug 'Calling API: PetApi.update_pet_with_form ...'
|
||||
end
|
||||
# verify the required parameter 'pet_id' is set
|
||||
if @api_client.config.client_side_validation && pet_id.nil?
|
||||
fail ArgumentError, "Missing the required parameter 'pet_id' when calling PetApi.update_pet_with_form"
|
||||
end
|
||||
# resource path
|
||||
local_var_path = '/pet/{petId}'.sub('{' + 'petId' + '}', CGI.escape(pet_id.to_s).gsub('%2F', '/'))
|
||||
|
||||
# query parameters
|
||||
query_params = opts[:query_params] || {}
|
||||
|
||||
# header parameters
|
||||
header_params = opts[:header_params] || {}
|
||||
# HTTP header 'Content-Type'
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(['application/x-www-form-urlencoded'])
|
||||
|
||||
# form parameters
|
||||
form_params = opts[:form_params] || {}
|
||||
form_params['name'] = opts[:'name'] if !opts[:'name'].nil?
|
||||
form_params['status'] = opts[:'status'] if !opts[:'status'].nil?
|
||||
|
||||
# http body (model)
|
||||
post_body = opts[:body]
|
||||
|
||||
# return_type
|
||||
return_type = opts[:return_type]
|
||||
|
||||
# auth_names
|
||||
auth_names = opts[:auth_names] || ['petstore_auth']
|
||||
|
||||
new_options = opts.merge(
|
||||
:header_params => header_params,
|
||||
:query_params => query_params,
|
||||
:form_params => form_params,
|
||||
:body => post_body,
|
||||
:auth_names => auth_names,
|
||||
:return_type => return_type
|
||||
)
|
||||
|
||||
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
|
||||
if @api_client.config.debugging
|
||||
@api_client.config.logger.debug "API called: PetApi#update_pet_with_form\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
||||
end
|
||||
return data, status_code, headers
|
||||
end
|
||||
|
||||
# uploads an image
|
||||
# @param pet_id [Integer] ID of pet to update
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @option opts [String] :additional_metadata Additional data to pass to server
|
||||
# @option opts [File] :file file to upload
|
||||
# @return [ApiResponse]
|
||||
def upload_file(pet_id, opts = {})
|
||||
data, _status_code, _headers = upload_file_with_http_info(pet_id, opts)
|
||||
data
|
||||
end
|
||||
|
||||
# uploads an image
|
||||
# @param pet_id [Integer] ID of pet to update
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @option opts [String] :additional_metadata Additional data to pass to server
|
||||
# @option opts [File] :file file to upload
|
||||
# @return [Array<(ApiResponse, Integer, Hash)>] ApiResponse data, response status code and response headers
|
||||
def upload_file_with_http_info(pet_id, opts = {})
|
||||
if @api_client.config.debugging
|
||||
@api_client.config.logger.debug 'Calling API: PetApi.upload_file ...'
|
||||
end
|
||||
# verify the required parameter 'pet_id' is set
|
||||
if @api_client.config.client_side_validation && pet_id.nil?
|
||||
fail ArgumentError, "Missing the required parameter 'pet_id' when calling PetApi.upload_file"
|
||||
end
|
||||
# resource path
|
||||
local_var_path = '/pet/{petId}/uploadImage'.sub('{' + 'petId' + '}', CGI.escape(pet_id.to_s).gsub('%2F', '/'))
|
||||
|
||||
# query parameters
|
||||
query_params = opts[:query_params] || {}
|
||||
|
||||
# header parameters
|
||||
header_params = opts[:header_params] || {}
|
||||
# HTTP header 'Accept' (if needed)
|
||||
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
||||
# HTTP header 'Content-Type'
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])
|
||||
|
||||
# form parameters
|
||||
form_params = opts[:form_params] || {}
|
||||
form_params['additionalMetadata'] = opts[:'additional_metadata'] if !opts[:'additional_metadata'].nil?
|
||||
form_params['file'] = opts[:'file'] if !opts[:'file'].nil?
|
||||
|
||||
# http body (model)
|
||||
post_body = opts[:body]
|
||||
|
||||
# return_type
|
||||
return_type = opts[:return_type] || 'ApiResponse'
|
||||
|
||||
# auth_names
|
||||
auth_names = opts[:auth_names] || ['petstore_auth']
|
||||
|
||||
new_options = opts.merge(
|
||||
:header_params => header_params,
|
||||
:query_params => query_params,
|
||||
:form_params => form_params,
|
||||
:body => post_body,
|
||||
:auth_names => auth_names,
|
||||
:return_type => return_type
|
||||
)
|
||||
|
||||
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
|
||||
if @api_client.config.debugging
|
||||
@api_client.config.logger.debug "API called: PetApi#upload_file\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
||||
end
|
||||
return data, status_code, headers
|
||||
end
|
||||
|
||||
# uploads an image (required)
|
||||
# @param pet_id [Integer] ID of pet to update
|
||||
# @param required_file [File] file to upload
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @option opts [String] :additional_metadata Additional data to pass to server
|
||||
# @return [ApiResponse]
|
||||
def upload_file_with_required_file(pet_id, required_file, opts = {})
|
||||
data, _status_code, _headers = upload_file_with_required_file_with_http_info(pet_id, required_file, opts)
|
||||
data
|
||||
end
|
||||
|
||||
# uploads an image (required)
|
||||
# @param pet_id [Integer] ID of pet to update
|
||||
# @param required_file [File] file to upload
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @option opts [String] :additional_metadata Additional data to pass to server
|
||||
# @return [Array<(ApiResponse, Integer, Hash)>] ApiResponse data, response status code and response headers
|
||||
def upload_file_with_required_file_with_http_info(pet_id, required_file, opts = {})
|
||||
if @api_client.config.debugging
|
||||
@api_client.config.logger.debug 'Calling API: PetApi.upload_file_with_required_file ...'
|
||||
end
|
||||
# verify the required parameter 'pet_id' is set
|
||||
if @api_client.config.client_side_validation && pet_id.nil?
|
||||
fail ArgumentError, "Missing the required parameter 'pet_id' when calling PetApi.upload_file_with_required_file"
|
||||
end
|
||||
# verify the required parameter 'required_file' is set
|
||||
if @api_client.config.client_side_validation && required_file.nil?
|
||||
fail ArgumentError, "Missing the required parameter 'required_file' when calling PetApi.upload_file_with_required_file"
|
||||
end
|
||||
# resource path
|
||||
local_var_path = '/fake/{petId}/uploadImageWithRequiredFile'.sub('{' + 'petId' + '}', CGI.escape(pet_id.to_s).gsub('%2F', '/'))
|
||||
|
||||
# query parameters
|
||||
query_params = opts[:query_params] || {}
|
||||
|
||||
# header parameters
|
||||
header_params = opts[:header_params] || {}
|
||||
# HTTP header 'Accept' (if needed)
|
||||
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
||||
# HTTP header 'Content-Type'
|
||||
header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])
|
||||
|
||||
# form parameters
|
||||
form_params = opts[:form_params] || {}
|
||||
form_params['requiredFile'] = required_file
|
||||
form_params['additionalMetadata'] = opts[:'additional_metadata'] if !opts[:'additional_metadata'].nil?
|
||||
|
||||
# http body (model)
|
||||
post_body = opts[:body]
|
||||
|
||||
# return_type
|
||||
return_type = opts[:return_type] || 'ApiResponse'
|
||||
|
||||
# auth_names
|
||||
auth_names = opts[:auth_names] || ['petstore_auth']
|
||||
|
||||
new_options = opts.merge(
|
||||
:header_params => header_params,
|
||||
:query_params => query_params,
|
||||
:form_params => form_params,
|
||||
:body => post_body,
|
||||
:auth_names => auth_names,
|
||||
:return_type => return_type
|
||||
)
|
||||
|
||||
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
|
||||
if @api_client.config.debugging
|
||||
@api_client.config.logger.debug "API called: PetApi#upload_file_with_required_file\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
||||
end
|
||||
return data, status_code, headers
|
||||
end
|
||||
end
|
||||
end
|
268
samples/client/petstore/ruby/lib/petstore/api/store_api.rb
Normal file
268
samples/client/petstore/ruby/lib/petstore/api/store_api.rb
Normal file
@ -0,0 +1,268 @@
|
||||
=begin
|
||||
#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: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
Generated by: https://openapi-generator.tech
|
||||
OpenAPI Generator version: 4.2.0-SNAPSHOT
|
||||
|
||||
=end
|
||||
|
||||
require 'cgi'
|
||||
|
||||
module Petstore
|
||||
class StoreApi
|
||||
attr_accessor :api_client
|
||||
|
||||
def initialize(api_client = ApiClient.default)
|
||||
@api_client = api_client
|
||||
end
|
||||
# Delete purchase order by ID
|
||||
# For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
# @param order_id [String] ID of the order that needs to be deleted
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [nil]
|
||||
def delete_order(order_id, opts = {})
|
||||
delete_order_with_http_info(order_id, opts)
|
||||
nil
|
||||
end
|
||||
|
||||
# Delete purchase order by ID
|
||||
# For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
# @param order_id [String] ID of the order that needs to be deleted
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
|
||||
def delete_order_with_http_info(order_id, opts = {})
|
||||
if @api_client.config.debugging
|
||||
@api_client.config.logger.debug 'Calling API: StoreApi.delete_order ...'
|
||||
end
|
||||
# verify the required parameter 'order_id' is set
|
||||
if @api_client.config.client_side_validation && order_id.nil?
|
||||
fail ArgumentError, "Missing the required parameter 'order_id' when calling StoreApi.delete_order"
|
||||
end
|
||||
# resource path
|
||||
local_var_path = '/store/order/{order_id}'.sub('{' + 'order_id' + '}', CGI.escape(order_id.to_s).gsub('%2F', '/'))
|
||||
|
||||
# query parameters
|
||||
query_params = opts[:query_params] || {}
|
||||
|
||||
# header parameters
|
||||
header_params = opts[:header_params] || {}
|
||||
|
||||
# form parameters
|
||||
form_params = opts[:form_params] || {}
|
||||
|
||||
# http body (model)
|
||||
post_body = opts[:body]
|
||||
|
||||
# return_type
|
||||
return_type = opts[:return_type]
|
||||
|
||||
# auth_names
|
||||
auth_names = opts[:auth_names] || []
|
||||
|
||||
new_options = opts.merge(
|
||||
:header_params => header_params,
|
||||
:query_params => query_params,
|
||||
:form_params => form_params,
|
||||
:body => post_body,
|
||||
:auth_names => auth_names,
|
||||
:return_type => return_type
|
||||
)
|
||||
|
||||
data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
|
||||
if @api_client.config.debugging
|
||||
@api_client.config.logger.debug "API called: StoreApi#delete_order\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
||||
end
|
||||
return data, status_code, headers
|
||||
end
|
||||
|
||||
# Returns pet inventories by status
|
||||
# Returns a map of status codes to quantities
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [Hash<String, Integer>]
|
||||
def get_inventory(opts = {})
|
||||
data, _status_code, _headers = get_inventory_with_http_info(opts)
|
||||
data
|
||||
end
|
||||
|
||||
# Returns pet inventories by status
|
||||
# Returns a map of status codes to quantities
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [Array<(Hash<String, Integer>, Integer, Hash)>] Hash<String, Integer> data, response status code and response headers
|
||||
def get_inventory_with_http_info(opts = {})
|
||||
if @api_client.config.debugging
|
||||
@api_client.config.logger.debug 'Calling API: StoreApi.get_inventory ...'
|
||||
end
|
||||
# resource path
|
||||
local_var_path = '/store/inventory'
|
||||
|
||||
# query parameters
|
||||
query_params = opts[:query_params] || {}
|
||||
|
||||
# header parameters
|
||||
header_params = opts[:header_params] || {}
|
||||
# HTTP header 'Accept' (if needed)
|
||||
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
||||
|
||||
# form parameters
|
||||
form_params = opts[:form_params] || {}
|
||||
|
||||
# http body (model)
|
||||
post_body = opts[:body]
|
||||
|
||||
# return_type
|
||||
return_type = opts[:return_type] || 'Hash<String, Integer>'
|
||||
|
||||
# auth_names
|
||||
auth_names = opts[:auth_names] || ['api_key']
|
||||
|
||||
new_options = opts.merge(
|
||||
:header_params => header_params,
|
||||
:query_params => query_params,
|
||||
:form_params => form_params,
|
||||
:body => post_body,
|
||||
:auth_names => auth_names,
|
||||
:return_type => return_type
|
||||
)
|
||||
|
||||
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
|
||||
if @api_client.config.debugging
|
||||
@api_client.config.logger.debug "API called: StoreApi#get_inventory\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
||||
end
|
||||
return data, status_code, headers
|
||||
end
|
||||
|
||||
# Find purchase order by ID
|
||||
# For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
# @param order_id [Integer] ID of pet that needs to be fetched
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [Order]
|
||||
def get_order_by_id(order_id, opts = {})
|
||||
data, _status_code, _headers = get_order_by_id_with_http_info(order_id, opts)
|
||||
data
|
||||
end
|
||||
|
||||
# Find purchase order by ID
|
||||
# For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
# @param order_id [Integer] ID of pet that needs to be fetched
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [Array<(Order, Integer, Hash)>] Order data, response status code and response headers
|
||||
def get_order_by_id_with_http_info(order_id, opts = {})
|
||||
if @api_client.config.debugging
|
||||
@api_client.config.logger.debug 'Calling API: StoreApi.get_order_by_id ...'
|
||||
end
|
||||
# verify the required parameter 'order_id' is set
|
||||
if @api_client.config.client_side_validation && order_id.nil?
|
||||
fail ArgumentError, "Missing the required parameter 'order_id' when calling StoreApi.get_order_by_id"
|
||||
end
|
||||
if @api_client.config.client_side_validation && order_id > 5
|
||||
fail ArgumentError, 'invalid value for "order_id" when calling StoreApi.get_order_by_id, must be smaller than or equal to 5.'
|
||||
end
|
||||
|
||||
if @api_client.config.client_side_validation && order_id < 1
|
||||
fail ArgumentError, 'invalid value for "order_id" when calling StoreApi.get_order_by_id, must be greater than or equal to 1.'
|
||||
end
|
||||
|
||||
# resource path
|
||||
local_var_path = '/store/order/{order_id}'.sub('{' + 'order_id' + '}', CGI.escape(order_id.to_s).gsub('%2F', '/'))
|
||||
|
||||
# query parameters
|
||||
query_params = opts[:query_params] || {}
|
||||
|
||||
# header parameters
|
||||
header_params = opts[:header_params] || {}
|
||||
# HTTP header 'Accept' (if needed)
|
||||
header_params['Accept'] = @api_client.select_header_accept(['application/xml', 'application/json'])
|
||||
|
||||
# form parameters
|
||||
form_params = opts[:form_params] || {}
|
||||
|
||||
# http body (model)
|
||||
post_body = opts[:body]
|
||||
|
||||
# return_type
|
||||
return_type = opts[:return_type] || 'Order'
|
||||
|
||||
# auth_names
|
||||
auth_names = opts[:auth_names] || []
|
||||
|
||||
new_options = opts.merge(
|
||||
:header_params => header_params,
|
||||
:query_params => query_params,
|
||||
:form_params => form_params,
|
||||
:body => post_body,
|
||||
:auth_names => auth_names,
|
||||
:return_type => return_type
|
||||
)
|
||||
|
||||
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
|
||||
if @api_client.config.debugging
|
||||
@api_client.config.logger.debug "API called: StoreApi#get_order_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
||||
end
|
||||
return data, status_code, headers
|
||||
end
|
||||
|
||||
# Place an order for a pet
|
||||
# @param body [Order] order placed for purchasing the pet
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [Order]
|
||||
def place_order(body, opts = {})
|
||||
data, _status_code, _headers = place_order_with_http_info(body, opts)
|
||||
data
|
||||
end
|
||||
|
||||
# Place an order for a pet
|
||||
# @param body [Order] order placed for purchasing the pet
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [Array<(Order, Integer, Hash)>] Order data, response status code and response headers
|
||||
def place_order_with_http_info(body, opts = {})
|
||||
if @api_client.config.debugging
|
||||
@api_client.config.logger.debug 'Calling API: StoreApi.place_order ...'
|
||||
end
|
||||
# verify the required parameter 'body' is set
|
||||
if @api_client.config.client_side_validation && body.nil?
|
||||
fail ArgumentError, "Missing the required parameter 'body' when calling StoreApi.place_order"
|
||||
end
|
||||
# resource path
|
||||
local_var_path = '/store/order'
|
||||
|
||||
# query parameters
|
||||
query_params = opts[:query_params] || {}
|
||||
|
||||
# header parameters
|
||||
header_params = opts[:header_params] || {}
|
||||
# HTTP header 'Accept' (if needed)
|
||||
header_params['Accept'] = @api_client.select_header_accept(['application/xml', 'application/json'])
|
||||
|
||||
# form parameters
|
||||
form_params = opts[:form_params] || {}
|
||||
|
||||
# http body (model)
|
||||
post_body = opts[:body] || @api_client.object_to_http_body(body)
|
||||
|
||||
# return_type
|
||||
return_type = opts[:return_type] || 'Order'
|
||||
|
||||
# auth_names
|
||||
auth_names = opts[:auth_names] || []
|
||||
|
||||
new_options = opts.merge(
|
||||
:header_params => header_params,
|
||||
:query_params => query_params,
|
||||
:form_params => form_params,
|
||||
:body => post_body,
|
||||
:auth_names => auth_names,
|
||||
:return_type => return_type
|
||||
)
|
||||
|
||||
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
|
||||
if @api_client.config.debugging
|
||||
@api_client.config.logger.debug "API called: StoreApi#place_order\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
||||
end
|
||||
return data, status_code, headers
|
||||
end
|
||||
end
|
||||
end
|
504
samples/client/petstore/ruby/lib/petstore/api/user_api.rb
Normal file
504
samples/client/petstore/ruby/lib/petstore/api/user_api.rb
Normal file
@ -0,0 +1,504 @@
|
||||
=begin
|
||||
#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: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
Generated by: https://openapi-generator.tech
|
||||
OpenAPI Generator version: 4.2.0-SNAPSHOT
|
||||
|
||||
=end
|
||||
|
||||
require 'cgi'
|
||||
|
||||
module Petstore
|
||||
class UserApi
|
||||
attr_accessor :api_client
|
||||
|
||||
def initialize(api_client = ApiClient.default)
|
||||
@api_client = api_client
|
||||
end
|
||||
# Create user
|
||||
# This can only be done by the logged in user.
|
||||
# @param body [User] Created user object
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [nil]
|
||||
def create_user(body, opts = {})
|
||||
create_user_with_http_info(body, opts)
|
||||
nil
|
||||
end
|
||||
|
||||
# Create user
|
||||
# This can only be done by the logged in user.
|
||||
# @param body [User] Created user object
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
|
||||
def create_user_with_http_info(body, opts = {})
|
||||
if @api_client.config.debugging
|
||||
@api_client.config.logger.debug 'Calling API: UserApi.create_user ...'
|
||||
end
|
||||
# verify the required parameter 'body' is set
|
||||
if @api_client.config.client_side_validation && body.nil?
|
||||
fail ArgumentError, "Missing the required parameter 'body' when calling UserApi.create_user"
|
||||
end
|
||||
# resource path
|
||||
local_var_path = '/user'
|
||||
|
||||
# query parameters
|
||||
query_params = opts[:query_params] || {}
|
||||
|
||||
# header parameters
|
||||
header_params = opts[:header_params] || {}
|
||||
|
||||
# form parameters
|
||||
form_params = opts[:form_params] || {}
|
||||
|
||||
# http body (model)
|
||||
post_body = opts[:body] || @api_client.object_to_http_body(body)
|
||||
|
||||
# return_type
|
||||
return_type = opts[:return_type]
|
||||
|
||||
# auth_names
|
||||
auth_names = opts[:auth_names] || []
|
||||
|
||||
new_options = opts.merge(
|
||||
:header_params => header_params,
|
||||
:query_params => query_params,
|
||||
:form_params => form_params,
|
||||
:body => post_body,
|
||||
:auth_names => auth_names,
|
||||
:return_type => return_type
|
||||
)
|
||||
|
||||
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
|
||||
if @api_client.config.debugging
|
||||
@api_client.config.logger.debug "API called: UserApi#create_user\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
||||
end
|
||||
return data, status_code, headers
|
||||
end
|
||||
|
||||
# Creates list of users with given input array
|
||||
# @param body [Array<User>] List of user object
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [nil]
|
||||
def create_users_with_array_input(body, opts = {})
|
||||
create_users_with_array_input_with_http_info(body, opts)
|
||||
nil
|
||||
end
|
||||
|
||||
# Creates list of users with given input array
|
||||
# @param body [Array<User>] List of user object
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
|
||||
def create_users_with_array_input_with_http_info(body, opts = {})
|
||||
if @api_client.config.debugging
|
||||
@api_client.config.logger.debug 'Calling API: UserApi.create_users_with_array_input ...'
|
||||
end
|
||||
# verify the required parameter 'body' is set
|
||||
if @api_client.config.client_side_validation && body.nil?
|
||||
fail ArgumentError, "Missing the required parameter 'body' when calling UserApi.create_users_with_array_input"
|
||||
end
|
||||
# resource path
|
||||
local_var_path = '/user/createWithArray'
|
||||
|
||||
# query parameters
|
||||
query_params = opts[:query_params] || {}
|
||||
|
||||
# header parameters
|
||||
header_params = opts[:header_params] || {}
|
||||
|
||||
# form parameters
|
||||
form_params = opts[:form_params] || {}
|
||||
|
||||
# http body (model)
|
||||
post_body = opts[:body] || @api_client.object_to_http_body(body)
|
||||
|
||||
# return_type
|
||||
return_type = opts[:return_type]
|
||||
|
||||
# auth_names
|
||||
auth_names = opts[:auth_names] || []
|
||||
|
||||
new_options = opts.merge(
|
||||
:header_params => header_params,
|
||||
:query_params => query_params,
|
||||
:form_params => form_params,
|
||||
:body => post_body,
|
||||
:auth_names => auth_names,
|
||||
:return_type => return_type
|
||||
)
|
||||
|
||||
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
|
||||
if @api_client.config.debugging
|
||||
@api_client.config.logger.debug "API called: UserApi#create_users_with_array_input\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
||||
end
|
||||
return data, status_code, headers
|
||||
end
|
||||
|
||||
# Creates list of users with given input array
|
||||
# @param body [Array<User>] List of user object
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [nil]
|
||||
def create_users_with_list_input(body, opts = {})
|
||||
create_users_with_list_input_with_http_info(body, opts)
|
||||
nil
|
||||
end
|
||||
|
||||
# Creates list of users with given input array
|
||||
# @param body [Array<User>] List of user object
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
|
||||
def create_users_with_list_input_with_http_info(body, opts = {})
|
||||
if @api_client.config.debugging
|
||||
@api_client.config.logger.debug 'Calling API: UserApi.create_users_with_list_input ...'
|
||||
end
|
||||
# verify the required parameter 'body' is set
|
||||
if @api_client.config.client_side_validation && body.nil?
|
||||
fail ArgumentError, "Missing the required parameter 'body' when calling UserApi.create_users_with_list_input"
|
||||
end
|
||||
# resource path
|
||||
local_var_path = '/user/createWithList'
|
||||
|
||||
# query parameters
|
||||
query_params = opts[:query_params] || {}
|
||||
|
||||
# header parameters
|
||||
header_params = opts[:header_params] || {}
|
||||
|
||||
# form parameters
|
||||
form_params = opts[:form_params] || {}
|
||||
|
||||
# http body (model)
|
||||
post_body = opts[:body] || @api_client.object_to_http_body(body)
|
||||
|
||||
# return_type
|
||||
return_type = opts[:return_type]
|
||||
|
||||
# auth_names
|
||||
auth_names = opts[:auth_names] || []
|
||||
|
||||
new_options = opts.merge(
|
||||
:header_params => header_params,
|
||||
:query_params => query_params,
|
||||
:form_params => form_params,
|
||||
:body => post_body,
|
||||
:auth_names => auth_names,
|
||||
:return_type => return_type
|
||||
)
|
||||
|
||||
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
|
||||
if @api_client.config.debugging
|
||||
@api_client.config.logger.debug "API called: UserApi#create_users_with_list_input\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
||||
end
|
||||
return data, status_code, headers
|
||||
end
|
||||
|
||||
# Delete user
|
||||
# This can only be done by the logged in user.
|
||||
# @param username [String] The name that needs to be deleted
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [nil]
|
||||
def delete_user(username, opts = {})
|
||||
delete_user_with_http_info(username, opts)
|
||||
nil
|
||||
end
|
||||
|
||||
# Delete user
|
||||
# This can only be done by the logged in user.
|
||||
# @param username [String] The name that needs to be deleted
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
|
||||
def delete_user_with_http_info(username, opts = {})
|
||||
if @api_client.config.debugging
|
||||
@api_client.config.logger.debug 'Calling API: UserApi.delete_user ...'
|
||||
end
|
||||
# verify the required parameter 'username' is set
|
||||
if @api_client.config.client_side_validation && username.nil?
|
||||
fail ArgumentError, "Missing the required parameter 'username' when calling UserApi.delete_user"
|
||||
end
|
||||
# resource path
|
||||
local_var_path = '/user/{username}'.sub('{' + 'username' + '}', CGI.escape(username.to_s).gsub('%2F', '/'))
|
||||
|
||||
# query parameters
|
||||
query_params = opts[:query_params] || {}
|
||||
|
||||
# header parameters
|
||||
header_params = opts[:header_params] || {}
|
||||
|
||||
# form parameters
|
||||
form_params = opts[:form_params] || {}
|
||||
|
||||
# http body (model)
|
||||
post_body = opts[:body]
|
||||
|
||||
# return_type
|
||||
return_type = opts[:return_type]
|
||||
|
||||
# auth_names
|
||||
auth_names = opts[:auth_names] || []
|
||||
|
||||
new_options = opts.merge(
|
||||
:header_params => header_params,
|
||||
:query_params => query_params,
|
||||
:form_params => form_params,
|
||||
:body => post_body,
|
||||
:auth_names => auth_names,
|
||||
:return_type => return_type
|
||||
)
|
||||
|
||||
data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
|
||||
if @api_client.config.debugging
|
||||
@api_client.config.logger.debug "API called: UserApi#delete_user\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
||||
end
|
||||
return data, status_code, headers
|
||||
end
|
||||
|
||||
# Get user by user name
|
||||
# @param username [String] The name that needs to be fetched. Use user1 for testing.
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [User]
|
||||
def get_user_by_name(username, opts = {})
|
||||
data, _status_code, _headers = get_user_by_name_with_http_info(username, opts)
|
||||
data
|
||||
end
|
||||
|
||||
# Get user by user name
|
||||
# @param username [String] The name that needs to be fetched. Use user1 for testing.
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [Array<(User, Integer, Hash)>] User data, response status code and response headers
|
||||
def get_user_by_name_with_http_info(username, opts = {})
|
||||
if @api_client.config.debugging
|
||||
@api_client.config.logger.debug 'Calling API: UserApi.get_user_by_name ...'
|
||||
end
|
||||
# verify the required parameter 'username' is set
|
||||
if @api_client.config.client_side_validation && username.nil?
|
||||
fail ArgumentError, "Missing the required parameter 'username' when calling UserApi.get_user_by_name"
|
||||
end
|
||||
# resource path
|
||||
local_var_path = '/user/{username}'.sub('{' + 'username' + '}', CGI.escape(username.to_s).gsub('%2F', '/'))
|
||||
|
||||
# query parameters
|
||||
query_params = opts[:query_params] || {}
|
||||
|
||||
# header parameters
|
||||
header_params = opts[:header_params] || {}
|
||||
# HTTP header 'Accept' (if needed)
|
||||
header_params['Accept'] = @api_client.select_header_accept(['application/xml', 'application/json'])
|
||||
|
||||
# form parameters
|
||||
form_params = opts[:form_params] || {}
|
||||
|
||||
# http body (model)
|
||||
post_body = opts[:body]
|
||||
|
||||
# return_type
|
||||
return_type = opts[:return_type] || 'User'
|
||||
|
||||
# auth_names
|
||||
auth_names = opts[:auth_names] || []
|
||||
|
||||
new_options = opts.merge(
|
||||
:header_params => header_params,
|
||||
:query_params => query_params,
|
||||
:form_params => form_params,
|
||||
:body => post_body,
|
||||
:auth_names => auth_names,
|
||||
:return_type => return_type
|
||||
)
|
||||
|
||||
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
|
||||
if @api_client.config.debugging
|
||||
@api_client.config.logger.debug "API called: UserApi#get_user_by_name\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
||||
end
|
||||
return data, status_code, headers
|
||||
end
|
||||
|
||||
# Logs user into the system
|
||||
# @param username [String] The user name for login
|
||||
# @param password [String] The password for login in clear text
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [String]
|
||||
def login_user(username, password, opts = {})
|
||||
data, _status_code, _headers = login_user_with_http_info(username, password, opts)
|
||||
data
|
||||
end
|
||||
|
||||
# Logs user into the system
|
||||
# @param username [String] The user name for login
|
||||
# @param password [String] The password for login in clear text
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [Array<(String, Integer, Hash)>] String data, response status code and response headers
|
||||
def login_user_with_http_info(username, password, opts = {})
|
||||
if @api_client.config.debugging
|
||||
@api_client.config.logger.debug 'Calling API: UserApi.login_user ...'
|
||||
end
|
||||
# verify the required parameter 'username' is set
|
||||
if @api_client.config.client_side_validation && username.nil?
|
||||
fail ArgumentError, "Missing the required parameter 'username' when calling UserApi.login_user"
|
||||
end
|
||||
# verify the required parameter 'password' is set
|
||||
if @api_client.config.client_side_validation && password.nil?
|
||||
fail ArgumentError, "Missing the required parameter 'password' when calling UserApi.login_user"
|
||||
end
|
||||
# resource path
|
||||
local_var_path = '/user/login'
|
||||
|
||||
# query parameters
|
||||
query_params = opts[:query_params] || {}
|
||||
query_params[:'username'] = username
|
||||
query_params[:'password'] = password
|
||||
|
||||
# header parameters
|
||||
header_params = opts[:header_params] || {}
|
||||
# HTTP header 'Accept' (if needed)
|
||||
header_params['Accept'] = @api_client.select_header_accept(['application/xml', 'application/json'])
|
||||
|
||||
# form parameters
|
||||
form_params = opts[:form_params] || {}
|
||||
|
||||
# http body (model)
|
||||
post_body = opts[:body]
|
||||
|
||||
# return_type
|
||||
return_type = opts[:return_type] || 'String'
|
||||
|
||||
# auth_names
|
||||
auth_names = opts[:auth_names] || []
|
||||
|
||||
new_options = opts.merge(
|
||||
:header_params => header_params,
|
||||
:query_params => query_params,
|
||||
:form_params => form_params,
|
||||
:body => post_body,
|
||||
:auth_names => auth_names,
|
||||
:return_type => return_type
|
||||
)
|
||||
|
||||
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
|
||||
if @api_client.config.debugging
|
||||
@api_client.config.logger.debug "API called: UserApi#login_user\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
||||
end
|
||||
return data, status_code, headers
|
||||
end
|
||||
|
||||
# Logs out current logged in user session
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [nil]
|
||||
def logout_user(opts = {})
|
||||
logout_user_with_http_info(opts)
|
||||
nil
|
||||
end
|
||||
|
||||
# Logs out current logged in user session
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
|
||||
def logout_user_with_http_info(opts = {})
|
||||
if @api_client.config.debugging
|
||||
@api_client.config.logger.debug 'Calling API: UserApi.logout_user ...'
|
||||
end
|
||||
# resource path
|
||||
local_var_path = '/user/logout'
|
||||
|
||||
# query parameters
|
||||
query_params = opts[:query_params] || {}
|
||||
|
||||
# header parameters
|
||||
header_params = opts[:header_params] || {}
|
||||
|
||||
# form parameters
|
||||
form_params = opts[:form_params] || {}
|
||||
|
||||
# http body (model)
|
||||
post_body = opts[:body]
|
||||
|
||||
# return_type
|
||||
return_type = opts[:return_type]
|
||||
|
||||
# auth_names
|
||||
auth_names = opts[:auth_names] || []
|
||||
|
||||
new_options = opts.merge(
|
||||
:header_params => header_params,
|
||||
:query_params => query_params,
|
||||
:form_params => form_params,
|
||||
:body => post_body,
|
||||
:auth_names => auth_names,
|
||||
:return_type => return_type
|
||||
)
|
||||
|
||||
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
|
||||
if @api_client.config.debugging
|
||||
@api_client.config.logger.debug "API called: UserApi#logout_user\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
||||
end
|
||||
return data, status_code, headers
|
||||
end
|
||||
|
||||
# Updated user
|
||||
# This can only be done by the logged in user.
|
||||
# @param username [String] name that need to be deleted
|
||||
# @param body [User] Updated user object
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [nil]
|
||||
def update_user(username, body, opts = {})
|
||||
update_user_with_http_info(username, body, opts)
|
||||
nil
|
||||
end
|
||||
|
||||
# Updated user
|
||||
# This can only be done by the logged in user.
|
||||
# @param username [String] name that need to be deleted
|
||||
# @param body [User] Updated user object
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
|
||||
def update_user_with_http_info(username, body, opts = {})
|
||||
if @api_client.config.debugging
|
||||
@api_client.config.logger.debug 'Calling API: UserApi.update_user ...'
|
||||
end
|
||||
# verify the required parameter 'username' is set
|
||||
if @api_client.config.client_side_validation && username.nil?
|
||||
fail ArgumentError, "Missing the required parameter 'username' when calling UserApi.update_user"
|
||||
end
|
||||
# verify the required parameter 'body' is set
|
||||
if @api_client.config.client_side_validation && body.nil?
|
||||
fail ArgumentError, "Missing the required parameter 'body' when calling UserApi.update_user"
|
||||
end
|
||||
# resource path
|
||||
local_var_path = '/user/{username}'.sub('{' + 'username' + '}', CGI.escape(username.to_s).gsub('%2F', '/'))
|
||||
|
||||
# query parameters
|
||||
query_params = opts[:query_params] || {}
|
||||
|
||||
# header parameters
|
||||
header_params = opts[:header_params] || {}
|
||||
|
||||
# form parameters
|
||||
form_params = opts[:form_params] || {}
|
||||
|
||||
# http body (model)
|
||||
post_body = opts[:body] || @api_client.object_to_http_body(body)
|
||||
|
||||
# return_type
|
||||
return_type = opts[:return_type]
|
||||
|
||||
# auth_names
|
||||
auth_names = opts[:auth_names] || []
|
||||
|
||||
new_options = opts.merge(
|
||||
:header_params => header_params,
|
||||
:query_params => query_params,
|
||||
:form_params => form_params,
|
||||
:body => post_body,
|
||||
:auth_names => auth_names,
|
||||
:return_type => return_type
|
||||
)
|
||||
|
||||
data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)
|
||||
if @api_client.config.debugging
|
||||
@api_client.config.logger.debug "API called: UserApi#update_user\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
||||
end
|
||||
return data, status_code, headers
|
||||
end
|
||||
end
|
||||
end
|
386
samples/client/petstore/ruby/lib/petstore/api_client.rb
Normal file
386
samples/client/petstore/ruby/lib/petstore/api_client.rb
Normal file
@ -0,0 +1,386 @@
|
||||
=begin
|
||||
#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: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
Generated by: https://openapi-generator.tech
|
||||
OpenAPI Generator version: 4.2.0-SNAPSHOT
|
||||
|
||||
=end
|
||||
|
||||
require 'date'
|
||||
require 'json'
|
||||
require 'logger'
|
||||
require 'tempfile'
|
||||
require 'typhoeus'
|
||||
|
||||
module Petstore
|
||||
class ApiClient
|
||||
# The Configuration object holding settings to be used in the API client.
|
||||
attr_accessor :config
|
||||
|
||||
# Defines the headers to be used in HTTP requests of all API calls by default.
|
||||
#
|
||||
# @return [Hash]
|
||||
attr_accessor :default_headers
|
||||
|
||||
# Initializes the ApiClient
|
||||
# @option config [Configuration] Configuration for initializing the object, default to Configuration.default
|
||||
def initialize(config = Configuration.default)
|
||||
@config = config
|
||||
@user_agent = "OpenAPI-Generator/#{VERSION}/ruby"
|
||||
@default_headers = {
|
||||
'Content-Type' => 'application/json',
|
||||
'User-Agent' => @user_agent
|
||||
}
|
||||
end
|
||||
|
||||
def self.default
|
||||
@@default ||= ApiClient.new
|
||||
end
|
||||
|
||||
# Call an API with given options.
|
||||
#
|
||||
# @return [Array<(Object, Integer, Hash)>] an array of 3 elements:
|
||||
# the data deserialized from response body (could be nil), response status code and response headers.
|
||||
def call_api(http_method, path, opts = {})
|
||||
request = build_request(http_method, path, opts)
|
||||
response = request.run
|
||||
|
||||
if @config.debugging
|
||||
@config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
|
||||
end
|
||||
|
||||
unless response.success?
|
||||
if response.timed_out?
|
||||
fail ApiError.new('Connection timed out')
|
||||
elsif response.code == 0
|
||||
# Errors from libcurl will be made visible here
|
||||
fail ApiError.new(:code => 0,
|
||||
:message => response.return_message)
|
||||
else
|
||||
fail ApiError.new(:code => response.code,
|
||||
:response_headers => response.headers,
|
||||
:response_body => response.body),
|
||||
response.status_message
|
||||
end
|
||||
end
|
||||
|
||||
if opts[:return_type]
|
||||
data = deserialize(response, opts[:return_type])
|
||||
else
|
||||
data = nil
|
||||
end
|
||||
return data, response.code, response.headers
|
||||
end
|
||||
|
||||
# Builds the HTTP request
|
||||
#
|
||||
# @param [String] http_method HTTP method/verb (e.g. POST)
|
||||
# @param [String] path URL path (e.g. /account/new)
|
||||
# @option opts [Hash] :header_params Header parameters
|
||||
# @option opts [Hash] :query_params Query parameters
|
||||
# @option opts [Hash] :form_params Query parameters
|
||||
# @option opts [Object] :body HTTP body (JSON/XML)
|
||||
# @return [Typhoeus::Request] A Typhoeus Request
|
||||
def build_request(http_method, path, opts = {})
|
||||
url = build_request_url(path)
|
||||
http_method = http_method.to_sym.downcase
|
||||
|
||||
header_params = @default_headers.merge(opts[:header_params] || {})
|
||||
query_params = opts[:query_params] || {}
|
||||
form_params = opts[:form_params] || {}
|
||||
|
||||
update_params_for_auth! header_params, query_params, opts[:auth_names]
|
||||
|
||||
# set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)
|
||||
_verify_ssl_host = @config.verify_ssl_host ? 2 : 0
|
||||
|
||||
req_opts = {
|
||||
:method => http_method,
|
||||
:headers => header_params,
|
||||
:params => query_params,
|
||||
:params_encoding => @config.params_encoding,
|
||||
:timeout => @config.timeout,
|
||||
:ssl_verifypeer => @config.verify_ssl,
|
||||
:ssl_verifyhost => _verify_ssl_host,
|
||||
:sslcert => @config.cert_file,
|
||||
:sslkey => @config.key_file,
|
||||
:verbose => @config.debugging
|
||||
}
|
||||
|
||||
# set custom cert, if provided
|
||||
req_opts[:cainfo] = @config.ssl_ca_cert if @config.ssl_ca_cert
|
||||
|
||||
if [:post, :patch, :put, :delete].include?(http_method)
|
||||
req_body = build_request_body(header_params, form_params, opts[:body])
|
||||
req_opts.update :body => req_body
|
||||
if @config.debugging
|
||||
@config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n"
|
||||
end
|
||||
end
|
||||
|
||||
request = Typhoeus::Request.new(url, req_opts)
|
||||
download_file(request) if opts[:return_type] == 'File'
|
||||
request
|
||||
end
|
||||
|
||||
# Builds the HTTP request body
|
||||
#
|
||||
# @param [Hash] header_params Header parameters
|
||||
# @param [Hash] form_params Query parameters
|
||||
# @param [Object] body HTTP body (JSON/XML)
|
||||
# @return [String] HTTP body data in the form of string
|
||||
def build_request_body(header_params, form_params, body)
|
||||
# http form
|
||||
if header_params['Content-Type'] == 'application/x-www-form-urlencoded' ||
|
||||
header_params['Content-Type'] == 'multipart/form-data'
|
||||
data = {}
|
||||
form_params.each do |key, value|
|
||||
case value
|
||||
when ::File, ::Array, nil
|
||||
# let typhoeus handle File, Array and nil parameters
|
||||
data[key] = value
|
||||
else
|
||||
data[key] = value.to_s
|
||||
end
|
||||
end
|
||||
elsif body
|
||||
data = body.is_a?(String) ? body : body.to_json
|
||||
else
|
||||
data = nil
|
||||
end
|
||||
data
|
||||
end
|
||||
|
||||
# Check if the given MIME is a JSON MIME.
|
||||
# JSON MIME examples:
|
||||
# application/json
|
||||
# application/json; charset=UTF8
|
||||
# APPLICATION/JSON
|
||||
# */*
|
||||
# @param [String] mime MIME
|
||||
# @return [Boolean] True if the MIME is application/json
|
||||
def json_mime?(mime)
|
||||
(mime == '*/*') || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
|
||||
end
|
||||
|
||||
# Deserialize the response to the given return type.
|
||||
#
|
||||
# @param [Response] response HTTP response
|
||||
# @param [String] return_type some examples: "User", "Array<User>", "Hash<String, Integer>"
|
||||
def deserialize(response, return_type)
|
||||
body = response.body
|
||||
|
||||
# handle file downloading - return the File instance processed in request callbacks
|
||||
# note that response body is empty when the file is written in chunks in request on_body callback
|
||||
return @tempfile if return_type == 'File'
|
||||
|
||||
return nil if body.nil? || body.empty?
|
||||
|
||||
# return response body directly for String return type
|
||||
return body if return_type == 'String'
|
||||
|
||||
# ensuring a default content type
|
||||
content_type = response.headers['Content-Type'] || 'application/json'
|
||||
|
||||
fail "Content-Type is not supported: #{content_type}" unless json_mime?(content_type)
|
||||
|
||||
begin
|
||||
data = JSON.parse("[#{body}]", :symbolize_names => true)[0]
|
||||
rescue JSON::ParserError => e
|
||||
if %w(String Date DateTime).include?(return_type)
|
||||
data = body
|
||||
else
|
||||
raise e
|
||||
end
|
||||
end
|
||||
|
||||
convert_to_type data, return_type
|
||||
end
|
||||
|
||||
# Convert data to the given return type.
|
||||
# @param [Object] data Data to be converted
|
||||
# @param [String] return_type Return type
|
||||
# @return [Mixed] Data in a particular type
|
||||
def convert_to_type(data, return_type)
|
||||
return nil if data.nil?
|
||||
case return_type
|
||||
when 'String'
|
||||
data.to_s
|
||||
when 'Integer'
|
||||
data.to_i
|
||||
when 'Float'
|
||||
data.to_f
|
||||
when 'Boolean'
|
||||
data == true
|
||||
when 'DateTime'
|
||||
# parse date time (expecting ISO 8601 format)
|
||||
DateTime.parse data
|
||||
when 'Date'
|
||||
# parse date time (expecting ISO 8601 format)
|
||||
Date.parse data
|
||||
when 'Object'
|
||||
# generic object (usually a Hash), return directly
|
||||
data
|
||||
when /\AArray<(.+)>\z/
|
||||
# e.g. Array<Pet>
|
||||
sub_type = $1
|
||||
data.map { |item| convert_to_type(item, sub_type) }
|
||||
when /\AHash\<String, (.+)\>\z/
|
||||
# e.g. Hash<String, Integer>
|
||||
sub_type = $1
|
||||
{}.tap do |hash|
|
||||
data.each { |k, v| hash[k] = convert_to_type(v, sub_type) }
|
||||
end
|
||||
else
|
||||
# models, e.g. Pet
|
||||
Petstore.const_get(return_type).build_from_hash(data)
|
||||
end
|
||||
end
|
||||
|
||||
# Save response body into a file in (the defined) temporary folder, using the filename
|
||||
# from the "Content-Disposition" header if provided, otherwise a random filename.
|
||||
# The response body is written to the file in chunks in order to handle files which
|
||||
# size is larger than maximum Ruby String or even larger than the maximum memory a Ruby
|
||||
# process can use.
|
||||
#
|
||||
# @see Configuration#temp_folder_path
|
||||
def download_file(request)
|
||||
tempfile = nil
|
||||
encoding = nil
|
||||
request.on_headers do |response|
|
||||
content_disposition = response.headers['Content-Disposition']
|
||||
if content_disposition && content_disposition =~ /filename=/i
|
||||
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
|
||||
prefix = sanitize_filename(filename)
|
||||
else
|
||||
prefix = 'download-'
|
||||
end
|
||||
prefix = prefix + '-' unless prefix.end_with?('-')
|
||||
encoding = response.body.encoding
|
||||
tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
|
||||
@tempfile = tempfile
|
||||
end
|
||||
request.on_body do |chunk|
|
||||
chunk.force_encoding(encoding)
|
||||
tempfile.write(chunk)
|
||||
end
|
||||
request.on_complete do |response|
|
||||
tempfile.close if tempfile
|
||||
@config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
|
||||
"with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
|
||||
"will be deleted automatically with GC. It's also recommended to delete the temp file "\
|
||||
"explicitly with `tempfile.delete`"
|
||||
end
|
||||
end
|
||||
|
||||
# Sanitize filename by removing path.
|
||||
# e.g. ../../sun.gif becomes sun.gif
|
||||
#
|
||||
# @param [String] filename the filename to be sanitized
|
||||
# @return [String] the sanitized filename
|
||||
def sanitize_filename(filename)
|
||||
filename.gsub(/.*[\/\\]/, '')
|
||||
end
|
||||
|
||||
def build_request_url(path)
|
||||
# Add leading and trailing slashes to path
|
||||
path = "/#{path}".gsub(/\/+/, '/')
|
||||
@config.base_url + path
|
||||
end
|
||||
|
||||
# Update hearder and query params based on authentication settings.
|
||||
#
|
||||
# @param [Hash] header_params Header parameters
|
||||
# @param [Hash] query_params Query parameters
|
||||
# @param [String] auth_names Authentication scheme name
|
||||
def update_params_for_auth!(header_params, query_params, auth_names)
|
||||
Array(auth_names).each do |auth_name|
|
||||
auth_setting = @config.auth_settings[auth_name]
|
||||
next unless auth_setting
|
||||
case auth_setting[:in]
|
||||
when 'header' then header_params[auth_setting[:key]] = auth_setting[:value]
|
||||
when 'query' then query_params[auth_setting[:key]] = auth_setting[:value]
|
||||
else fail ArgumentError, 'Authentication token must be in `query` of `header`'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Sets user agent in HTTP header
|
||||
#
|
||||
# @param [String] user_agent User agent (e.g. openapi-generator/ruby/1.0.0)
|
||||
def user_agent=(user_agent)
|
||||
@user_agent = user_agent
|
||||
@default_headers['User-Agent'] = @user_agent
|
||||
end
|
||||
|
||||
# Return Accept header based on an array of accepts provided.
|
||||
# @param [Array] accepts array for Accept
|
||||
# @return [String] the Accept header (e.g. application/json)
|
||||
def select_header_accept(accepts)
|
||||
return nil if accepts.nil? || accepts.empty?
|
||||
# use JSON when present, otherwise use all of the provided
|
||||
json_accept = accepts.find { |s| json_mime?(s) }
|
||||
json_accept || accepts.join(',')
|
||||
end
|
||||
|
||||
# Return Content-Type header based on an array of content types provided.
|
||||
# @param [Array] content_types array for Content-Type
|
||||
# @return [String] the Content-Type header (e.g. application/json)
|
||||
def select_header_content_type(content_types)
|
||||
# use application/json by default
|
||||
return 'application/json' if content_types.nil? || content_types.empty?
|
||||
# use JSON when present, otherwise use the first one
|
||||
json_content_type = content_types.find { |s| json_mime?(s) }
|
||||
json_content_type || content_types.first
|
||||
end
|
||||
|
||||
# Convert object (array, hash, object, etc) to JSON string.
|
||||
# @param [Object] model object to be converted into JSON string
|
||||
# @return [String] JSON string representation of the object
|
||||
def object_to_http_body(model)
|
||||
return model if model.nil? || model.is_a?(String)
|
||||
local_body = nil
|
||||
if model.is_a?(Array)
|
||||
local_body = model.map { |m| object_to_hash(m) }
|
||||
else
|
||||
local_body = object_to_hash(model)
|
||||
end
|
||||
local_body.to_json
|
||||
end
|
||||
|
||||
# Convert object(non-array) to hash.
|
||||
# @param [Object] obj object to be converted into JSON string
|
||||
# @return [String] JSON string representation of the object
|
||||
def object_to_hash(obj)
|
||||
if obj.respond_to?(:to_hash)
|
||||
obj.to_hash
|
||||
else
|
||||
obj
|
||||
end
|
||||
end
|
||||
|
||||
# Build parameter value according to the given collection format.
|
||||
# @param [String] collection_format one of :csv, :ssv, :tsv, :pipes and :multi
|
||||
def build_collection_param(param, collection_format)
|
||||
case collection_format
|
||||
when :csv
|
||||
param.join(',')
|
||||
when :ssv
|
||||
param.join(' ')
|
||||
when :tsv
|
||||
param.join("\t")
|
||||
when :pipes
|
||||
param.join('|')
|
||||
when :multi
|
||||
# return the array directly as typhoeus will handle it as expected
|
||||
param
|
||||
else
|
||||
fail "unknown collection format: #{collection_format.inspect}"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
57
samples/client/petstore/ruby/lib/petstore/api_error.rb
Normal file
57
samples/client/petstore/ruby/lib/petstore/api_error.rb
Normal file
@ -0,0 +1,57 @@
|
||||
=begin
|
||||
#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: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
Generated by: https://openapi-generator.tech
|
||||
OpenAPI Generator version: 4.2.0-SNAPSHOT
|
||||
|
||||
=end
|
||||
|
||||
module Petstore
|
||||
class ApiError < StandardError
|
||||
attr_reader :code, :response_headers, :response_body
|
||||
|
||||
# Usage examples:
|
||||
# ApiError.new
|
||||
# ApiError.new("message")
|
||||
# ApiError.new(:code => 500, :response_headers => {}, :response_body => "")
|
||||
# ApiError.new(:code => 404, :message => "Not Found")
|
||||
def initialize(arg = nil)
|
||||
if arg.is_a? Hash
|
||||
if arg.key?(:message) || arg.key?('message')
|
||||
super(arg[:message] || arg['message'])
|
||||
else
|
||||
super arg
|
||||
end
|
||||
|
||||
arg.each do |k, v|
|
||||
instance_variable_set "@#{k}", v
|
||||
end
|
||||
else
|
||||
super arg
|
||||
end
|
||||
end
|
||||
|
||||
# Override to_s to display a friendly error message
|
||||
def to_s
|
||||
message
|
||||
end
|
||||
|
||||
def message
|
||||
if @message.nil?
|
||||
msg = "Error message: the server returns an error"
|
||||
else
|
||||
msg = @message
|
||||
end
|
||||
|
||||
msg += "\nHTTP status code: #{code}" if code
|
||||
msg += "\nResponse headers: #{response_headers}" if response_headers
|
||||
msg += "\nResponse body: #{response_body}" if response_body
|
||||
|
||||
msg
|
||||
end
|
||||
end
|
||||
end
|
269
samples/client/petstore/ruby/lib/petstore/configuration.rb
Normal file
269
samples/client/petstore/ruby/lib/petstore/configuration.rb
Normal file
@ -0,0 +1,269 @@
|
||||
=begin
|
||||
#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: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
Generated by: https://openapi-generator.tech
|
||||
OpenAPI Generator version: 4.2.0-SNAPSHOT
|
||||
|
||||
=end
|
||||
|
||||
module Petstore
|
||||
class Configuration
|
||||
# Defines url scheme
|
||||
attr_accessor :scheme
|
||||
|
||||
# Defines url host
|
||||
attr_accessor :host
|
||||
|
||||
# Defines url base path
|
||||
attr_accessor :base_path
|
||||
|
||||
# Defines API keys used with API Key authentications.
|
||||
#
|
||||
# @return [Hash] key: parameter name, value: parameter value (API key)
|
||||
#
|
||||
# @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
|
||||
# config.api_key['api_key'] = 'xxx'
|
||||
attr_accessor :api_key
|
||||
|
||||
# Defines API key prefixes used with API Key authentications.
|
||||
#
|
||||
# @return [Hash] key: parameter name, value: API key prefix
|
||||
#
|
||||
# @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
|
||||
# config.api_key_prefix['api_key'] = 'Token'
|
||||
attr_accessor :api_key_prefix
|
||||
|
||||
# Defines the username used with HTTP basic authentication.
|
||||
#
|
||||
# @return [String]
|
||||
attr_accessor :username
|
||||
|
||||
# Defines the password used with HTTP basic authentication.
|
||||
#
|
||||
# @return [String]
|
||||
attr_accessor :password
|
||||
|
||||
# Defines the access token (Bearer) used with OAuth2.
|
||||
attr_accessor :access_token
|
||||
|
||||
# Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
|
||||
# details will be logged with `logger.debug` (see the `logger` attribute).
|
||||
# Default to false.
|
||||
#
|
||||
# @return [true, false]
|
||||
attr_accessor :debugging
|
||||
|
||||
# Defines the logger used for debugging.
|
||||
# Default to `Rails.logger` (when in Rails) or logging to STDOUT.
|
||||
#
|
||||
# @return [#debug]
|
||||
attr_accessor :logger
|
||||
|
||||
# Defines the temporary folder to store downloaded files
|
||||
# (for API endpoints that have file response).
|
||||
# Default to use `Tempfile`.
|
||||
#
|
||||
# @return [String]
|
||||
attr_accessor :temp_folder_path
|
||||
|
||||
# The time limit for HTTP request in seconds.
|
||||
# Default to 0 (never times out).
|
||||
attr_accessor :timeout
|
||||
|
||||
# Set this to false to skip client side validation in the operation.
|
||||
# Default to true.
|
||||
# @return [true, false]
|
||||
attr_accessor :client_side_validation
|
||||
|
||||
### TLS/SSL setting
|
||||
# Set this to false to skip verifying SSL certificate when calling API from https server.
|
||||
# Default to true.
|
||||
#
|
||||
# @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
|
||||
#
|
||||
# @return [true, false]
|
||||
attr_accessor :verify_ssl
|
||||
|
||||
### TLS/SSL setting
|
||||
# Set this to false to skip verifying SSL host name
|
||||
# Default to true.
|
||||
#
|
||||
# @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
|
||||
#
|
||||
# @return [true, false]
|
||||
attr_accessor :verify_ssl_host
|
||||
|
||||
### TLS/SSL setting
|
||||
# Set this to customize the certificate file to verify the peer.
|
||||
#
|
||||
# @return [String] the path to the certificate file
|
||||
#
|
||||
# @see The `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code:
|
||||
# https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
|
||||
attr_accessor :ssl_ca_cert
|
||||
|
||||
### TLS/SSL setting
|
||||
# Client certificate file (for client certificate)
|
||||
attr_accessor :cert_file
|
||||
|
||||
### TLS/SSL setting
|
||||
# Client private key file (for client certificate)
|
||||
attr_accessor :key_file
|
||||
|
||||
# Set this to customize parameters encoding of array parameter with multi collectionFormat.
|
||||
# Default to nil.
|
||||
#
|
||||
# @see The params_encoding option of Ethon. Related source code:
|
||||
# https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
|
||||
attr_accessor :params_encoding
|
||||
|
||||
attr_accessor :inject_format
|
||||
|
||||
attr_accessor :force_ending_format
|
||||
|
||||
def initialize
|
||||
@scheme = 'http'
|
||||
@host = 'petstore.swagger.io'
|
||||
@base_path = '/v2'
|
||||
@api_key = {}
|
||||
@api_key_prefix = {}
|
||||
@timeout = 0
|
||||
@client_side_validation = true
|
||||
@verify_ssl = true
|
||||
@verify_ssl_host = true
|
||||
@params_encoding = nil
|
||||
@cert_file = nil
|
||||
@key_file = nil
|
||||
@debugging = false
|
||||
@inject_format = false
|
||||
@force_ending_format = false
|
||||
@logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
|
||||
|
||||
yield(self) if block_given?
|
||||
end
|
||||
|
||||
# The default Configuration object.
|
||||
def self.default
|
||||
@@default ||= Configuration.new
|
||||
end
|
||||
|
||||
def configure
|
||||
yield(self) if block_given?
|
||||
end
|
||||
|
||||
def scheme=(scheme)
|
||||
# remove :// from scheme
|
||||
@scheme = scheme.sub(/:\/\//, '')
|
||||
end
|
||||
|
||||
def host=(host)
|
||||
# remove http(s):// and anything after a slash
|
||||
@host = host.sub(/https?:\/\//, '').split('/').first
|
||||
end
|
||||
|
||||
def base_path=(base_path)
|
||||
# Add leading and trailing slashes to base_path
|
||||
@base_path = "/#{base_path}".gsub(/\/+/, '/')
|
||||
@base_path = '' if @base_path == '/'
|
||||
end
|
||||
|
||||
def base_url
|
||||
"#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
|
||||
end
|
||||
|
||||
# Gets API key (with prefix if set).
|
||||
# @param [String] param_name the parameter name of API key auth
|
||||
def api_key_with_prefix(param_name)
|
||||
if @api_key_prefix[param_name]
|
||||
"#{@api_key_prefix[param_name]} #{@api_key[param_name]}"
|
||||
else
|
||||
@api_key[param_name]
|
||||
end
|
||||
end
|
||||
|
||||
# Gets Basic Auth token string
|
||||
def basic_auth_token
|
||||
'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
|
||||
end
|
||||
|
||||
# Returns Auth Settings hash for api client.
|
||||
def auth_settings
|
||||
{
|
||||
'api_key' =>
|
||||
{
|
||||
type: 'api_key',
|
||||
in: 'header',
|
||||
key: 'api_key',
|
||||
value: api_key_with_prefix('api_key')
|
||||
},
|
||||
'api_key_query' =>
|
||||
{
|
||||
type: 'api_key',
|
||||
in: 'query',
|
||||
key: 'api_key_query',
|
||||
value: api_key_with_prefix('api_key_query')
|
||||
},
|
||||
'http_basic_test' =>
|
||||
{
|
||||
type: 'basic',
|
||||
in: 'header',
|
||||
key: 'Authorization',
|
||||
value: basic_auth_token
|
||||
},
|
||||
'petstore_auth' =>
|
||||
{
|
||||
type: 'oauth2',
|
||||
in: 'header',
|
||||
key: 'Authorization',
|
||||
value: "Bearer #{access_token}"
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
# Returns an array of Server setting
|
||||
def server_settings
|
||||
[
|
||||
{
|
||||
url: "http://petstore.swagger.io:80/v2",
|
||||
description: "No descriptoin provided",
|
||||
}
|
||||
]
|
||||
end
|
||||
|
||||
# Returns URL based on server settings
|
||||
#
|
||||
# @param index array index of the server settings
|
||||
# @param variables hash of variable and the corresponding value
|
||||
def server_url(index, variables = {})
|
||||
servers = server_settings
|
||||
|
||||
# check array index out of bound
|
||||
if (index < 0 || index >= servers.size)
|
||||
fail ArgumentError, "Invalid index #{index} when selecting the server. Must be less than #{servers.size}"
|
||||
end
|
||||
|
||||
server = servers[index]
|
||||
url = server[:url]
|
||||
|
||||
# go through variable and assign a value
|
||||
server[:variables].each do |name, variable|
|
||||
if variables.key?(name)
|
||||
if (server[:variables][name][:enum_values].include? variables[name])
|
||||
url.gsub! "{" + name.to_s + "}", variables[name]
|
||||
else
|
||||
fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."
|
||||
end
|
||||
else
|
||||
# use default value
|
||||
url.gsub! "{" + name.to_s + "}", server[:variables][name][:default_value]
|
||||
end
|
||||
end
|
||||
|
||||
url
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,196 @@
|
||||
=begin
|
||||
#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: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
Generated by: https://openapi-generator.tech
|
||||
OpenAPI Generator version: 4.2.0-SNAPSHOT
|
||||
|
||||
=end
|
||||
|
||||
require 'date'
|
||||
|
||||
module Petstore
|
||||
class AdditionalPropertiesAnyType
|
||||
attr_accessor :name
|
||||
|
||||
# Attribute mapping from ruby-style variable name to JSON key.
|
||||
def self.attribute_map
|
||||
{
|
||||
:'name' => :'name'
|
||||
}
|
||||
end
|
||||
|
||||
# Attribute type mapping.
|
||||
def self.openapi_types
|
||||
{
|
||||
:'name' => :'String'
|
||||
}
|
||||
end
|
||||
|
||||
# Initializes the object
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
def initialize(attributes = {})
|
||||
if (!attributes.is_a?(Hash))
|
||||
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::AdditionalPropertiesAnyType` initialize method"
|
||||
end
|
||||
|
||||
# check to see if the attribute exists and convert string to symbol for hash key
|
||||
attributes = attributes.each_with_object({}) { |(k, v), h|
|
||||
if (!self.class.attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::AdditionalPropertiesAnyType`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
||||
end
|
||||
h[k.to_sym] = v
|
||||
}
|
||||
|
||||
if attributes.key?(:'name')
|
||||
self.name = attributes[:'name']
|
||||
end
|
||||
end
|
||||
|
||||
# Show invalid properties with the reasons. Usually used together with valid?
|
||||
# @return Array for valid properties with the reasons
|
||||
def list_invalid_properties
|
||||
invalid_properties = Array.new
|
||||
invalid_properties
|
||||
end
|
||||
|
||||
# Check to see if the all the properties in the model are valid
|
||||
# @return true if the model is valid
|
||||
def valid?
|
||||
true
|
||||
end
|
||||
|
||||
# Checks equality by comparing each attribute.
|
||||
# @param [Object] Object to be compared
|
||||
def ==(o)
|
||||
return true if self.equal?(o)
|
||||
self.class == o.class &&
|
||||
name == o.name
|
||||
end
|
||||
|
||||
# @see the `==` method
|
||||
# @param [Object] Object to be compared
|
||||
def eql?(o)
|
||||
self == o
|
||||
end
|
||||
|
||||
# Calculates hash code according to all attributes.
|
||||
# @return [Integer] Hash code
|
||||
def hash
|
||||
[name].hash
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def self.build_from_hash(attributes)
|
||||
new.build_from_hash(attributes)
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def build_from_hash(attributes)
|
||||
return nil unless attributes.is_a?(Hash)
|
||||
self.class.openapi_types.each_pair do |key, type|
|
||||
if type =~ /\AArray<(.*)>/i
|
||||
# check to ensure the input is an array given that the attribute
|
||||
# is documented as an array but the input is not
|
||||
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
||||
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
||||
end
|
||||
elsif !attributes[self.class.attribute_map[key]].nil?
|
||||
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
||||
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
||||
end
|
||||
|
||||
self
|
||||
end
|
||||
|
||||
# Deserializes the data based on type
|
||||
# @param string type Data type
|
||||
# @param string value Value to be deserialized
|
||||
# @return [Object] Deserialized data
|
||||
def _deserialize(type, value)
|
||||
case type.to_sym
|
||||
when :DateTime
|
||||
DateTime.parse(value)
|
||||
when :Date
|
||||
Date.parse(value)
|
||||
when :String
|
||||
value.to_s
|
||||
when :Integer
|
||||
value.to_i
|
||||
when :Float
|
||||
value.to_f
|
||||
when :Boolean
|
||||
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
when :Object
|
||||
# generic object (usually a Hash), return directly
|
||||
value
|
||||
when /\AArray<(?<inner_type>.+)>\z/
|
||||
inner_type = Regexp.last_match[:inner_type]
|
||||
value.map { |v| _deserialize(inner_type, v) }
|
||||
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
||||
k_type = Regexp.last_match[:k_type]
|
||||
v_type = Regexp.last_match[:v_type]
|
||||
{}.tap do |hash|
|
||||
value.each do |k, v|
|
||||
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
||||
end
|
||||
end
|
||||
else # model
|
||||
Petstore.const_get(type).build_from_hash(value)
|
||||
end
|
||||
end
|
||||
|
||||
# Returns the string representation of the object
|
||||
# @return [String] String presentation of the object
|
||||
def to_s
|
||||
to_hash.to_s
|
||||
end
|
||||
|
||||
# to_body is an alias to to_hash (backward compatibility)
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_body
|
||||
to_hash
|
||||
end
|
||||
|
||||
# Returns the object in the form of hash
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_hash
|
||||
hash = {}
|
||||
self.class.attribute_map.each_pair do |attr, param|
|
||||
value = self.send(attr)
|
||||
next if value.nil?
|
||||
hash[param] = _to_hash(value)
|
||||
end
|
||||
hash
|
||||
end
|
||||
|
||||
# Outputs non-array value in the form of hash
|
||||
# For object, use to_hash. Otherwise, just return the value
|
||||
# @param [Object] value Any valid value
|
||||
# @return [Hash] Returns the value in the form of hash
|
||||
def _to_hash(value)
|
||||
if value.is_a?(Array)
|
||||
value.compact.map { |v| _to_hash(v) }
|
||||
elsif value.is_a?(Hash)
|
||||
{}.tap do |hash|
|
||||
value.each { |k, v| hash[k] = _to_hash(v) }
|
||||
end
|
||||
elsif value.respond_to? :to_hash
|
||||
value.to_hash
|
||||
else
|
||||
value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,196 @@
|
||||
=begin
|
||||
#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: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
Generated by: https://openapi-generator.tech
|
||||
OpenAPI Generator version: 4.2.0-SNAPSHOT
|
||||
|
||||
=end
|
||||
|
||||
require 'date'
|
||||
|
||||
module Petstore
|
||||
class AdditionalPropertiesArray
|
||||
attr_accessor :name
|
||||
|
||||
# Attribute mapping from ruby-style variable name to JSON key.
|
||||
def self.attribute_map
|
||||
{
|
||||
:'name' => :'name'
|
||||
}
|
||||
end
|
||||
|
||||
# Attribute type mapping.
|
||||
def self.openapi_types
|
||||
{
|
||||
:'name' => :'String'
|
||||
}
|
||||
end
|
||||
|
||||
# Initializes the object
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
def initialize(attributes = {})
|
||||
if (!attributes.is_a?(Hash))
|
||||
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::AdditionalPropertiesArray` initialize method"
|
||||
end
|
||||
|
||||
# check to see if the attribute exists and convert string to symbol for hash key
|
||||
attributes = attributes.each_with_object({}) { |(k, v), h|
|
||||
if (!self.class.attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::AdditionalPropertiesArray`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
||||
end
|
||||
h[k.to_sym] = v
|
||||
}
|
||||
|
||||
if attributes.key?(:'name')
|
||||
self.name = attributes[:'name']
|
||||
end
|
||||
end
|
||||
|
||||
# Show invalid properties with the reasons. Usually used together with valid?
|
||||
# @return Array for valid properties with the reasons
|
||||
def list_invalid_properties
|
||||
invalid_properties = Array.new
|
||||
invalid_properties
|
||||
end
|
||||
|
||||
# Check to see if the all the properties in the model are valid
|
||||
# @return true if the model is valid
|
||||
def valid?
|
||||
true
|
||||
end
|
||||
|
||||
# Checks equality by comparing each attribute.
|
||||
# @param [Object] Object to be compared
|
||||
def ==(o)
|
||||
return true if self.equal?(o)
|
||||
self.class == o.class &&
|
||||
name == o.name
|
||||
end
|
||||
|
||||
# @see the `==` method
|
||||
# @param [Object] Object to be compared
|
||||
def eql?(o)
|
||||
self == o
|
||||
end
|
||||
|
||||
# Calculates hash code according to all attributes.
|
||||
# @return [Integer] Hash code
|
||||
def hash
|
||||
[name].hash
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def self.build_from_hash(attributes)
|
||||
new.build_from_hash(attributes)
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def build_from_hash(attributes)
|
||||
return nil unless attributes.is_a?(Hash)
|
||||
self.class.openapi_types.each_pair do |key, type|
|
||||
if type =~ /\AArray<(.*)>/i
|
||||
# check to ensure the input is an array given that the attribute
|
||||
# is documented as an array but the input is not
|
||||
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
||||
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
||||
end
|
||||
elsif !attributes[self.class.attribute_map[key]].nil?
|
||||
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
||||
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
||||
end
|
||||
|
||||
self
|
||||
end
|
||||
|
||||
# Deserializes the data based on type
|
||||
# @param string type Data type
|
||||
# @param string value Value to be deserialized
|
||||
# @return [Object] Deserialized data
|
||||
def _deserialize(type, value)
|
||||
case type.to_sym
|
||||
when :DateTime
|
||||
DateTime.parse(value)
|
||||
when :Date
|
||||
Date.parse(value)
|
||||
when :String
|
||||
value.to_s
|
||||
when :Integer
|
||||
value.to_i
|
||||
when :Float
|
||||
value.to_f
|
||||
when :Boolean
|
||||
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
when :Object
|
||||
# generic object (usually a Hash), return directly
|
||||
value
|
||||
when /\AArray<(?<inner_type>.+)>\z/
|
||||
inner_type = Regexp.last_match[:inner_type]
|
||||
value.map { |v| _deserialize(inner_type, v) }
|
||||
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
||||
k_type = Regexp.last_match[:k_type]
|
||||
v_type = Regexp.last_match[:v_type]
|
||||
{}.tap do |hash|
|
||||
value.each do |k, v|
|
||||
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
||||
end
|
||||
end
|
||||
else # model
|
||||
Petstore.const_get(type).build_from_hash(value)
|
||||
end
|
||||
end
|
||||
|
||||
# Returns the string representation of the object
|
||||
# @return [String] String presentation of the object
|
||||
def to_s
|
||||
to_hash.to_s
|
||||
end
|
||||
|
||||
# to_body is an alias to to_hash (backward compatibility)
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_body
|
||||
to_hash
|
||||
end
|
||||
|
||||
# Returns the object in the form of hash
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_hash
|
||||
hash = {}
|
||||
self.class.attribute_map.each_pair do |attr, param|
|
||||
value = self.send(attr)
|
||||
next if value.nil?
|
||||
hash[param] = _to_hash(value)
|
||||
end
|
||||
hash
|
||||
end
|
||||
|
||||
# Outputs non-array value in the form of hash
|
||||
# For object, use to_hash. Otherwise, just return the value
|
||||
# @param [Object] value Any valid value
|
||||
# @return [Hash] Returns the value in the form of hash
|
||||
def _to_hash(value)
|
||||
if value.is_a?(Array)
|
||||
value.compact.map { |v| _to_hash(v) }
|
||||
elsif value.is_a?(Hash)
|
||||
{}.tap do |hash|
|
||||
value.each { |k, v| hash[k] = _to_hash(v) }
|
||||
end
|
||||
elsif value.respond_to? :to_hash
|
||||
value.to_hash
|
||||
else
|
||||
value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,196 @@
|
||||
=begin
|
||||
#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: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
Generated by: https://openapi-generator.tech
|
||||
OpenAPI Generator version: 4.2.0-SNAPSHOT
|
||||
|
||||
=end
|
||||
|
||||
require 'date'
|
||||
|
||||
module Petstore
|
||||
class AdditionalPropertiesBoolean
|
||||
attr_accessor :name
|
||||
|
||||
# Attribute mapping from ruby-style variable name to JSON key.
|
||||
def self.attribute_map
|
||||
{
|
||||
:'name' => :'name'
|
||||
}
|
||||
end
|
||||
|
||||
# Attribute type mapping.
|
||||
def self.openapi_types
|
||||
{
|
||||
:'name' => :'String'
|
||||
}
|
||||
end
|
||||
|
||||
# Initializes the object
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
def initialize(attributes = {})
|
||||
if (!attributes.is_a?(Hash))
|
||||
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::AdditionalPropertiesBoolean` initialize method"
|
||||
end
|
||||
|
||||
# check to see if the attribute exists and convert string to symbol for hash key
|
||||
attributes = attributes.each_with_object({}) { |(k, v), h|
|
||||
if (!self.class.attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::AdditionalPropertiesBoolean`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
||||
end
|
||||
h[k.to_sym] = v
|
||||
}
|
||||
|
||||
if attributes.key?(:'name')
|
||||
self.name = attributes[:'name']
|
||||
end
|
||||
end
|
||||
|
||||
# Show invalid properties with the reasons. Usually used together with valid?
|
||||
# @return Array for valid properties with the reasons
|
||||
def list_invalid_properties
|
||||
invalid_properties = Array.new
|
||||
invalid_properties
|
||||
end
|
||||
|
||||
# Check to see if the all the properties in the model are valid
|
||||
# @return true if the model is valid
|
||||
def valid?
|
||||
true
|
||||
end
|
||||
|
||||
# Checks equality by comparing each attribute.
|
||||
# @param [Object] Object to be compared
|
||||
def ==(o)
|
||||
return true if self.equal?(o)
|
||||
self.class == o.class &&
|
||||
name == o.name
|
||||
end
|
||||
|
||||
# @see the `==` method
|
||||
# @param [Object] Object to be compared
|
||||
def eql?(o)
|
||||
self == o
|
||||
end
|
||||
|
||||
# Calculates hash code according to all attributes.
|
||||
# @return [Integer] Hash code
|
||||
def hash
|
||||
[name].hash
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def self.build_from_hash(attributes)
|
||||
new.build_from_hash(attributes)
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def build_from_hash(attributes)
|
||||
return nil unless attributes.is_a?(Hash)
|
||||
self.class.openapi_types.each_pair do |key, type|
|
||||
if type =~ /\AArray<(.*)>/i
|
||||
# check to ensure the input is an array given that the attribute
|
||||
# is documented as an array but the input is not
|
||||
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
||||
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
||||
end
|
||||
elsif !attributes[self.class.attribute_map[key]].nil?
|
||||
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
||||
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
||||
end
|
||||
|
||||
self
|
||||
end
|
||||
|
||||
# Deserializes the data based on type
|
||||
# @param string type Data type
|
||||
# @param string value Value to be deserialized
|
||||
# @return [Object] Deserialized data
|
||||
def _deserialize(type, value)
|
||||
case type.to_sym
|
||||
when :DateTime
|
||||
DateTime.parse(value)
|
||||
when :Date
|
||||
Date.parse(value)
|
||||
when :String
|
||||
value.to_s
|
||||
when :Integer
|
||||
value.to_i
|
||||
when :Float
|
||||
value.to_f
|
||||
when :Boolean
|
||||
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
when :Object
|
||||
# generic object (usually a Hash), return directly
|
||||
value
|
||||
when /\AArray<(?<inner_type>.+)>\z/
|
||||
inner_type = Regexp.last_match[:inner_type]
|
||||
value.map { |v| _deserialize(inner_type, v) }
|
||||
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
||||
k_type = Regexp.last_match[:k_type]
|
||||
v_type = Regexp.last_match[:v_type]
|
||||
{}.tap do |hash|
|
||||
value.each do |k, v|
|
||||
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
||||
end
|
||||
end
|
||||
else # model
|
||||
Petstore.const_get(type).build_from_hash(value)
|
||||
end
|
||||
end
|
||||
|
||||
# Returns the string representation of the object
|
||||
# @return [String] String presentation of the object
|
||||
def to_s
|
||||
to_hash.to_s
|
||||
end
|
||||
|
||||
# to_body is an alias to to_hash (backward compatibility)
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_body
|
||||
to_hash
|
||||
end
|
||||
|
||||
# Returns the object in the form of hash
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_hash
|
||||
hash = {}
|
||||
self.class.attribute_map.each_pair do |attr, param|
|
||||
value = self.send(attr)
|
||||
next if value.nil?
|
||||
hash[param] = _to_hash(value)
|
||||
end
|
||||
hash
|
||||
end
|
||||
|
||||
# Outputs non-array value in the form of hash
|
||||
# For object, use to_hash. Otherwise, just return the value
|
||||
# @param [Object] value Any valid value
|
||||
# @return [Hash] Returns the value in the form of hash
|
||||
def _to_hash(value)
|
||||
if value.is_a?(Array)
|
||||
value.compact.map { |v| _to_hash(v) }
|
||||
elsif value.is_a?(Hash)
|
||||
{}.tap do |hash|
|
||||
value.each { |k, v| hash[k] = _to_hash(v) }
|
||||
end
|
||||
elsif value.respond_to? :to_hash
|
||||
value.to_hash
|
||||
else
|
||||
value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,302 @@
|
||||
=begin
|
||||
#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: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
Generated by: https://openapi-generator.tech
|
||||
OpenAPI Generator version: 4.2.0-SNAPSHOT
|
||||
|
||||
=end
|
||||
|
||||
require 'date'
|
||||
|
||||
module Petstore
|
||||
class AdditionalPropertiesClass
|
||||
attr_accessor :map_string
|
||||
|
||||
attr_accessor :map_number
|
||||
|
||||
attr_accessor :map_integer
|
||||
|
||||
attr_accessor :map_boolean
|
||||
|
||||
attr_accessor :map_array_integer
|
||||
|
||||
attr_accessor :map_array_anytype
|
||||
|
||||
attr_accessor :map_map_string
|
||||
|
||||
attr_accessor :map_map_anytype
|
||||
|
||||
attr_accessor :anytype_1
|
||||
|
||||
attr_accessor :anytype_2
|
||||
|
||||
attr_accessor :anytype_3
|
||||
|
||||
# Attribute mapping from ruby-style variable name to JSON key.
|
||||
def self.attribute_map
|
||||
{
|
||||
:'map_string' => :'map_string',
|
||||
:'map_number' => :'map_number',
|
||||
:'map_integer' => :'map_integer',
|
||||
:'map_boolean' => :'map_boolean',
|
||||
:'map_array_integer' => :'map_array_integer',
|
||||
:'map_array_anytype' => :'map_array_anytype',
|
||||
:'map_map_string' => :'map_map_string',
|
||||
:'map_map_anytype' => :'map_map_anytype',
|
||||
:'anytype_1' => :'anytype_1',
|
||||
:'anytype_2' => :'anytype_2',
|
||||
:'anytype_3' => :'anytype_3'
|
||||
}
|
||||
end
|
||||
|
||||
# Attribute type mapping.
|
||||
def self.openapi_types
|
||||
{
|
||||
:'map_string' => :'Hash<String, String>',
|
||||
:'map_number' => :'Hash<String, Float>',
|
||||
:'map_integer' => :'Hash<String, Integer>',
|
||||
:'map_boolean' => :'Hash<String, Boolean>',
|
||||
:'map_array_integer' => :'Hash<String, Array<Integer>>',
|
||||
:'map_array_anytype' => :'Hash<String, Array<Object>>',
|
||||
:'map_map_string' => :'Hash<String, Hash<String, String>>',
|
||||
:'map_map_anytype' => :'Hash<String, Hash<String, Object>>',
|
||||
:'anytype_1' => :'Object',
|
||||
:'anytype_2' => :'Object',
|
||||
:'anytype_3' => :'Object'
|
||||
}
|
||||
end
|
||||
|
||||
# Initializes the object
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
def initialize(attributes = {})
|
||||
if (!attributes.is_a?(Hash))
|
||||
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::AdditionalPropertiesClass` initialize method"
|
||||
end
|
||||
|
||||
# check to see if the attribute exists and convert string to symbol for hash key
|
||||
attributes = attributes.each_with_object({}) { |(k, v), h|
|
||||
if (!self.class.attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::AdditionalPropertiesClass`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
||||
end
|
||||
h[k.to_sym] = v
|
||||
}
|
||||
|
||||
if attributes.key?(:'map_string')
|
||||
if (value = attributes[:'map_string']).is_a?(Hash)
|
||||
self.map_string = value
|
||||
end
|
||||
end
|
||||
|
||||
if attributes.key?(:'map_number')
|
||||
if (value = attributes[:'map_number']).is_a?(Hash)
|
||||
self.map_number = value
|
||||
end
|
||||
end
|
||||
|
||||
if attributes.key?(:'map_integer')
|
||||
if (value = attributes[:'map_integer']).is_a?(Hash)
|
||||
self.map_integer = value
|
||||
end
|
||||
end
|
||||
|
||||
if attributes.key?(:'map_boolean')
|
||||
if (value = attributes[:'map_boolean']).is_a?(Hash)
|
||||
self.map_boolean = value
|
||||
end
|
||||
end
|
||||
|
||||
if attributes.key?(:'map_array_integer')
|
||||
if (value = attributes[:'map_array_integer']).is_a?(Hash)
|
||||
self.map_array_integer = value
|
||||
end
|
||||
end
|
||||
|
||||
if attributes.key?(:'map_array_anytype')
|
||||
if (value = attributes[:'map_array_anytype']).is_a?(Hash)
|
||||
self.map_array_anytype = value
|
||||
end
|
||||
end
|
||||
|
||||
if attributes.key?(:'map_map_string')
|
||||
if (value = attributes[:'map_map_string']).is_a?(Hash)
|
||||
self.map_map_string = value
|
||||
end
|
||||
end
|
||||
|
||||
if attributes.key?(:'map_map_anytype')
|
||||
if (value = attributes[:'map_map_anytype']).is_a?(Hash)
|
||||
self.map_map_anytype = value
|
||||
end
|
||||
end
|
||||
|
||||
if attributes.key?(:'anytype_1')
|
||||
self.anytype_1 = attributes[:'anytype_1']
|
||||
end
|
||||
|
||||
if attributes.key?(:'anytype_2')
|
||||
self.anytype_2 = attributes[:'anytype_2']
|
||||
end
|
||||
|
||||
if attributes.key?(:'anytype_3')
|
||||
self.anytype_3 = attributes[:'anytype_3']
|
||||
end
|
||||
end
|
||||
|
||||
# Show invalid properties with the reasons. Usually used together with valid?
|
||||
# @return Array for valid properties with the reasons
|
||||
def list_invalid_properties
|
||||
invalid_properties = Array.new
|
||||
invalid_properties
|
||||
end
|
||||
|
||||
# Check to see if the all the properties in the model are valid
|
||||
# @return true if the model is valid
|
||||
def valid?
|
||||
true
|
||||
end
|
||||
|
||||
# Checks equality by comparing each attribute.
|
||||
# @param [Object] Object to be compared
|
||||
def ==(o)
|
||||
return true if self.equal?(o)
|
||||
self.class == o.class &&
|
||||
map_string == o.map_string &&
|
||||
map_number == o.map_number &&
|
||||
map_integer == o.map_integer &&
|
||||
map_boolean == o.map_boolean &&
|
||||
map_array_integer == o.map_array_integer &&
|
||||
map_array_anytype == o.map_array_anytype &&
|
||||
map_map_string == o.map_map_string &&
|
||||
map_map_anytype == o.map_map_anytype &&
|
||||
anytype_1 == o.anytype_1 &&
|
||||
anytype_2 == o.anytype_2 &&
|
||||
anytype_3 == o.anytype_3
|
||||
end
|
||||
|
||||
# @see the `==` method
|
||||
# @param [Object] Object to be compared
|
||||
def eql?(o)
|
||||
self == o
|
||||
end
|
||||
|
||||
# Calculates hash code according to all attributes.
|
||||
# @return [Integer] Hash code
|
||||
def hash
|
||||
[map_string, map_number, map_integer, map_boolean, map_array_integer, map_array_anytype, map_map_string, map_map_anytype, anytype_1, anytype_2, anytype_3].hash
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def self.build_from_hash(attributes)
|
||||
new.build_from_hash(attributes)
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def build_from_hash(attributes)
|
||||
return nil unless attributes.is_a?(Hash)
|
||||
self.class.openapi_types.each_pair do |key, type|
|
||||
if type =~ /\AArray<(.*)>/i
|
||||
# check to ensure the input is an array given that the attribute
|
||||
# is documented as an array but the input is not
|
||||
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
||||
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
||||
end
|
||||
elsif !attributes[self.class.attribute_map[key]].nil?
|
||||
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
||||
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
||||
end
|
||||
|
||||
self
|
||||
end
|
||||
|
||||
# Deserializes the data based on type
|
||||
# @param string type Data type
|
||||
# @param string value Value to be deserialized
|
||||
# @return [Object] Deserialized data
|
||||
def _deserialize(type, value)
|
||||
case type.to_sym
|
||||
when :DateTime
|
||||
DateTime.parse(value)
|
||||
when :Date
|
||||
Date.parse(value)
|
||||
when :String
|
||||
value.to_s
|
||||
when :Integer
|
||||
value.to_i
|
||||
when :Float
|
||||
value.to_f
|
||||
when :Boolean
|
||||
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
when :Object
|
||||
# generic object (usually a Hash), return directly
|
||||
value
|
||||
when /\AArray<(?<inner_type>.+)>\z/
|
||||
inner_type = Regexp.last_match[:inner_type]
|
||||
value.map { |v| _deserialize(inner_type, v) }
|
||||
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
||||
k_type = Regexp.last_match[:k_type]
|
||||
v_type = Regexp.last_match[:v_type]
|
||||
{}.tap do |hash|
|
||||
value.each do |k, v|
|
||||
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
||||
end
|
||||
end
|
||||
else # model
|
||||
Petstore.const_get(type).build_from_hash(value)
|
||||
end
|
||||
end
|
||||
|
||||
# Returns the string representation of the object
|
||||
# @return [String] String presentation of the object
|
||||
def to_s
|
||||
to_hash.to_s
|
||||
end
|
||||
|
||||
# to_body is an alias to to_hash (backward compatibility)
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_body
|
||||
to_hash
|
||||
end
|
||||
|
||||
# Returns the object in the form of hash
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_hash
|
||||
hash = {}
|
||||
self.class.attribute_map.each_pair do |attr, param|
|
||||
value = self.send(attr)
|
||||
next if value.nil?
|
||||
hash[param] = _to_hash(value)
|
||||
end
|
||||
hash
|
||||
end
|
||||
|
||||
# Outputs non-array value in the form of hash
|
||||
# For object, use to_hash. Otherwise, just return the value
|
||||
# @param [Object] value Any valid value
|
||||
# @return [Hash] Returns the value in the form of hash
|
||||
def _to_hash(value)
|
||||
if value.is_a?(Array)
|
||||
value.compact.map { |v| _to_hash(v) }
|
||||
elsif value.is_a?(Hash)
|
||||
{}.tap do |hash|
|
||||
value.each { |k, v| hash[k] = _to_hash(v) }
|
||||
end
|
||||
elsif value.respond_to? :to_hash
|
||||
value.to_hash
|
||||
else
|
||||
value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,196 @@
|
||||
=begin
|
||||
#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: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
Generated by: https://openapi-generator.tech
|
||||
OpenAPI Generator version: 4.2.0-SNAPSHOT
|
||||
|
||||
=end
|
||||
|
||||
require 'date'
|
||||
|
||||
module Petstore
|
||||
class AdditionalPropertiesInteger
|
||||
attr_accessor :name
|
||||
|
||||
# Attribute mapping from ruby-style variable name to JSON key.
|
||||
def self.attribute_map
|
||||
{
|
||||
:'name' => :'name'
|
||||
}
|
||||
end
|
||||
|
||||
# Attribute type mapping.
|
||||
def self.openapi_types
|
||||
{
|
||||
:'name' => :'String'
|
||||
}
|
||||
end
|
||||
|
||||
# Initializes the object
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
def initialize(attributes = {})
|
||||
if (!attributes.is_a?(Hash))
|
||||
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::AdditionalPropertiesInteger` initialize method"
|
||||
end
|
||||
|
||||
# check to see if the attribute exists and convert string to symbol for hash key
|
||||
attributes = attributes.each_with_object({}) { |(k, v), h|
|
||||
if (!self.class.attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::AdditionalPropertiesInteger`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
||||
end
|
||||
h[k.to_sym] = v
|
||||
}
|
||||
|
||||
if attributes.key?(:'name')
|
||||
self.name = attributes[:'name']
|
||||
end
|
||||
end
|
||||
|
||||
# Show invalid properties with the reasons. Usually used together with valid?
|
||||
# @return Array for valid properties with the reasons
|
||||
def list_invalid_properties
|
||||
invalid_properties = Array.new
|
||||
invalid_properties
|
||||
end
|
||||
|
||||
# Check to see if the all the properties in the model are valid
|
||||
# @return true if the model is valid
|
||||
def valid?
|
||||
true
|
||||
end
|
||||
|
||||
# Checks equality by comparing each attribute.
|
||||
# @param [Object] Object to be compared
|
||||
def ==(o)
|
||||
return true if self.equal?(o)
|
||||
self.class == o.class &&
|
||||
name == o.name
|
||||
end
|
||||
|
||||
# @see the `==` method
|
||||
# @param [Object] Object to be compared
|
||||
def eql?(o)
|
||||
self == o
|
||||
end
|
||||
|
||||
# Calculates hash code according to all attributes.
|
||||
# @return [Integer] Hash code
|
||||
def hash
|
||||
[name].hash
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def self.build_from_hash(attributes)
|
||||
new.build_from_hash(attributes)
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def build_from_hash(attributes)
|
||||
return nil unless attributes.is_a?(Hash)
|
||||
self.class.openapi_types.each_pair do |key, type|
|
||||
if type =~ /\AArray<(.*)>/i
|
||||
# check to ensure the input is an array given that the attribute
|
||||
# is documented as an array but the input is not
|
||||
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
||||
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
||||
end
|
||||
elsif !attributes[self.class.attribute_map[key]].nil?
|
||||
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
||||
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
||||
end
|
||||
|
||||
self
|
||||
end
|
||||
|
||||
# Deserializes the data based on type
|
||||
# @param string type Data type
|
||||
# @param string value Value to be deserialized
|
||||
# @return [Object] Deserialized data
|
||||
def _deserialize(type, value)
|
||||
case type.to_sym
|
||||
when :DateTime
|
||||
DateTime.parse(value)
|
||||
when :Date
|
||||
Date.parse(value)
|
||||
when :String
|
||||
value.to_s
|
||||
when :Integer
|
||||
value.to_i
|
||||
when :Float
|
||||
value.to_f
|
||||
when :Boolean
|
||||
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
when :Object
|
||||
# generic object (usually a Hash), return directly
|
||||
value
|
||||
when /\AArray<(?<inner_type>.+)>\z/
|
||||
inner_type = Regexp.last_match[:inner_type]
|
||||
value.map { |v| _deserialize(inner_type, v) }
|
||||
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
||||
k_type = Regexp.last_match[:k_type]
|
||||
v_type = Regexp.last_match[:v_type]
|
||||
{}.tap do |hash|
|
||||
value.each do |k, v|
|
||||
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
||||
end
|
||||
end
|
||||
else # model
|
||||
Petstore.const_get(type).build_from_hash(value)
|
||||
end
|
||||
end
|
||||
|
||||
# Returns the string representation of the object
|
||||
# @return [String] String presentation of the object
|
||||
def to_s
|
||||
to_hash.to_s
|
||||
end
|
||||
|
||||
# to_body is an alias to to_hash (backward compatibility)
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_body
|
||||
to_hash
|
||||
end
|
||||
|
||||
# Returns the object in the form of hash
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_hash
|
||||
hash = {}
|
||||
self.class.attribute_map.each_pair do |attr, param|
|
||||
value = self.send(attr)
|
||||
next if value.nil?
|
||||
hash[param] = _to_hash(value)
|
||||
end
|
||||
hash
|
||||
end
|
||||
|
||||
# Outputs non-array value in the form of hash
|
||||
# For object, use to_hash. Otherwise, just return the value
|
||||
# @param [Object] value Any valid value
|
||||
# @return [Hash] Returns the value in the form of hash
|
||||
def _to_hash(value)
|
||||
if value.is_a?(Array)
|
||||
value.compact.map { |v| _to_hash(v) }
|
||||
elsif value.is_a?(Hash)
|
||||
{}.tap do |hash|
|
||||
value.each { |k, v| hash[k] = _to_hash(v) }
|
||||
end
|
||||
elsif value.respond_to? :to_hash
|
||||
value.to_hash
|
||||
else
|
||||
value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,196 @@
|
||||
=begin
|
||||
#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: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
Generated by: https://openapi-generator.tech
|
||||
OpenAPI Generator version: 4.2.0-SNAPSHOT
|
||||
|
||||
=end
|
||||
|
||||
require 'date'
|
||||
|
||||
module Petstore
|
||||
class AdditionalPropertiesNumber
|
||||
attr_accessor :name
|
||||
|
||||
# Attribute mapping from ruby-style variable name to JSON key.
|
||||
def self.attribute_map
|
||||
{
|
||||
:'name' => :'name'
|
||||
}
|
||||
end
|
||||
|
||||
# Attribute type mapping.
|
||||
def self.openapi_types
|
||||
{
|
||||
:'name' => :'String'
|
||||
}
|
||||
end
|
||||
|
||||
# Initializes the object
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
def initialize(attributes = {})
|
||||
if (!attributes.is_a?(Hash))
|
||||
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::AdditionalPropertiesNumber` initialize method"
|
||||
end
|
||||
|
||||
# check to see if the attribute exists and convert string to symbol for hash key
|
||||
attributes = attributes.each_with_object({}) { |(k, v), h|
|
||||
if (!self.class.attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::AdditionalPropertiesNumber`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
||||
end
|
||||
h[k.to_sym] = v
|
||||
}
|
||||
|
||||
if attributes.key?(:'name')
|
||||
self.name = attributes[:'name']
|
||||
end
|
||||
end
|
||||
|
||||
# Show invalid properties with the reasons. Usually used together with valid?
|
||||
# @return Array for valid properties with the reasons
|
||||
def list_invalid_properties
|
||||
invalid_properties = Array.new
|
||||
invalid_properties
|
||||
end
|
||||
|
||||
# Check to see if the all the properties in the model are valid
|
||||
# @return true if the model is valid
|
||||
def valid?
|
||||
true
|
||||
end
|
||||
|
||||
# Checks equality by comparing each attribute.
|
||||
# @param [Object] Object to be compared
|
||||
def ==(o)
|
||||
return true if self.equal?(o)
|
||||
self.class == o.class &&
|
||||
name == o.name
|
||||
end
|
||||
|
||||
# @see the `==` method
|
||||
# @param [Object] Object to be compared
|
||||
def eql?(o)
|
||||
self == o
|
||||
end
|
||||
|
||||
# Calculates hash code according to all attributes.
|
||||
# @return [Integer] Hash code
|
||||
def hash
|
||||
[name].hash
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def self.build_from_hash(attributes)
|
||||
new.build_from_hash(attributes)
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def build_from_hash(attributes)
|
||||
return nil unless attributes.is_a?(Hash)
|
||||
self.class.openapi_types.each_pair do |key, type|
|
||||
if type =~ /\AArray<(.*)>/i
|
||||
# check to ensure the input is an array given that the attribute
|
||||
# is documented as an array but the input is not
|
||||
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
||||
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
||||
end
|
||||
elsif !attributes[self.class.attribute_map[key]].nil?
|
||||
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
||||
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
||||
end
|
||||
|
||||
self
|
||||
end
|
||||
|
||||
# Deserializes the data based on type
|
||||
# @param string type Data type
|
||||
# @param string value Value to be deserialized
|
||||
# @return [Object] Deserialized data
|
||||
def _deserialize(type, value)
|
||||
case type.to_sym
|
||||
when :DateTime
|
||||
DateTime.parse(value)
|
||||
when :Date
|
||||
Date.parse(value)
|
||||
when :String
|
||||
value.to_s
|
||||
when :Integer
|
||||
value.to_i
|
||||
when :Float
|
||||
value.to_f
|
||||
when :Boolean
|
||||
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
when :Object
|
||||
# generic object (usually a Hash), return directly
|
||||
value
|
||||
when /\AArray<(?<inner_type>.+)>\z/
|
||||
inner_type = Regexp.last_match[:inner_type]
|
||||
value.map { |v| _deserialize(inner_type, v) }
|
||||
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
||||
k_type = Regexp.last_match[:k_type]
|
||||
v_type = Regexp.last_match[:v_type]
|
||||
{}.tap do |hash|
|
||||
value.each do |k, v|
|
||||
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
||||
end
|
||||
end
|
||||
else # model
|
||||
Petstore.const_get(type).build_from_hash(value)
|
||||
end
|
||||
end
|
||||
|
||||
# Returns the string representation of the object
|
||||
# @return [String] String presentation of the object
|
||||
def to_s
|
||||
to_hash.to_s
|
||||
end
|
||||
|
||||
# to_body is an alias to to_hash (backward compatibility)
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_body
|
||||
to_hash
|
||||
end
|
||||
|
||||
# Returns the object in the form of hash
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_hash
|
||||
hash = {}
|
||||
self.class.attribute_map.each_pair do |attr, param|
|
||||
value = self.send(attr)
|
||||
next if value.nil?
|
||||
hash[param] = _to_hash(value)
|
||||
end
|
||||
hash
|
||||
end
|
||||
|
||||
# Outputs non-array value in the form of hash
|
||||
# For object, use to_hash. Otherwise, just return the value
|
||||
# @param [Object] value Any valid value
|
||||
# @return [Hash] Returns the value in the form of hash
|
||||
def _to_hash(value)
|
||||
if value.is_a?(Array)
|
||||
value.compact.map { |v| _to_hash(v) }
|
||||
elsif value.is_a?(Hash)
|
||||
{}.tap do |hash|
|
||||
value.each { |k, v| hash[k] = _to_hash(v) }
|
||||
end
|
||||
elsif value.respond_to? :to_hash
|
||||
value.to_hash
|
||||
else
|
||||
value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,196 @@
|
||||
=begin
|
||||
#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: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
Generated by: https://openapi-generator.tech
|
||||
OpenAPI Generator version: 4.2.0-SNAPSHOT
|
||||
|
||||
=end
|
||||
|
||||
require 'date'
|
||||
|
||||
module Petstore
|
||||
class AdditionalPropertiesObject
|
||||
attr_accessor :name
|
||||
|
||||
# Attribute mapping from ruby-style variable name to JSON key.
|
||||
def self.attribute_map
|
||||
{
|
||||
:'name' => :'name'
|
||||
}
|
||||
end
|
||||
|
||||
# Attribute type mapping.
|
||||
def self.openapi_types
|
||||
{
|
||||
:'name' => :'String'
|
||||
}
|
||||
end
|
||||
|
||||
# Initializes the object
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
def initialize(attributes = {})
|
||||
if (!attributes.is_a?(Hash))
|
||||
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::AdditionalPropertiesObject` initialize method"
|
||||
end
|
||||
|
||||
# check to see if the attribute exists and convert string to symbol for hash key
|
||||
attributes = attributes.each_with_object({}) { |(k, v), h|
|
||||
if (!self.class.attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::AdditionalPropertiesObject`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
||||
end
|
||||
h[k.to_sym] = v
|
||||
}
|
||||
|
||||
if attributes.key?(:'name')
|
||||
self.name = attributes[:'name']
|
||||
end
|
||||
end
|
||||
|
||||
# Show invalid properties with the reasons. Usually used together with valid?
|
||||
# @return Array for valid properties with the reasons
|
||||
def list_invalid_properties
|
||||
invalid_properties = Array.new
|
||||
invalid_properties
|
||||
end
|
||||
|
||||
# Check to see if the all the properties in the model are valid
|
||||
# @return true if the model is valid
|
||||
def valid?
|
||||
true
|
||||
end
|
||||
|
||||
# Checks equality by comparing each attribute.
|
||||
# @param [Object] Object to be compared
|
||||
def ==(o)
|
||||
return true if self.equal?(o)
|
||||
self.class == o.class &&
|
||||
name == o.name
|
||||
end
|
||||
|
||||
# @see the `==` method
|
||||
# @param [Object] Object to be compared
|
||||
def eql?(o)
|
||||
self == o
|
||||
end
|
||||
|
||||
# Calculates hash code according to all attributes.
|
||||
# @return [Integer] Hash code
|
||||
def hash
|
||||
[name].hash
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def self.build_from_hash(attributes)
|
||||
new.build_from_hash(attributes)
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def build_from_hash(attributes)
|
||||
return nil unless attributes.is_a?(Hash)
|
||||
self.class.openapi_types.each_pair do |key, type|
|
||||
if type =~ /\AArray<(.*)>/i
|
||||
# check to ensure the input is an array given that the attribute
|
||||
# is documented as an array but the input is not
|
||||
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
||||
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
||||
end
|
||||
elsif !attributes[self.class.attribute_map[key]].nil?
|
||||
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
||||
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
||||
end
|
||||
|
||||
self
|
||||
end
|
||||
|
||||
# Deserializes the data based on type
|
||||
# @param string type Data type
|
||||
# @param string value Value to be deserialized
|
||||
# @return [Object] Deserialized data
|
||||
def _deserialize(type, value)
|
||||
case type.to_sym
|
||||
when :DateTime
|
||||
DateTime.parse(value)
|
||||
when :Date
|
||||
Date.parse(value)
|
||||
when :String
|
||||
value.to_s
|
||||
when :Integer
|
||||
value.to_i
|
||||
when :Float
|
||||
value.to_f
|
||||
when :Boolean
|
||||
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
when :Object
|
||||
# generic object (usually a Hash), return directly
|
||||
value
|
||||
when /\AArray<(?<inner_type>.+)>\z/
|
||||
inner_type = Regexp.last_match[:inner_type]
|
||||
value.map { |v| _deserialize(inner_type, v) }
|
||||
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
||||
k_type = Regexp.last_match[:k_type]
|
||||
v_type = Regexp.last_match[:v_type]
|
||||
{}.tap do |hash|
|
||||
value.each do |k, v|
|
||||
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
||||
end
|
||||
end
|
||||
else # model
|
||||
Petstore.const_get(type).build_from_hash(value)
|
||||
end
|
||||
end
|
||||
|
||||
# Returns the string representation of the object
|
||||
# @return [String] String presentation of the object
|
||||
def to_s
|
||||
to_hash.to_s
|
||||
end
|
||||
|
||||
# to_body is an alias to to_hash (backward compatibility)
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_body
|
||||
to_hash
|
||||
end
|
||||
|
||||
# Returns the object in the form of hash
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_hash
|
||||
hash = {}
|
||||
self.class.attribute_map.each_pair do |attr, param|
|
||||
value = self.send(attr)
|
||||
next if value.nil?
|
||||
hash[param] = _to_hash(value)
|
||||
end
|
||||
hash
|
||||
end
|
||||
|
||||
# Outputs non-array value in the form of hash
|
||||
# For object, use to_hash. Otherwise, just return the value
|
||||
# @param [Object] value Any valid value
|
||||
# @return [Hash] Returns the value in the form of hash
|
||||
def _to_hash(value)
|
||||
if value.is_a?(Array)
|
||||
value.compact.map { |v| _to_hash(v) }
|
||||
elsif value.is_a?(Hash)
|
||||
{}.tap do |hash|
|
||||
value.each { |k, v| hash[k] = _to_hash(v) }
|
||||
end
|
||||
elsif value.respond_to? :to_hash
|
||||
value.to_hash
|
||||
else
|
||||
value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,196 @@
|
||||
=begin
|
||||
#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: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
Generated by: https://openapi-generator.tech
|
||||
OpenAPI Generator version: 4.2.0-SNAPSHOT
|
||||
|
||||
=end
|
||||
|
||||
require 'date'
|
||||
|
||||
module Petstore
|
||||
class AdditionalPropertiesString
|
||||
attr_accessor :name
|
||||
|
||||
# Attribute mapping from ruby-style variable name to JSON key.
|
||||
def self.attribute_map
|
||||
{
|
||||
:'name' => :'name'
|
||||
}
|
||||
end
|
||||
|
||||
# Attribute type mapping.
|
||||
def self.openapi_types
|
||||
{
|
||||
:'name' => :'String'
|
||||
}
|
||||
end
|
||||
|
||||
# Initializes the object
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
def initialize(attributes = {})
|
||||
if (!attributes.is_a?(Hash))
|
||||
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::AdditionalPropertiesString` initialize method"
|
||||
end
|
||||
|
||||
# check to see if the attribute exists and convert string to symbol for hash key
|
||||
attributes = attributes.each_with_object({}) { |(k, v), h|
|
||||
if (!self.class.attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::AdditionalPropertiesString`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
||||
end
|
||||
h[k.to_sym] = v
|
||||
}
|
||||
|
||||
if attributes.key?(:'name')
|
||||
self.name = attributes[:'name']
|
||||
end
|
||||
end
|
||||
|
||||
# Show invalid properties with the reasons. Usually used together with valid?
|
||||
# @return Array for valid properties with the reasons
|
||||
def list_invalid_properties
|
||||
invalid_properties = Array.new
|
||||
invalid_properties
|
||||
end
|
||||
|
||||
# Check to see if the all the properties in the model are valid
|
||||
# @return true if the model is valid
|
||||
def valid?
|
||||
true
|
||||
end
|
||||
|
||||
# Checks equality by comparing each attribute.
|
||||
# @param [Object] Object to be compared
|
||||
def ==(o)
|
||||
return true if self.equal?(o)
|
||||
self.class == o.class &&
|
||||
name == o.name
|
||||
end
|
||||
|
||||
# @see the `==` method
|
||||
# @param [Object] Object to be compared
|
||||
def eql?(o)
|
||||
self == o
|
||||
end
|
||||
|
||||
# Calculates hash code according to all attributes.
|
||||
# @return [Integer] Hash code
|
||||
def hash
|
||||
[name].hash
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def self.build_from_hash(attributes)
|
||||
new.build_from_hash(attributes)
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def build_from_hash(attributes)
|
||||
return nil unless attributes.is_a?(Hash)
|
||||
self.class.openapi_types.each_pair do |key, type|
|
||||
if type =~ /\AArray<(.*)>/i
|
||||
# check to ensure the input is an array given that the attribute
|
||||
# is documented as an array but the input is not
|
||||
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
||||
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
||||
end
|
||||
elsif !attributes[self.class.attribute_map[key]].nil?
|
||||
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
||||
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
||||
end
|
||||
|
||||
self
|
||||
end
|
||||
|
||||
# Deserializes the data based on type
|
||||
# @param string type Data type
|
||||
# @param string value Value to be deserialized
|
||||
# @return [Object] Deserialized data
|
||||
def _deserialize(type, value)
|
||||
case type.to_sym
|
||||
when :DateTime
|
||||
DateTime.parse(value)
|
||||
when :Date
|
||||
Date.parse(value)
|
||||
when :String
|
||||
value.to_s
|
||||
when :Integer
|
||||
value.to_i
|
||||
when :Float
|
||||
value.to_f
|
||||
when :Boolean
|
||||
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
when :Object
|
||||
# generic object (usually a Hash), return directly
|
||||
value
|
||||
when /\AArray<(?<inner_type>.+)>\z/
|
||||
inner_type = Regexp.last_match[:inner_type]
|
||||
value.map { |v| _deserialize(inner_type, v) }
|
||||
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
||||
k_type = Regexp.last_match[:k_type]
|
||||
v_type = Regexp.last_match[:v_type]
|
||||
{}.tap do |hash|
|
||||
value.each do |k, v|
|
||||
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
||||
end
|
||||
end
|
||||
else # model
|
||||
Petstore.const_get(type).build_from_hash(value)
|
||||
end
|
||||
end
|
||||
|
||||
# Returns the string representation of the object
|
||||
# @return [String] String presentation of the object
|
||||
def to_s
|
||||
to_hash.to_s
|
||||
end
|
||||
|
||||
# to_body is an alias to to_hash (backward compatibility)
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_body
|
||||
to_hash
|
||||
end
|
||||
|
||||
# Returns the object in the form of hash
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_hash
|
||||
hash = {}
|
||||
self.class.attribute_map.each_pair do |attr, param|
|
||||
value = self.send(attr)
|
||||
next if value.nil?
|
||||
hash[param] = _to_hash(value)
|
||||
end
|
||||
hash
|
||||
end
|
||||
|
||||
# Outputs non-array value in the form of hash
|
||||
# For object, use to_hash. Otherwise, just return the value
|
||||
# @param [Object] value Any valid value
|
||||
# @return [Hash] Returns the value in the form of hash
|
||||
def _to_hash(value)
|
||||
if value.is_a?(Array)
|
||||
value.compact.map { |v| _to_hash(v) }
|
||||
elsif value.is_a?(Hash)
|
||||
{}.tap do |hash|
|
||||
value.each { |k, v| hash[k] = _to_hash(v) }
|
||||
end
|
||||
elsif value.respond_to? :to_hash
|
||||
value.to_hash
|
||||
else
|
||||
value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
217
samples/client/petstore/ruby/lib/petstore/models/animal.rb
Normal file
217
samples/client/petstore/ruby/lib/petstore/models/animal.rb
Normal file
@ -0,0 +1,217 @@
|
||||
=begin
|
||||
#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: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
Generated by: https://openapi-generator.tech
|
||||
OpenAPI Generator version: 4.2.0-SNAPSHOT
|
||||
|
||||
=end
|
||||
|
||||
require 'date'
|
||||
|
||||
module Petstore
|
||||
class Animal
|
||||
attr_accessor :class_name
|
||||
|
||||
attr_accessor :color
|
||||
|
||||
# Attribute mapping from ruby-style variable name to JSON key.
|
||||
def self.attribute_map
|
||||
{
|
||||
:'class_name' => :'className',
|
||||
:'color' => :'color'
|
||||
}
|
||||
end
|
||||
|
||||
# Attribute type mapping.
|
||||
def self.openapi_types
|
||||
{
|
||||
:'class_name' => :'String',
|
||||
:'color' => :'String'
|
||||
}
|
||||
end
|
||||
|
||||
# discriminator's property name in OpenAPI v3
|
||||
def self.openapi_discriminator_name
|
||||
:'class_name'
|
||||
end
|
||||
|
||||
# Initializes the object
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
def initialize(attributes = {})
|
||||
if (!attributes.is_a?(Hash))
|
||||
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::Animal` initialize method"
|
||||
end
|
||||
|
||||
# check to see if the attribute exists and convert string to symbol for hash key
|
||||
attributes = attributes.each_with_object({}) { |(k, v), h|
|
||||
if (!self.class.attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::Animal`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
||||
end
|
||||
h[k.to_sym] = v
|
||||
}
|
||||
|
||||
if attributes.key?(:'class_name')
|
||||
self.class_name = attributes[:'class_name']
|
||||
end
|
||||
|
||||
if attributes.key?(:'color')
|
||||
self.color = attributes[:'color']
|
||||
else
|
||||
self.color = 'red'
|
||||
end
|
||||
end
|
||||
|
||||
# Show invalid properties with the reasons. Usually used together with valid?
|
||||
# @return Array for valid properties with the reasons
|
||||
def list_invalid_properties
|
||||
invalid_properties = Array.new
|
||||
if @class_name.nil?
|
||||
invalid_properties.push('invalid value for "class_name", class_name cannot be nil.')
|
||||
end
|
||||
|
||||
invalid_properties
|
||||
end
|
||||
|
||||
# Check to see if the all the properties in the model are valid
|
||||
# @return true if the model is valid
|
||||
def valid?
|
||||
return false if @class_name.nil?
|
||||
true
|
||||
end
|
||||
|
||||
# Checks equality by comparing each attribute.
|
||||
# @param [Object] Object to be compared
|
||||
def ==(o)
|
||||
return true if self.equal?(o)
|
||||
self.class == o.class &&
|
||||
class_name == o.class_name &&
|
||||
color == o.color
|
||||
end
|
||||
|
||||
# @see the `==` method
|
||||
# @param [Object] Object to be compared
|
||||
def eql?(o)
|
||||
self == o
|
||||
end
|
||||
|
||||
# Calculates hash code according to all attributes.
|
||||
# @return [Integer] Hash code
|
||||
def hash
|
||||
[class_name, color].hash
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def self.build_from_hash(attributes)
|
||||
new.build_from_hash(attributes)
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def build_from_hash(attributes)
|
||||
return nil unless attributes.is_a?(Hash)
|
||||
self.class.openapi_types.each_pair do |key, type|
|
||||
if type =~ /\AArray<(.*)>/i
|
||||
# check to ensure the input is an array given that the attribute
|
||||
# is documented as an array but the input is not
|
||||
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
||||
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
||||
end
|
||||
elsif !attributes[self.class.attribute_map[key]].nil?
|
||||
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
||||
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
||||
end
|
||||
|
||||
self
|
||||
end
|
||||
|
||||
# Deserializes the data based on type
|
||||
# @param string type Data type
|
||||
# @param string value Value to be deserialized
|
||||
# @return [Object] Deserialized data
|
||||
def _deserialize(type, value)
|
||||
case type.to_sym
|
||||
when :DateTime
|
||||
DateTime.parse(value)
|
||||
when :Date
|
||||
Date.parse(value)
|
||||
when :String
|
||||
value.to_s
|
||||
when :Integer
|
||||
value.to_i
|
||||
when :Float
|
||||
value.to_f
|
||||
when :Boolean
|
||||
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
when :Object
|
||||
# generic object (usually a Hash), return directly
|
||||
value
|
||||
when /\AArray<(?<inner_type>.+)>\z/
|
||||
inner_type = Regexp.last_match[:inner_type]
|
||||
value.map { |v| _deserialize(inner_type, v) }
|
||||
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
||||
k_type = Regexp.last_match[:k_type]
|
||||
v_type = Regexp.last_match[:v_type]
|
||||
{}.tap do |hash|
|
||||
value.each do |k, v|
|
||||
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
||||
end
|
||||
end
|
||||
else # model
|
||||
Petstore.const_get(type).build_from_hash(value)
|
||||
end
|
||||
end
|
||||
|
||||
# Returns the string representation of the object
|
||||
# @return [String] String presentation of the object
|
||||
def to_s
|
||||
to_hash.to_s
|
||||
end
|
||||
|
||||
# to_body is an alias to to_hash (backward compatibility)
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_body
|
||||
to_hash
|
||||
end
|
||||
|
||||
# Returns the object in the form of hash
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_hash
|
||||
hash = {}
|
||||
self.class.attribute_map.each_pair do |attr, param|
|
||||
value = self.send(attr)
|
||||
next if value.nil?
|
||||
hash[param] = _to_hash(value)
|
||||
end
|
||||
hash
|
||||
end
|
||||
|
||||
# Outputs non-array value in the form of hash
|
||||
# For object, use to_hash. Otherwise, just return the value
|
||||
# @param [Object] value Any valid value
|
||||
# @return [Hash] Returns the value in the form of hash
|
||||
def _to_hash(value)
|
||||
if value.is_a?(Array)
|
||||
value.compact.map { |v| _to_hash(v) }
|
||||
elsif value.is_a?(Hash)
|
||||
{}.tap do |hash|
|
||||
value.each { |k, v| hash[k] = _to_hash(v) }
|
||||
end
|
||||
elsif value.respond_to? :to_hash
|
||||
value.to_hash
|
||||
else
|
||||
value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
214
samples/client/petstore/ruby/lib/petstore/models/api_response.rb
Normal file
214
samples/client/petstore/ruby/lib/petstore/models/api_response.rb
Normal file
@ -0,0 +1,214 @@
|
||||
=begin
|
||||
#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: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
Generated by: https://openapi-generator.tech
|
||||
OpenAPI Generator version: 4.2.0-SNAPSHOT
|
||||
|
||||
=end
|
||||
|
||||
require 'date'
|
||||
|
||||
module Petstore
|
||||
class ApiResponse
|
||||
attr_accessor :code
|
||||
|
||||
attr_accessor :type
|
||||
|
||||
attr_accessor :message
|
||||
|
||||
# Attribute mapping from ruby-style variable name to JSON key.
|
||||
def self.attribute_map
|
||||
{
|
||||
:'code' => :'code',
|
||||
:'type' => :'type',
|
||||
:'message' => :'message'
|
||||
}
|
||||
end
|
||||
|
||||
# Attribute type mapping.
|
||||
def self.openapi_types
|
||||
{
|
||||
:'code' => :'Integer',
|
||||
:'type' => :'String',
|
||||
:'message' => :'String'
|
||||
}
|
||||
end
|
||||
|
||||
# Initializes the object
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
def initialize(attributes = {})
|
||||
if (!attributes.is_a?(Hash))
|
||||
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::ApiResponse` initialize method"
|
||||
end
|
||||
|
||||
# check to see if the attribute exists and convert string to symbol for hash key
|
||||
attributes = attributes.each_with_object({}) { |(k, v), h|
|
||||
if (!self.class.attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::ApiResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
||||
end
|
||||
h[k.to_sym] = v
|
||||
}
|
||||
|
||||
if attributes.key?(:'code')
|
||||
self.code = attributes[:'code']
|
||||
end
|
||||
|
||||
if attributes.key?(:'type')
|
||||
self.type = attributes[:'type']
|
||||
end
|
||||
|
||||
if attributes.key?(:'message')
|
||||
self.message = attributes[:'message']
|
||||
end
|
||||
end
|
||||
|
||||
# Show invalid properties with the reasons. Usually used together with valid?
|
||||
# @return Array for valid properties with the reasons
|
||||
def list_invalid_properties
|
||||
invalid_properties = Array.new
|
||||
invalid_properties
|
||||
end
|
||||
|
||||
# Check to see if the all the properties in the model are valid
|
||||
# @return true if the model is valid
|
||||
def valid?
|
||||
true
|
||||
end
|
||||
|
||||
# Checks equality by comparing each attribute.
|
||||
# @param [Object] Object to be compared
|
||||
def ==(o)
|
||||
return true if self.equal?(o)
|
||||
self.class == o.class &&
|
||||
code == o.code &&
|
||||
type == o.type &&
|
||||
message == o.message
|
||||
end
|
||||
|
||||
# @see the `==` method
|
||||
# @param [Object] Object to be compared
|
||||
def eql?(o)
|
||||
self == o
|
||||
end
|
||||
|
||||
# Calculates hash code according to all attributes.
|
||||
# @return [Integer] Hash code
|
||||
def hash
|
||||
[code, type, message].hash
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def self.build_from_hash(attributes)
|
||||
new.build_from_hash(attributes)
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def build_from_hash(attributes)
|
||||
return nil unless attributes.is_a?(Hash)
|
||||
self.class.openapi_types.each_pair do |key, type|
|
||||
if type =~ /\AArray<(.*)>/i
|
||||
# check to ensure the input is an array given that the attribute
|
||||
# is documented as an array but the input is not
|
||||
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
||||
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
||||
end
|
||||
elsif !attributes[self.class.attribute_map[key]].nil?
|
||||
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
||||
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
||||
end
|
||||
|
||||
self
|
||||
end
|
||||
|
||||
# Deserializes the data based on type
|
||||
# @param string type Data type
|
||||
# @param string value Value to be deserialized
|
||||
# @return [Object] Deserialized data
|
||||
def _deserialize(type, value)
|
||||
case type.to_sym
|
||||
when :DateTime
|
||||
DateTime.parse(value)
|
||||
when :Date
|
||||
Date.parse(value)
|
||||
when :String
|
||||
value.to_s
|
||||
when :Integer
|
||||
value.to_i
|
||||
when :Float
|
||||
value.to_f
|
||||
when :Boolean
|
||||
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
when :Object
|
||||
# generic object (usually a Hash), return directly
|
||||
value
|
||||
when /\AArray<(?<inner_type>.+)>\z/
|
||||
inner_type = Regexp.last_match[:inner_type]
|
||||
value.map { |v| _deserialize(inner_type, v) }
|
||||
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
||||
k_type = Regexp.last_match[:k_type]
|
||||
v_type = Regexp.last_match[:v_type]
|
||||
{}.tap do |hash|
|
||||
value.each do |k, v|
|
||||
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
||||
end
|
||||
end
|
||||
else # model
|
||||
Petstore.const_get(type).build_from_hash(value)
|
||||
end
|
||||
end
|
||||
|
||||
# Returns the string representation of the object
|
||||
# @return [String] String presentation of the object
|
||||
def to_s
|
||||
to_hash.to_s
|
||||
end
|
||||
|
||||
# to_body is an alias to to_hash (backward compatibility)
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_body
|
||||
to_hash
|
||||
end
|
||||
|
||||
# Returns the object in the form of hash
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_hash
|
||||
hash = {}
|
||||
self.class.attribute_map.each_pair do |attr, param|
|
||||
value = self.send(attr)
|
||||
next if value.nil?
|
||||
hash[param] = _to_hash(value)
|
||||
end
|
||||
hash
|
||||
end
|
||||
|
||||
# Outputs non-array value in the form of hash
|
||||
# For object, use to_hash. Otherwise, just return the value
|
||||
# @param [Object] value Any valid value
|
||||
# @return [Hash] Returns the value in the form of hash
|
||||
def _to_hash(value)
|
||||
if value.is_a?(Array)
|
||||
value.compact.map { |v| _to_hash(v) }
|
||||
elsif value.is_a?(Hash)
|
||||
{}.tap do |hash|
|
||||
value.each { |k, v| hash[k] = _to_hash(v) }
|
||||
end
|
||||
elsif value.respond_to? :to_hash
|
||||
value.to_hash
|
||||
else
|
||||
value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,198 @@
|
||||
=begin
|
||||
#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: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
Generated by: https://openapi-generator.tech
|
||||
OpenAPI Generator version: 4.2.0-SNAPSHOT
|
||||
|
||||
=end
|
||||
|
||||
require 'date'
|
||||
|
||||
module Petstore
|
||||
class ArrayOfArrayOfNumberOnly
|
||||
attr_accessor :array_array_number
|
||||
|
||||
# Attribute mapping from ruby-style variable name to JSON key.
|
||||
def self.attribute_map
|
||||
{
|
||||
:'array_array_number' => :'ArrayArrayNumber'
|
||||
}
|
||||
end
|
||||
|
||||
# Attribute type mapping.
|
||||
def self.openapi_types
|
||||
{
|
||||
:'array_array_number' => :'Array<Array<Float>>'
|
||||
}
|
||||
end
|
||||
|
||||
# Initializes the object
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
def initialize(attributes = {})
|
||||
if (!attributes.is_a?(Hash))
|
||||
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::ArrayOfArrayOfNumberOnly` initialize method"
|
||||
end
|
||||
|
||||
# check to see if the attribute exists and convert string to symbol for hash key
|
||||
attributes = attributes.each_with_object({}) { |(k, v), h|
|
||||
if (!self.class.attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::ArrayOfArrayOfNumberOnly`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
||||
end
|
||||
h[k.to_sym] = v
|
||||
}
|
||||
|
||||
if attributes.key?(:'array_array_number')
|
||||
if (value = attributes[:'array_array_number']).is_a?(Array)
|
||||
self.array_array_number = value
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Show invalid properties with the reasons. Usually used together with valid?
|
||||
# @return Array for valid properties with the reasons
|
||||
def list_invalid_properties
|
||||
invalid_properties = Array.new
|
||||
invalid_properties
|
||||
end
|
||||
|
||||
# Check to see if the all the properties in the model are valid
|
||||
# @return true if the model is valid
|
||||
def valid?
|
||||
true
|
||||
end
|
||||
|
||||
# Checks equality by comparing each attribute.
|
||||
# @param [Object] Object to be compared
|
||||
def ==(o)
|
||||
return true if self.equal?(o)
|
||||
self.class == o.class &&
|
||||
array_array_number == o.array_array_number
|
||||
end
|
||||
|
||||
# @see the `==` method
|
||||
# @param [Object] Object to be compared
|
||||
def eql?(o)
|
||||
self == o
|
||||
end
|
||||
|
||||
# Calculates hash code according to all attributes.
|
||||
# @return [Integer] Hash code
|
||||
def hash
|
||||
[array_array_number].hash
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def self.build_from_hash(attributes)
|
||||
new.build_from_hash(attributes)
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def build_from_hash(attributes)
|
||||
return nil unless attributes.is_a?(Hash)
|
||||
self.class.openapi_types.each_pair do |key, type|
|
||||
if type =~ /\AArray<(.*)>/i
|
||||
# check to ensure the input is an array given that the attribute
|
||||
# is documented as an array but the input is not
|
||||
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
||||
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
||||
end
|
||||
elsif !attributes[self.class.attribute_map[key]].nil?
|
||||
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
||||
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
||||
end
|
||||
|
||||
self
|
||||
end
|
||||
|
||||
# Deserializes the data based on type
|
||||
# @param string type Data type
|
||||
# @param string value Value to be deserialized
|
||||
# @return [Object] Deserialized data
|
||||
def _deserialize(type, value)
|
||||
case type.to_sym
|
||||
when :DateTime
|
||||
DateTime.parse(value)
|
||||
when :Date
|
||||
Date.parse(value)
|
||||
when :String
|
||||
value.to_s
|
||||
when :Integer
|
||||
value.to_i
|
||||
when :Float
|
||||
value.to_f
|
||||
when :Boolean
|
||||
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
when :Object
|
||||
# generic object (usually a Hash), return directly
|
||||
value
|
||||
when /\AArray<(?<inner_type>.+)>\z/
|
||||
inner_type = Regexp.last_match[:inner_type]
|
||||
value.map { |v| _deserialize(inner_type, v) }
|
||||
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
||||
k_type = Regexp.last_match[:k_type]
|
||||
v_type = Regexp.last_match[:v_type]
|
||||
{}.tap do |hash|
|
||||
value.each do |k, v|
|
||||
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
||||
end
|
||||
end
|
||||
else # model
|
||||
Petstore.const_get(type).build_from_hash(value)
|
||||
end
|
||||
end
|
||||
|
||||
# Returns the string representation of the object
|
||||
# @return [String] String presentation of the object
|
||||
def to_s
|
||||
to_hash.to_s
|
||||
end
|
||||
|
||||
# to_body is an alias to to_hash (backward compatibility)
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_body
|
||||
to_hash
|
||||
end
|
||||
|
||||
# Returns the object in the form of hash
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_hash
|
||||
hash = {}
|
||||
self.class.attribute_map.each_pair do |attr, param|
|
||||
value = self.send(attr)
|
||||
next if value.nil?
|
||||
hash[param] = _to_hash(value)
|
||||
end
|
||||
hash
|
||||
end
|
||||
|
||||
# Outputs non-array value in the form of hash
|
||||
# For object, use to_hash. Otherwise, just return the value
|
||||
# @param [Object] value Any valid value
|
||||
# @return [Hash] Returns the value in the form of hash
|
||||
def _to_hash(value)
|
||||
if value.is_a?(Array)
|
||||
value.compact.map { |v| _to_hash(v) }
|
||||
elsif value.is_a?(Hash)
|
||||
{}.tap do |hash|
|
||||
value.each { |k, v| hash[k] = _to_hash(v) }
|
||||
end
|
||||
elsif value.respond_to? :to_hash
|
||||
value.to_hash
|
||||
else
|
||||
value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,198 @@
|
||||
=begin
|
||||
#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: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
Generated by: https://openapi-generator.tech
|
||||
OpenAPI Generator version: 4.2.0-SNAPSHOT
|
||||
|
||||
=end
|
||||
|
||||
require 'date'
|
||||
|
||||
module Petstore
|
||||
class ArrayOfNumberOnly
|
||||
attr_accessor :array_number
|
||||
|
||||
# Attribute mapping from ruby-style variable name to JSON key.
|
||||
def self.attribute_map
|
||||
{
|
||||
:'array_number' => :'ArrayNumber'
|
||||
}
|
||||
end
|
||||
|
||||
# Attribute type mapping.
|
||||
def self.openapi_types
|
||||
{
|
||||
:'array_number' => :'Array<Float>'
|
||||
}
|
||||
end
|
||||
|
||||
# Initializes the object
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
def initialize(attributes = {})
|
||||
if (!attributes.is_a?(Hash))
|
||||
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::ArrayOfNumberOnly` initialize method"
|
||||
end
|
||||
|
||||
# check to see if the attribute exists and convert string to symbol for hash key
|
||||
attributes = attributes.each_with_object({}) { |(k, v), h|
|
||||
if (!self.class.attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::ArrayOfNumberOnly`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
||||
end
|
||||
h[k.to_sym] = v
|
||||
}
|
||||
|
||||
if attributes.key?(:'array_number')
|
||||
if (value = attributes[:'array_number']).is_a?(Array)
|
||||
self.array_number = value
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Show invalid properties with the reasons. Usually used together with valid?
|
||||
# @return Array for valid properties with the reasons
|
||||
def list_invalid_properties
|
||||
invalid_properties = Array.new
|
||||
invalid_properties
|
||||
end
|
||||
|
||||
# Check to see if the all the properties in the model are valid
|
||||
# @return true if the model is valid
|
||||
def valid?
|
||||
true
|
||||
end
|
||||
|
||||
# Checks equality by comparing each attribute.
|
||||
# @param [Object] Object to be compared
|
||||
def ==(o)
|
||||
return true if self.equal?(o)
|
||||
self.class == o.class &&
|
||||
array_number == o.array_number
|
||||
end
|
||||
|
||||
# @see the `==` method
|
||||
# @param [Object] Object to be compared
|
||||
def eql?(o)
|
||||
self == o
|
||||
end
|
||||
|
||||
# Calculates hash code according to all attributes.
|
||||
# @return [Integer] Hash code
|
||||
def hash
|
||||
[array_number].hash
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def self.build_from_hash(attributes)
|
||||
new.build_from_hash(attributes)
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def build_from_hash(attributes)
|
||||
return nil unless attributes.is_a?(Hash)
|
||||
self.class.openapi_types.each_pair do |key, type|
|
||||
if type =~ /\AArray<(.*)>/i
|
||||
# check to ensure the input is an array given that the attribute
|
||||
# is documented as an array but the input is not
|
||||
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
||||
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
||||
end
|
||||
elsif !attributes[self.class.attribute_map[key]].nil?
|
||||
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
||||
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
||||
end
|
||||
|
||||
self
|
||||
end
|
||||
|
||||
# Deserializes the data based on type
|
||||
# @param string type Data type
|
||||
# @param string value Value to be deserialized
|
||||
# @return [Object] Deserialized data
|
||||
def _deserialize(type, value)
|
||||
case type.to_sym
|
||||
when :DateTime
|
||||
DateTime.parse(value)
|
||||
when :Date
|
||||
Date.parse(value)
|
||||
when :String
|
||||
value.to_s
|
||||
when :Integer
|
||||
value.to_i
|
||||
when :Float
|
||||
value.to_f
|
||||
when :Boolean
|
||||
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
when :Object
|
||||
# generic object (usually a Hash), return directly
|
||||
value
|
||||
when /\AArray<(?<inner_type>.+)>\z/
|
||||
inner_type = Regexp.last_match[:inner_type]
|
||||
value.map { |v| _deserialize(inner_type, v) }
|
||||
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
||||
k_type = Regexp.last_match[:k_type]
|
||||
v_type = Regexp.last_match[:v_type]
|
||||
{}.tap do |hash|
|
||||
value.each do |k, v|
|
||||
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
||||
end
|
||||
end
|
||||
else # model
|
||||
Petstore.const_get(type).build_from_hash(value)
|
||||
end
|
||||
end
|
||||
|
||||
# Returns the string representation of the object
|
||||
# @return [String] String presentation of the object
|
||||
def to_s
|
||||
to_hash.to_s
|
||||
end
|
||||
|
||||
# to_body is an alias to to_hash (backward compatibility)
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_body
|
||||
to_hash
|
||||
end
|
||||
|
||||
# Returns the object in the form of hash
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_hash
|
||||
hash = {}
|
||||
self.class.attribute_map.each_pair do |attr, param|
|
||||
value = self.send(attr)
|
||||
next if value.nil?
|
||||
hash[param] = _to_hash(value)
|
||||
end
|
||||
hash
|
||||
end
|
||||
|
||||
# Outputs non-array value in the form of hash
|
||||
# For object, use to_hash. Otherwise, just return the value
|
||||
# @param [Object] value Any valid value
|
||||
# @return [Hash] Returns the value in the form of hash
|
||||
def _to_hash(value)
|
||||
if value.is_a?(Array)
|
||||
value.compact.map { |v| _to_hash(v) }
|
||||
elsif value.is_a?(Hash)
|
||||
{}.tap do |hash|
|
||||
value.each { |k, v| hash[k] = _to_hash(v) }
|
||||
end
|
||||
elsif value.respond_to? :to_hash
|
||||
value.to_hash
|
||||
else
|
||||
value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
220
samples/client/petstore/ruby/lib/petstore/models/array_test.rb
Normal file
220
samples/client/petstore/ruby/lib/petstore/models/array_test.rb
Normal file
@ -0,0 +1,220 @@
|
||||
=begin
|
||||
#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: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
Generated by: https://openapi-generator.tech
|
||||
OpenAPI Generator version: 4.2.0-SNAPSHOT
|
||||
|
||||
=end
|
||||
|
||||
require 'date'
|
||||
|
||||
module Petstore
|
||||
class ArrayTest
|
||||
attr_accessor :array_of_string
|
||||
|
||||
attr_accessor :array_array_of_integer
|
||||
|
||||
attr_accessor :array_array_of_model
|
||||
|
||||
# Attribute mapping from ruby-style variable name to JSON key.
|
||||
def self.attribute_map
|
||||
{
|
||||
:'array_of_string' => :'array_of_string',
|
||||
:'array_array_of_integer' => :'array_array_of_integer',
|
||||
:'array_array_of_model' => :'array_array_of_model'
|
||||
}
|
||||
end
|
||||
|
||||
# Attribute type mapping.
|
||||
def self.openapi_types
|
||||
{
|
||||
:'array_of_string' => :'Array<String>',
|
||||
:'array_array_of_integer' => :'Array<Array<Integer>>',
|
||||
:'array_array_of_model' => :'Array<Array<ReadOnlyFirst>>'
|
||||
}
|
||||
end
|
||||
|
||||
# Initializes the object
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
def initialize(attributes = {})
|
||||
if (!attributes.is_a?(Hash))
|
||||
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::ArrayTest` initialize method"
|
||||
end
|
||||
|
||||
# check to see if the attribute exists and convert string to symbol for hash key
|
||||
attributes = attributes.each_with_object({}) { |(k, v), h|
|
||||
if (!self.class.attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::ArrayTest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
||||
end
|
||||
h[k.to_sym] = v
|
||||
}
|
||||
|
||||
if attributes.key?(:'array_of_string')
|
||||
if (value = attributes[:'array_of_string']).is_a?(Array)
|
||||
self.array_of_string = value
|
||||
end
|
||||
end
|
||||
|
||||
if attributes.key?(:'array_array_of_integer')
|
||||
if (value = attributes[:'array_array_of_integer']).is_a?(Array)
|
||||
self.array_array_of_integer = value
|
||||
end
|
||||
end
|
||||
|
||||
if attributes.key?(:'array_array_of_model')
|
||||
if (value = attributes[:'array_array_of_model']).is_a?(Array)
|
||||
self.array_array_of_model = value
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Show invalid properties with the reasons. Usually used together with valid?
|
||||
# @return Array for valid properties with the reasons
|
||||
def list_invalid_properties
|
||||
invalid_properties = Array.new
|
||||
invalid_properties
|
||||
end
|
||||
|
||||
# Check to see if the all the properties in the model are valid
|
||||
# @return true if the model is valid
|
||||
def valid?
|
||||
true
|
||||
end
|
||||
|
||||
# Checks equality by comparing each attribute.
|
||||
# @param [Object] Object to be compared
|
||||
def ==(o)
|
||||
return true if self.equal?(o)
|
||||
self.class == o.class &&
|
||||
array_of_string == o.array_of_string &&
|
||||
array_array_of_integer == o.array_array_of_integer &&
|
||||
array_array_of_model == o.array_array_of_model
|
||||
end
|
||||
|
||||
# @see the `==` method
|
||||
# @param [Object] Object to be compared
|
||||
def eql?(o)
|
||||
self == o
|
||||
end
|
||||
|
||||
# Calculates hash code according to all attributes.
|
||||
# @return [Integer] Hash code
|
||||
def hash
|
||||
[array_of_string, array_array_of_integer, array_array_of_model].hash
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def self.build_from_hash(attributes)
|
||||
new.build_from_hash(attributes)
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def build_from_hash(attributes)
|
||||
return nil unless attributes.is_a?(Hash)
|
||||
self.class.openapi_types.each_pair do |key, type|
|
||||
if type =~ /\AArray<(.*)>/i
|
||||
# check to ensure the input is an array given that the attribute
|
||||
# is documented as an array but the input is not
|
||||
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
||||
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
||||
end
|
||||
elsif !attributes[self.class.attribute_map[key]].nil?
|
||||
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
||||
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
||||
end
|
||||
|
||||
self
|
||||
end
|
||||
|
||||
# Deserializes the data based on type
|
||||
# @param string type Data type
|
||||
# @param string value Value to be deserialized
|
||||
# @return [Object] Deserialized data
|
||||
def _deserialize(type, value)
|
||||
case type.to_sym
|
||||
when :DateTime
|
||||
DateTime.parse(value)
|
||||
when :Date
|
||||
Date.parse(value)
|
||||
when :String
|
||||
value.to_s
|
||||
when :Integer
|
||||
value.to_i
|
||||
when :Float
|
||||
value.to_f
|
||||
when :Boolean
|
||||
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
when :Object
|
||||
# generic object (usually a Hash), return directly
|
||||
value
|
||||
when /\AArray<(?<inner_type>.+)>\z/
|
||||
inner_type = Regexp.last_match[:inner_type]
|
||||
value.map { |v| _deserialize(inner_type, v) }
|
||||
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
||||
k_type = Regexp.last_match[:k_type]
|
||||
v_type = Regexp.last_match[:v_type]
|
||||
{}.tap do |hash|
|
||||
value.each do |k, v|
|
||||
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
||||
end
|
||||
end
|
||||
else # model
|
||||
Petstore.const_get(type).build_from_hash(value)
|
||||
end
|
||||
end
|
||||
|
||||
# Returns the string representation of the object
|
||||
# @return [String] String presentation of the object
|
||||
def to_s
|
||||
to_hash.to_s
|
||||
end
|
||||
|
||||
# to_body is an alias to to_hash (backward compatibility)
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_body
|
||||
to_hash
|
||||
end
|
||||
|
||||
# Returns the object in the form of hash
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_hash
|
||||
hash = {}
|
||||
self.class.attribute_map.each_pair do |attr, param|
|
||||
value = self.send(attr)
|
||||
next if value.nil?
|
||||
hash[param] = _to_hash(value)
|
||||
end
|
||||
hash
|
||||
end
|
||||
|
||||
# Outputs non-array value in the form of hash
|
||||
# For object, use to_hash. Otherwise, just return the value
|
||||
# @param [Object] value Any valid value
|
||||
# @return [Hash] Returns the value in the form of hash
|
||||
def _to_hash(value)
|
||||
if value.is_a?(Array)
|
||||
value.compact.map { |v| _to_hash(v) }
|
||||
elsif value.is_a?(Hash)
|
||||
{}.tap do |hash|
|
||||
value.each { |k, v| hash[k] = _to_hash(v) }
|
||||
end
|
||||
elsif value.respond_to? :to_hash
|
||||
value.to_hash
|
||||
else
|
||||
value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,242 @@
|
||||
=begin
|
||||
#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: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
Generated by: https://openapi-generator.tech
|
||||
OpenAPI Generator version: 4.2.0-SNAPSHOT
|
||||
|
||||
=end
|
||||
|
||||
require 'date'
|
||||
|
||||
module Petstore
|
||||
class Capitalization
|
||||
attr_accessor :small_camel
|
||||
|
||||
attr_accessor :capital_camel
|
||||
|
||||
attr_accessor :small_snake
|
||||
|
||||
attr_accessor :capital_snake
|
||||
|
||||
attr_accessor :sca_eth_flow_points
|
||||
|
||||
# Name of the pet
|
||||
attr_accessor :att_name
|
||||
|
||||
# Attribute mapping from ruby-style variable name to JSON key.
|
||||
def self.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'
|
||||
}
|
||||
end
|
||||
|
||||
# Attribute type mapping.
|
||||
def self.openapi_types
|
||||
{
|
||||
:'small_camel' => :'String',
|
||||
:'capital_camel' => :'String',
|
||||
:'small_snake' => :'String',
|
||||
:'capital_snake' => :'String',
|
||||
:'sca_eth_flow_points' => :'String',
|
||||
:'att_name' => :'String'
|
||||
}
|
||||
end
|
||||
|
||||
# Initializes the object
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
def initialize(attributes = {})
|
||||
if (!attributes.is_a?(Hash))
|
||||
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::Capitalization` initialize method"
|
||||
end
|
||||
|
||||
# check to see if the attribute exists and convert string to symbol for hash key
|
||||
attributes = attributes.each_with_object({}) { |(k, v), h|
|
||||
if (!self.class.attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::Capitalization`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
||||
end
|
||||
h[k.to_sym] = v
|
||||
}
|
||||
|
||||
if attributes.key?(:'small_camel')
|
||||
self.small_camel = attributes[:'small_camel']
|
||||
end
|
||||
|
||||
if attributes.key?(:'capital_camel')
|
||||
self.capital_camel = attributes[:'capital_camel']
|
||||
end
|
||||
|
||||
if attributes.key?(:'small_snake')
|
||||
self.small_snake = attributes[:'small_snake']
|
||||
end
|
||||
|
||||
if attributes.key?(:'capital_snake')
|
||||
self.capital_snake = attributes[:'capital_snake']
|
||||
end
|
||||
|
||||
if attributes.key?(:'sca_eth_flow_points')
|
||||
self.sca_eth_flow_points = attributes[:'sca_eth_flow_points']
|
||||
end
|
||||
|
||||
if attributes.key?(:'att_name')
|
||||
self.att_name = attributes[:'att_name']
|
||||
end
|
||||
end
|
||||
|
||||
# Show invalid properties with the reasons. Usually used together with valid?
|
||||
# @return Array for valid properties with the reasons
|
||||
def list_invalid_properties
|
||||
invalid_properties = Array.new
|
||||
invalid_properties
|
||||
end
|
||||
|
||||
# Check to see if the all the properties in the model are valid
|
||||
# @return true if the model is valid
|
||||
def valid?
|
||||
true
|
||||
end
|
||||
|
||||
# Checks equality by comparing each attribute.
|
||||
# @param [Object] Object to be compared
|
||||
def ==(o)
|
||||
return true if self.equal?(o)
|
||||
self.class == o.class &&
|
||||
small_camel == o.small_camel &&
|
||||
capital_camel == o.capital_camel &&
|
||||
small_snake == o.small_snake &&
|
||||
capital_snake == o.capital_snake &&
|
||||
sca_eth_flow_points == o.sca_eth_flow_points &&
|
||||
att_name == o.att_name
|
||||
end
|
||||
|
||||
# @see the `==` method
|
||||
# @param [Object] Object to be compared
|
||||
def eql?(o)
|
||||
self == o
|
||||
end
|
||||
|
||||
# Calculates hash code according to all attributes.
|
||||
# @return [Integer] Hash code
|
||||
def hash
|
||||
[small_camel, capital_camel, small_snake, capital_snake, sca_eth_flow_points, att_name].hash
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def self.build_from_hash(attributes)
|
||||
new.build_from_hash(attributes)
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def build_from_hash(attributes)
|
||||
return nil unless attributes.is_a?(Hash)
|
||||
self.class.openapi_types.each_pair do |key, type|
|
||||
if type =~ /\AArray<(.*)>/i
|
||||
# check to ensure the input is an array given that the attribute
|
||||
# is documented as an array but the input is not
|
||||
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
||||
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
||||
end
|
||||
elsif !attributes[self.class.attribute_map[key]].nil?
|
||||
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
||||
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
||||
end
|
||||
|
||||
self
|
||||
end
|
||||
|
||||
# Deserializes the data based on type
|
||||
# @param string type Data type
|
||||
# @param string value Value to be deserialized
|
||||
# @return [Object] Deserialized data
|
||||
def _deserialize(type, value)
|
||||
case type.to_sym
|
||||
when :DateTime
|
||||
DateTime.parse(value)
|
||||
when :Date
|
||||
Date.parse(value)
|
||||
when :String
|
||||
value.to_s
|
||||
when :Integer
|
||||
value.to_i
|
||||
when :Float
|
||||
value.to_f
|
||||
when :Boolean
|
||||
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
when :Object
|
||||
# generic object (usually a Hash), return directly
|
||||
value
|
||||
when /\AArray<(?<inner_type>.+)>\z/
|
||||
inner_type = Regexp.last_match[:inner_type]
|
||||
value.map { |v| _deserialize(inner_type, v) }
|
||||
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
||||
k_type = Regexp.last_match[:k_type]
|
||||
v_type = Regexp.last_match[:v_type]
|
||||
{}.tap do |hash|
|
||||
value.each do |k, v|
|
||||
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
||||
end
|
||||
end
|
||||
else # model
|
||||
Petstore.const_get(type).build_from_hash(value)
|
||||
end
|
||||
end
|
||||
|
||||
# Returns the string representation of the object
|
||||
# @return [String] String presentation of the object
|
||||
def to_s
|
||||
to_hash.to_s
|
||||
end
|
||||
|
||||
# to_body is an alias to to_hash (backward compatibility)
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_body
|
||||
to_hash
|
||||
end
|
||||
|
||||
# Returns the object in the form of hash
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_hash
|
||||
hash = {}
|
||||
self.class.attribute_map.each_pair do |attr, param|
|
||||
value = self.send(attr)
|
||||
next if value.nil?
|
||||
hash[param] = _to_hash(value)
|
||||
end
|
||||
hash
|
||||
end
|
||||
|
||||
# Outputs non-array value in the form of hash
|
||||
# For object, use to_hash. Otherwise, just return the value
|
||||
# @param [Object] value Any valid value
|
||||
# @return [Hash] Returns the value in the form of hash
|
||||
def _to_hash(value)
|
||||
if value.is_a?(Array)
|
||||
value.compact.map { |v| _to_hash(v) }
|
||||
elsif value.is_a?(Hash)
|
||||
{}.tap do |hash|
|
||||
value.each { |k, v| hash[k] = _to_hash(v) }
|
||||
end
|
||||
elsif value.respond_to? :to_hash
|
||||
value.to_hash
|
||||
else
|
||||
value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
208
samples/client/petstore/ruby/lib/petstore/models/cat.rb
Normal file
208
samples/client/petstore/ruby/lib/petstore/models/cat.rb
Normal file
@ -0,0 +1,208 @@
|
||||
=begin
|
||||
#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: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
Generated by: https://openapi-generator.tech
|
||||
OpenAPI Generator version: 4.2.0-SNAPSHOT
|
||||
|
||||
=end
|
||||
|
||||
require 'date'
|
||||
|
||||
module Petstore
|
||||
class Cat < Animal
|
||||
attr_accessor :declawed
|
||||
|
||||
# Attribute mapping from ruby-style variable name to JSON key.
|
||||
def self.attribute_map
|
||||
{
|
||||
:'declawed' => :'declawed'
|
||||
}
|
||||
end
|
||||
|
||||
# Attribute type mapping.
|
||||
def self.openapi_types
|
||||
{
|
||||
:'declawed' => :'Boolean'
|
||||
}
|
||||
end
|
||||
|
||||
# List of class defined in allOf (OpenAPI v3)
|
||||
def self.openapi_all_of
|
||||
[
|
||||
:'Animal',
|
||||
:'CatAllOf'
|
||||
]
|
||||
end
|
||||
|
||||
# Initializes the object
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
def initialize(attributes = {})
|
||||
if (!attributes.is_a?(Hash))
|
||||
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::Cat` initialize method"
|
||||
end
|
||||
|
||||
# check to see if the attribute exists and convert string to symbol for hash key
|
||||
attributes = attributes.each_with_object({}) { |(k, v), h|
|
||||
if (!self.class.attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::Cat`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
||||
end
|
||||
h[k.to_sym] = v
|
||||
}
|
||||
|
||||
# call parent's initialize
|
||||
super(attributes)
|
||||
|
||||
if attributes.key?(:'declawed')
|
||||
self.declawed = attributes[:'declawed']
|
||||
end
|
||||
end
|
||||
|
||||
# Show invalid properties with the reasons. Usually used together with valid?
|
||||
# @return Array for valid properties with the reasons
|
||||
def list_invalid_properties
|
||||
invalid_properties = super
|
||||
invalid_properties
|
||||
end
|
||||
|
||||
# Check to see if the all the properties in the model are valid
|
||||
# @return true if the model is valid
|
||||
def valid?
|
||||
true && super
|
||||
end
|
||||
|
||||
# Checks equality by comparing each attribute.
|
||||
# @param [Object] Object to be compared
|
||||
def ==(o)
|
||||
return true if self.equal?(o)
|
||||
self.class == o.class &&
|
||||
declawed == o.declawed && super(o)
|
||||
end
|
||||
|
||||
# @see the `==` method
|
||||
# @param [Object] Object to be compared
|
||||
def eql?(o)
|
||||
self == o
|
||||
end
|
||||
|
||||
# Calculates hash code according to all attributes.
|
||||
# @return [Integer] Hash code
|
||||
def hash
|
||||
[declawed].hash
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def self.build_from_hash(attributes)
|
||||
new.build_from_hash(attributes)
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def build_from_hash(attributes)
|
||||
return nil unless attributes.is_a?(Hash)
|
||||
super(attributes)
|
||||
self.class.openapi_types.each_pair do |key, type|
|
||||
if type =~ /\AArray<(.*)>/i
|
||||
# check to ensure the input is an array given that the attribute
|
||||
# is documented as an array but the input is not
|
||||
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
||||
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
||||
end
|
||||
elsif !attributes[self.class.attribute_map[key]].nil?
|
||||
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
||||
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
||||
end
|
||||
|
||||
self
|
||||
end
|
||||
|
||||
# Deserializes the data based on type
|
||||
# @param string type Data type
|
||||
# @param string value Value to be deserialized
|
||||
# @return [Object] Deserialized data
|
||||
def _deserialize(type, value)
|
||||
case type.to_sym
|
||||
when :DateTime
|
||||
DateTime.parse(value)
|
||||
when :Date
|
||||
Date.parse(value)
|
||||
when :String
|
||||
value.to_s
|
||||
when :Integer
|
||||
value.to_i
|
||||
when :Float
|
||||
value.to_f
|
||||
when :Boolean
|
||||
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
when :Object
|
||||
# generic object (usually a Hash), return directly
|
||||
value
|
||||
when /\AArray<(?<inner_type>.+)>\z/
|
||||
inner_type = Regexp.last_match[:inner_type]
|
||||
value.map { |v| _deserialize(inner_type, v) }
|
||||
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
||||
k_type = Regexp.last_match[:k_type]
|
||||
v_type = Regexp.last_match[:v_type]
|
||||
{}.tap do |hash|
|
||||
value.each do |k, v|
|
||||
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
||||
end
|
||||
end
|
||||
else # model
|
||||
Petstore.const_get(type).build_from_hash(value)
|
||||
end
|
||||
end
|
||||
|
||||
# Returns the string representation of the object
|
||||
# @return [String] String presentation of the object
|
||||
def to_s
|
||||
to_hash.to_s
|
||||
end
|
||||
|
||||
# to_body is an alias to to_hash (backward compatibility)
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_body
|
||||
to_hash
|
||||
end
|
||||
|
||||
# Returns the object in the form of hash
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_hash
|
||||
hash = super
|
||||
self.class.attribute_map.each_pair do |attr, param|
|
||||
value = self.send(attr)
|
||||
next if value.nil?
|
||||
hash[param] = _to_hash(value)
|
||||
end
|
||||
hash
|
||||
end
|
||||
|
||||
# Outputs non-array value in the form of hash
|
||||
# For object, use to_hash. Otherwise, just return the value
|
||||
# @param [Object] value Any valid value
|
||||
# @return [Hash] Returns the value in the form of hash
|
||||
def _to_hash(value)
|
||||
if value.is_a?(Array)
|
||||
value.compact.map { |v| _to_hash(v) }
|
||||
elsif value.is_a?(Hash)
|
||||
{}.tap do |hash|
|
||||
value.each { |k, v| hash[k] = _to_hash(v) }
|
||||
end
|
||||
elsif value.respond_to? :to_hash
|
||||
value.to_hash
|
||||
else
|
||||
value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
196
samples/client/petstore/ruby/lib/petstore/models/cat_all_of.rb
Normal file
196
samples/client/petstore/ruby/lib/petstore/models/cat_all_of.rb
Normal file
@ -0,0 +1,196 @@
|
||||
=begin
|
||||
#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: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
Generated by: https://openapi-generator.tech
|
||||
OpenAPI Generator version: 4.2.0-SNAPSHOT
|
||||
|
||||
=end
|
||||
|
||||
require 'date'
|
||||
|
||||
module Petstore
|
||||
class CatAllOf
|
||||
attr_accessor :declawed
|
||||
|
||||
# Attribute mapping from ruby-style variable name to JSON key.
|
||||
def self.attribute_map
|
||||
{
|
||||
:'declawed' => :'declawed'
|
||||
}
|
||||
end
|
||||
|
||||
# Attribute type mapping.
|
||||
def self.openapi_types
|
||||
{
|
||||
:'declawed' => :'Boolean'
|
||||
}
|
||||
end
|
||||
|
||||
# Initializes the object
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
def initialize(attributes = {})
|
||||
if (!attributes.is_a?(Hash))
|
||||
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::CatAllOf` initialize method"
|
||||
end
|
||||
|
||||
# check to see if the attribute exists and convert string to symbol for hash key
|
||||
attributes = attributes.each_with_object({}) { |(k, v), h|
|
||||
if (!self.class.attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::CatAllOf`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
||||
end
|
||||
h[k.to_sym] = v
|
||||
}
|
||||
|
||||
if attributes.key?(:'declawed')
|
||||
self.declawed = attributes[:'declawed']
|
||||
end
|
||||
end
|
||||
|
||||
# Show invalid properties with the reasons. Usually used together with valid?
|
||||
# @return Array for valid properties with the reasons
|
||||
def list_invalid_properties
|
||||
invalid_properties = Array.new
|
||||
invalid_properties
|
||||
end
|
||||
|
||||
# Check to see if the all the properties in the model are valid
|
||||
# @return true if the model is valid
|
||||
def valid?
|
||||
true
|
||||
end
|
||||
|
||||
# Checks equality by comparing each attribute.
|
||||
# @param [Object] Object to be compared
|
||||
def ==(o)
|
||||
return true if self.equal?(o)
|
||||
self.class == o.class &&
|
||||
declawed == o.declawed
|
||||
end
|
||||
|
||||
# @see the `==` method
|
||||
# @param [Object] Object to be compared
|
||||
def eql?(o)
|
||||
self == o
|
||||
end
|
||||
|
||||
# Calculates hash code according to all attributes.
|
||||
# @return [Integer] Hash code
|
||||
def hash
|
||||
[declawed].hash
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def self.build_from_hash(attributes)
|
||||
new.build_from_hash(attributes)
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def build_from_hash(attributes)
|
||||
return nil unless attributes.is_a?(Hash)
|
||||
self.class.openapi_types.each_pair do |key, type|
|
||||
if type =~ /\AArray<(.*)>/i
|
||||
# check to ensure the input is an array given that the attribute
|
||||
# is documented as an array but the input is not
|
||||
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
||||
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
||||
end
|
||||
elsif !attributes[self.class.attribute_map[key]].nil?
|
||||
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
||||
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
||||
end
|
||||
|
||||
self
|
||||
end
|
||||
|
||||
# Deserializes the data based on type
|
||||
# @param string type Data type
|
||||
# @param string value Value to be deserialized
|
||||
# @return [Object] Deserialized data
|
||||
def _deserialize(type, value)
|
||||
case type.to_sym
|
||||
when :DateTime
|
||||
DateTime.parse(value)
|
||||
when :Date
|
||||
Date.parse(value)
|
||||
when :String
|
||||
value.to_s
|
||||
when :Integer
|
||||
value.to_i
|
||||
when :Float
|
||||
value.to_f
|
||||
when :Boolean
|
||||
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
when :Object
|
||||
# generic object (usually a Hash), return directly
|
||||
value
|
||||
when /\AArray<(?<inner_type>.+)>\z/
|
||||
inner_type = Regexp.last_match[:inner_type]
|
||||
value.map { |v| _deserialize(inner_type, v) }
|
||||
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
||||
k_type = Regexp.last_match[:k_type]
|
||||
v_type = Regexp.last_match[:v_type]
|
||||
{}.tap do |hash|
|
||||
value.each do |k, v|
|
||||
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
||||
end
|
||||
end
|
||||
else # model
|
||||
Petstore.const_get(type).build_from_hash(value)
|
||||
end
|
||||
end
|
||||
|
||||
# Returns the string representation of the object
|
||||
# @return [String] String presentation of the object
|
||||
def to_s
|
||||
to_hash.to_s
|
||||
end
|
||||
|
||||
# to_body is an alias to to_hash (backward compatibility)
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_body
|
||||
to_hash
|
||||
end
|
||||
|
||||
# Returns the object in the form of hash
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_hash
|
||||
hash = {}
|
||||
self.class.attribute_map.each_pair do |attr, param|
|
||||
value = self.send(attr)
|
||||
next if value.nil?
|
||||
hash[param] = _to_hash(value)
|
||||
end
|
||||
hash
|
||||
end
|
||||
|
||||
# Outputs non-array value in the form of hash
|
||||
# For object, use to_hash. Otherwise, just return the value
|
||||
# @param [Object] value Any valid value
|
||||
# @return [Hash] Returns the value in the form of hash
|
||||
def _to_hash(value)
|
||||
if value.is_a?(Array)
|
||||
value.compact.map { |v| _to_hash(v) }
|
||||
elsif value.is_a?(Hash)
|
||||
{}.tap do |hash|
|
||||
value.each { |k, v| hash[k] = _to_hash(v) }
|
||||
end
|
||||
elsif value.respond_to? :to_hash
|
||||
value.to_hash
|
||||
else
|
||||
value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
212
samples/client/petstore/ruby/lib/petstore/models/category.rb
Normal file
212
samples/client/petstore/ruby/lib/petstore/models/category.rb
Normal file
@ -0,0 +1,212 @@
|
||||
=begin
|
||||
#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: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
Generated by: https://openapi-generator.tech
|
||||
OpenAPI Generator version: 4.2.0-SNAPSHOT
|
||||
|
||||
=end
|
||||
|
||||
require 'date'
|
||||
|
||||
module Petstore
|
||||
class Category
|
||||
attr_accessor :id
|
||||
|
||||
attr_accessor :name
|
||||
|
||||
# Attribute mapping from ruby-style variable name to JSON key.
|
||||
def self.attribute_map
|
||||
{
|
||||
:'id' => :'id',
|
||||
:'name' => :'name'
|
||||
}
|
||||
end
|
||||
|
||||
# Attribute type mapping.
|
||||
def self.openapi_types
|
||||
{
|
||||
:'id' => :'Integer',
|
||||
:'name' => :'String'
|
||||
}
|
||||
end
|
||||
|
||||
# Initializes the object
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
def initialize(attributes = {})
|
||||
if (!attributes.is_a?(Hash))
|
||||
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::Category` initialize method"
|
||||
end
|
||||
|
||||
# check to see if the attribute exists and convert string to symbol for hash key
|
||||
attributes = attributes.each_with_object({}) { |(k, v), h|
|
||||
if (!self.class.attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::Category`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
||||
end
|
||||
h[k.to_sym] = v
|
||||
}
|
||||
|
||||
if attributes.key?(:'id')
|
||||
self.id = attributes[:'id']
|
||||
end
|
||||
|
||||
if attributes.key?(:'name')
|
||||
self.name = attributes[:'name']
|
||||
else
|
||||
self.name = 'default-name'
|
||||
end
|
||||
end
|
||||
|
||||
# Show invalid properties with the reasons. Usually used together with valid?
|
||||
# @return Array for valid properties with the reasons
|
||||
def list_invalid_properties
|
||||
invalid_properties = Array.new
|
||||
if @name.nil?
|
||||
invalid_properties.push('invalid value for "name", name cannot be nil.')
|
||||
end
|
||||
|
||||
invalid_properties
|
||||
end
|
||||
|
||||
# Check to see if the all the properties in the model are valid
|
||||
# @return true if the model is valid
|
||||
def valid?
|
||||
return false if @name.nil?
|
||||
true
|
||||
end
|
||||
|
||||
# Checks equality by comparing each attribute.
|
||||
# @param [Object] Object to be compared
|
||||
def ==(o)
|
||||
return true if self.equal?(o)
|
||||
self.class == o.class &&
|
||||
id == o.id &&
|
||||
name == o.name
|
||||
end
|
||||
|
||||
# @see the `==` method
|
||||
# @param [Object] Object to be compared
|
||||
def eql?(o)
|
||||
self == o
|
||||
end
|
||||
|
||||
# Calculates hash code according to all attributes.
|
||||
# @return [Integer] Hash code
|
||||
def hash
|
||||
[id, name].hash
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def self.build_from_hash(attributes)
|
||||
new.build_from_hash(attributes)
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def build_from_hash(attributes)
|
||||
return nil unless attributes.is_a?(Hash)
|
||||
self.class.openapi_types.each_pair do |key, type|
|
||||
if type =~ /\AArray<(.*)>/i
|
||||
# check to ensure the input is an array given that the attribute
|
||||
# is documented as an array but the input is not
|
||||
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
||||
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
||||
end
|
||||
elsif !attributes[self.class.attribute_map[key]].nil?
|
||||
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
||||
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
||||
end
|
||||
|
||||
self
|
||||
end
|
||||
|
||||
# Deserializes the data based on type
|
||||
# @param string type Data type
|
||||
# @param string value Value to be deserialized
|
||||
# @return [Object] Deserialized data
|
||||
def _deserialize(type, value)
|
||||
case type.to_sym
|
||||
when :DateTime
|
||||
DateTime.parse(value)
|
||||
when :Date
|
||||
Date.parse(value)
|
||||
when :String
|
||||
value.to_s
|
||||
when :Integer
|
||||
value.to_i
|
||||
when :Float
|
||||
value.to_f
|
||||
when :Boolean
|
||||
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
when :Object
|
||||
# generic object (usually a Hash), return directly
|
||||
value
|
||||
when /\AArray<(?<inner_type>.+)>\z/
|
||||
inner_type = Regexp.last_match[:inner_type]
|
||||
value.map { |v| _deserialize(inner_type, v) }
|
||||
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
||||
k_type = Regexp.last_match[:k_type]
|
||||
v_type = Regexp.last_match[:v_type]
|
||||
{}.tap do |hash|
|
||||
value.each do |k, v|
|
||||
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
||||
end
|
||||
end
|
||||
else # model
|
||||
Petstore.const_get(type).build_from_hash(value)
|
||||
end
|
||||
end
|
||||
|
||||
# Returns the string representation of the object
|
||||
# @return [String] String presentation of the object
|
||||
def to_s
|
||||
to_hash.to_s
|
||||
end
|
||||
|
||||
# to_body is an alias to to_hash (backward compatibility)
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_body
|
||||
to_hash
|
||||
end
|
||||
|
||||
# Returns the object in the form of hash
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_hash
|
||||
hash = {}
|
||||
self.class.attribute_map.each_pair do |attr, param|
|
||||
value = self.send(attr)
|
||||
next if value.nil?
|
||||
hash[param] = _to_hash(value)
|
||||
end
|
||||
hash
|
||||
end
|
||||
|
||||
# Outputs non-array value in the form of hash
|
||||
# For object, use to_hash. Otherwise, just return the value
|
||||
# @param [Object] value Any valid value
|
||||
# @return [Hash] Returns the value in the form of hash
|
||||
def _to_hash(value)
|
||||
if value.is_a?(Array)
|
||||
value.compact.map { |v| _to_hash(v) }
|
||||
elsif value.is_a?(Hash)
|
||||
{}.tap do |hash|
|
||||
value.each { |k, v| hash[k] = _to_hash(v) }
|
||||
end
|
||||
elsif value.respond_to? :to_hash
|
||||
value.to_hash
|
||||
else
|
||||
value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
197
samples/client/petstore/ruby/lib/petstore/models/class_model.rb
Normal file
197
samples/client/petstore/ruby/lib/petstore/models/class_model.rb
Normal file
@ -0,0 +1,197 @@
|
||||
=begin
|
||||
#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: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
Generated by: https://openapi-generator.tech
|
||||
OpenAPI Generator version: 4.2.0-SNAPSHOT
|
||||
|
||||
=end
|
||||
|
||||
require 'date'
|
||||
|
||||
module Petstore
|
||||
# Model for testing model with \"_class\" property
|
||||
class ClassModel
|
||||
attr_accessor :_class
|
||||
|
||||
# Attribute mapping from ruby-style variable name to JSON key.
|
||||
def self.attribute_map
|
||||
{
|
||||
:'_class' => :'_class'
|
||||
}
|
||||
end
|
||||
|
||||
# Attribute type mapping.
|
||||
def self.openapi_types
|
||||
{
|
||||
:'_class' => :'String'
|
||||
}
|
||||
end
|
||||
|
||||
# Initializes the object
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
def initialize(attributes = {})
|
||||
if (!attributes.is_a?(Hash))
|
||||
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::ClassModel` initialize method"
|
||||
end
|
||||
|
||||
# check to see if the attribute exists and convert string to symbol for hash key
|
||||
attributes = attributes.each_with_object({}) { |(k, v), h|
|
||||
if (!self.class.attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::ClassModel`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
||||
end
|
||||
h[k.to_sym] = v
|
||||
}
|
||||
|
||||
if attributes.key?(:'_class')
|
||||
self._class = attributes[:'_class']
|
||||
end
|
||||
end
|
||||
|
||||
# Show invalid properties with the reasons. Usually used together with valid?
|
||||
# @return Array for valid properties with the reasons
|
||||
def list_invalid_properties
|
||||
invalid_properties = Array.new
|
||||
invalid_properties
|
||||
end
|
||||
|
||||
# Check to see if the all the properties in the model are valid
|
||||
# @return true if the model is valid
|
||||
def valid?
|
||||
true
|
||||
end
|
||||
|
||||
# Checks equality by comparing each attribute.
|
||||
# @param [Object] Object to be compared
|
||||
def ==(o)
|
||||
return true if self.equal?(o)
|
||||
self.class == o.class &&
|
||||
_class == o._class
|
||||
end
|
||||
|
||||
# @see the `==` method
|
||||
# @param [Object] Object to be compared
|
||||
def eql?(o)
|
||||
self == o
|
||||
end
|
||||
|
||||
# Calculates hash code according to all attributes.
|
||||
# @return [Integer] Hash code
|
||||
def hash
|
||||
[_class].hash
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def self.build_from_hash(attributes)
|
||||
new.build_from_hash(attributes)
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def build_from_hash(attributes)
|
||||
return nil unless attributes.is_a?(Hash)
|
||||
self.class.openapi_types.each_pair do |key, type|
|
||||
if type =~ /\AArray<(.*)>/i
|
||||
# check to ensure the input is an array given that the attribute
|
||||
# is documented as an array but the input is not
|
||||
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
||||
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
||||
end
|
||||
elsif !attributes[self.class.attribute_map[key]].nil?
|
||||
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
||||
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
||||
end
|
||||
|
||||
self
|
||||
end
|
||||
|
||||
# Deserializes the data based on type
|
||||
# @param string type Data type
|
||||
# @param string value Value to be deserialized
|
||||
# @return [Object] Deserialized data
|
||||
def _deserialize(type, value)
|
||||
case type.to_sym
|
||||
when :DateTime
|
||||
DateTime.parse(value)
|
||||
when :Date
|
||||
Date.parse(value)
|
||||
when :String
|
||||
value.to_s
|
||||
when :Integer
|
||||
value.to_i
|
||||
when :Float
|
||||
value.to_f
|
||||
when :Boolean
|
||||
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
when :Object
|
||||
# generic object (usually a Hash), return directly
|
||||
value
|
||||
when /\AArray<(?<inner_type>.+)>\z/
|
||||
inner_type = Regexp.last_match[:inner_type]
|
||||
value.map { |v| _deserialize(inner_type, v) }
|
||||
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
||||
k_type = Regexp.last_match[:k_type]
|
||||
v_type = Regexp.last_match[:v_type]
|
||||
{}.tap do |hash|
|
||||
value.each do |k, v|
|
||||
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
||||
end
|
||||
end
|
||||
else # model
|
||||
Petstore.const_get(type).build_from_hash(value)
|
||||
end
|
||||
end
|
||||
|
||||
# Returns the string representation of the object
|
||||
# @return [String] String presentation of the object
|
||||
def to_s
|
||||
to_hash.to_s
|
||||
end
|
||||
|
||||
# to_body is an alias to to_hash (backward compatibility)
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_body
|
||||
to_hash
|
||||
end
|
||||
|
||||
# Returns the object in the form of hash
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_hash
|
||||
hash = {}
|
||||
self.class.attribute_map.each_pair do |attr, param|
|
||||
value = self.send(attr)
|
||||
next if value.nil?
|
||||
hash[param] = _to_hash(value)
|
||||
end
|
||||
hash
|
||||
end
|
||||
|
||||
# Outputs non-array value in the form of hash
|
||||
# For object, use to_hash. Otherwise, just return the value
|
||||
# @param [Object] value Any valid value
|
||||
# @return [Hash] Returns the value in the form of hash
|
||||
def _to_hash(value)
|
||||
if value.is_a?(Array)
|
||||
value.compact.map { |v| _to_hash(v) }
|
||||
elsif value.is_a?(Hash)
|
||||
{}.tap do |hash|
|
||||
value.each { |k, v| hash[k] = _to_hash(v) }
|
||||
end
|
||||
elsif value.respond_to? :to_hash
|
||||
value.to_hash
|
||||
else
|
||||
value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
196
samples/client/petstore/ruby/lib/petstore/models/client.rb
Normal file
196
samples/client/petstore/ruby/lib/petstore/models/client.rb
Normal file
@ -0,0 +1,196 @@
|
||||
=begin
|
||||
#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: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
Generated by: https://openapi-generator.tech
|
||||
OpenAPI Generator version: 4.2.0-SNAPSHOT
|
||||
|
||||
=end
|
||||
|
||||
require 'date'
|
||||
|
||||
module Petstore
|
||||
class Client
|
||||
attr_accessor :client
|
||||
|
||||
# Attribute mapping from ruby-style variable name to JSON key.
|
||||
def self.attribute_map
|
||||
{
|
||||
:'client' => :'client'
|
||||
}
|
||||
end
|
||||
|
||||
# Attribute type mapping.
|
||||
def self.openapi_types
|
||||
{
|
||||
:'client' => :'String'
|
||||
}
|
||||
end
|
||||
|
||||
# Initializes the object
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
def initialize(attributes = {})
|
||||
if (!attributes.is_a?(Hash))
|
||||
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::Client` initialize method"
|
||||
end
|
||||
|
||||
# check to see if the attribute exists and convert string to symbol for hash key
|
||||
attributes = attributes.each_with_object({}) { |(k, v), h|
|
||||
if (!self.class.attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::Client`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
||||
end
|
||||
h[k.to_sym] = v
|
||||
}
|
||||
|
||||
if attributes.key?(:'client')
|
||||
self.client = attributes[:'client']
|
||||
end
|
||||
end
|
||||
|
||||
# Show invalid properties with the reasons. Usually used together with valid?
|
||||
# @return Array for valid properties with the reasons
|
||||
def list_invalid_properties
|
||||
invalid_properties = Array.new
|
||||
invalid_properties
|
||||
end
|
||||
|
||||
# Check to see if the all the properties in the model are valid
|
||||
# @return true if the model is valid
|
||||
def valid?
|
||||
true
|
||||
end
|
||||
|
||||
# Checks equality by comparing each attribute.
|
||||
# @param [Object] Object to be compared
|
||||
def ==(o)
|
||||
return true if self.equal?(o)
|
||||
self.class == o.class &&
|
||||
client == o.client
|
||||
end
|
||||
|
||||
# @see the `==` method
|
||||
# @param [Object] Object to be compared
|
||||
def eql?(o)
|
||||
self == o
|
||||
end
|
||||
|
||||
# Calculates hash code according to all attributes.
|
||||
# @return [Integer] Hash code
|
||||
def hash
|
||||
[client].hash
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def self.build_from_hash(attributes)
|
||||
new.build_from_hash(attributes)
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def build_from_hash(attributes)
|
||||
return nil unless attributes.is_a?(Hash)
|
||||
self.class.openapi_types.each_pair do |key, type|
|
||||
if type =~ /\AArray<(.*)>/i
|
||||
# check to ensure the input is an array given that the attribute
|
||||
# is documented as an array but the input is not
|
||||
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
||||
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
||||
end
|
||||
elsif !attributes[self.class.attribute_map[key]].nil?
|
||||
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
||||
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
||||
end
|
||||
|
||||
self
|
||||
end
|
||||
|
||||
# Deserializes the data based on type
|
||||
# @param string type Data type
|
||||
# @param string value Value to be deserialized
|
||||
# @return [Object] Deserialized data
|
||||
def _deserialize(type, value)
|
||||
case type.to_sym
|
||||
when :DateTime
|
||||
DateTime.parse(value)
|
||||
when :Date
|
||||
Date.parse(value)
|
||||
when :String
|
||||
value.to_s
|
||||
when :Integer
|
||||
value.to_i
|
||||
when :Float
|
||||
value.to_f
|
||||
when :Boolean
|
||||
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
when :Object
|
||||
# generic object (usually a Hash), return directly
|
||||
value
|
||||
when /\AArray<(?<inner_type>.+)>\z/
|
||||
inner_type = Regexp.last_match[:inner_type]
|
||||
value.map { |v| _deserialize(inner_type, v) }
|
||||
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
||||
k_type = Regexp.last_match[:k_type]
|
||||
v_type = Regexp.last_match[:v_type]
|
||||
{}.tap do |hash|
|
||||
value.each do |k, v|
|
||||
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
||||
end
|
||||
end
|
||||
else # model
|
||||
Petstore.const_get(type).build_from_hash(value)
|
||||
end
|
||||
end
|
||||
|
||||
# Returns the string representation of the object
|
||||
# @return [String] String presentation of the object
|
||||
def to_s
|
||||
to_hash.to_s
|
||||
end
|
||||
|
||||
# to_body is an alias to to_hash (backward compatibility)
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_body
|
||||
to_hash
|
||||
end
|
||||
|
||||
# Returns the object in the form of hash
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_hash
|
||||
hash = {}
|
||||
self.class.attribute_map.each_pair do |attr, param|
|
||||
value = self.send(attr)
|
||||
next if value.nil?
|
||||
hash[param] = _to_hash(value)
|
||||
end
|
||||
hash
|
||||
end
|
||||
|
||||
# Outputs non-array value in the form of hash
|
||||
# For object, use to_hash. Otherwise, just return the value
|
||||
# @param [Object] value Any valid value
|
||||
# @return [Hash] Returns the value in the form of hash
|
||||
def _to_hash(value)
|
||||
if value.is_a?(Array)
|
||||
value.compact.map { |v| _to_hash(v) }
|
||||
elsif value.is_a?(Hash)
|
||||
{}.tap do |hash|
|
||||
value.each { |k, v| hash[k] = _to_hash(v) }
|
||||
end
|
||||
elsif value.respond_to? :to_hash
|
||||
value.to_hash
|
||||
else
|
||||
value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
208
samples/client/petstore/ruby/lib/petstore/models/dog.rb
Normal file
208
samples/client/petstore/ruby/lib/petstore/models/dog.rb
Normal file
@ -0,0 +1,208 @@
|
||||
=begin
|
||||
#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: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
Generated by: https://openapi-generator.tech
|
||||
OpenAPI Generator version: 4.2.0-SNAPSHOT
|
||||
|
||||
=end
|
||||
|
||||
require 'date'
|
||||
|
||||
module Petstore
|
||||
class Dog < Animal
|
||||
attr_accessor :breed
|
||||
|
||||
# Attribute mapping from ruby-style variable name to JSON key.
|
||||
def self.attribute_map
|
||||
{
|
||||
:'breed' => :'breed'
|
||||
}
|
||||
end
|
||||
|
||||
# Attribute type mapping.
|
||||
def self.openapi_types
|
||||
{
|
||||
:'breed' => :'String'
|
||||
}
|
||||
end
|
||||
|
||||
# List of class defined in allOf (OpenAPI v3)
|
||||
def self.openapi_all_of
|
||||
[
|
||||
:'Animal',
|
||||
:'DogAllOf'
|
||||
]
|
||||
end
|
||||
|
||||
# Initializes the object
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
def initialize(attributes = {})
|
||||
if (!attributes.is_a?(Hash))
|
||||
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::Dog` initialize method"
|
||||
end
|
||||
|
||||
# check to see if the attribute exists and convert string to symbol for hash key
|
||||
attributes = attributes.each_with_object({}) { |(k, v), h|
|
||||
if (!self.class.attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::Dog`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
||||
end
|
||||
h[k.to_sym] = v
|
||||
}
|
||||
|
||||
# call parent's initialize
|
||||
super(attributes)
|
||||
|
||||
if attributes.key?(:'breed')
|
||||
self.breed = attributes[:'breed']
|
||||
end
|
||||
end
|
||||
|
||||
# Show invalid properties with the reasons. Usually used together with valid?
|
||||
# @return Array for valid properties with the reasons
|
||||
def list_invalid_properties
|
||||
invalid_properties = super
|
||||
invalid_properties
|
||||
end
|
||||
|
||||
# Check to see if the all the properties in the model are valid
|
||||
# @return true if the model is valid
|
||||
def valid?
|
||||
true && super
|
||||
end
|
||||
|
||||
# Checks equality by comparing each attribute.
|
||||
# @param [Object] Object to be compared
|
||||
def ==(o)
|
||||
return true if self.equal?(o)
|
||||
self.class == o.class &&
|
||||
breed == o.breed && super(o)
|
||||
end
|
||||
|
||||
# @see the `==` method
|
||||
# @param [Object] Object to be compared
|
||||
def eql?(o)
|
||||
self == o
|
||||
end
|
||||
|
||||
# Calculates hash code according to all attributes.
|
||||
# @return [Integer] Hash code
|
||||
def hash
|
||||
[breed].hash
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def self.build_from_hash(attributes)
|
||||
new.build_from_hash(attributes)
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def build_from_hash(attributes)
|
||||
return nil unless attributes.is_a?(Hash)
|
||||
super(attributes)
|
||||
self.class.openapi_types.each_pair do |key, type|
|
||||
if type =~ /\AArray<(.*)>/i
|
||||
# check to ensure the input is an array given that the attribute
|
||||
# is documented as an array but the input is not
|
||||
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
||||
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
||||
end
|
||||
elsif !attributes[self.class.attribute_map[key]].nil?
|
||||
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
||||
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
||||
end
|
||||
|
||||
self
|
||||
end
|
||||
|
||||
# Deserializes the data based on type
|
||||
# @param string type Data type
|
||||
# @param string value Value to be deserialized
|
||||
# @return [Object] Deserialized data
|
||||
def _deserialize(type, value)
|
||||
case type.to_sym
|
||||
when :DateTime
|
||||
DateTime.parse(value)
|
||||
when :Date
|
||||
Date.parse(value)
|
||||
when :String
|
||||
value.to_s
|
||||
when :Integer
|
||||
value.to_i
|
||||
when :Float
|
||||
value.to_f
|
||||
when :Boolean
|
||||
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
when :Object
|
||||
# generic object (usually a Hash), return directly
|
||||
value
|
||||
when /\AArray<(?<inner_type>.+)>\z/
|
||||
inner_type = Regexp.last_match[:inner_type]
|
||||
value.map { |v| _deserialize(inner_type, v) }
|
||||
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
||||
k_type = Regexp.last_match[:k_type]
|
||||
v_type = Regexp.last_match[:v_type]
|
||||
{}.tap do |hash|
|
||||
value.each do |k, v|
|
||||
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
||||
end
|
||||
end
|
||||
else # model
|
||||
Petstore.const_get(type).build_from_hash(value)
|
||||
end
|
||||
end
|
||||
|
||||
# Returns the string representation of the object
|
||||
# @return [String] String presentation of the object
|
||||
def to_s
|
||||
to_hash.to_s
|
||||
end
|
||||
|
||||
# to_body is an alias to to_hash (backward compatibility)
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_body
|
||||
to_hash
|
||||
end
|
||||
|
||||
# Returns the object in the form of hash
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_hash
|
||||
hash = super
|
||||
self.class.attribute_map.each_pair do |attr, param|
|
||||
value = self.send(attr)
|
||||
next if value.nil?
|
||||
hash[param] = _to_hash(value)
|
||||
end
|
||||
hash
|
||||
end
|
||||
|
||||
# Outputs non-array value in the form of hash
|
||||
# For object, use to_hash. Otherwise, just return the value
|
||||
# @param [Object] value Any valid value
|
||||
# @return [Hash] Returns the value in the form of hash
|
||||
def _to_hash(value)
|
||||
if value.is_a?(Array)
|
||||
value.compact.map { |v| _to_hash(v) }
|
||||
elsif value.is_a?(Hash)
|
||||
{}.tap do |hash|
|
||||
value.each { |k, v| hash[k] = _to_hash(v) }
|
||||
end
|
||||
elsif value.respond_to? :to_hash
|
||||
value.to_hash
|
||||
else
|
||||
value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
196
samples/client/petstore/ruby/lib/petstore/models/dog_all_of.rb
Normal file
196
samples/client/petstore/ruby/lib/petstore/models/dog_all_of.rb
Normal file
@ -0,0 +1,196 @@
|
||||
=begin
|
||||
#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: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
Generated by: https://openapi-generator.tech
|
||||
OpenAPI Generator version: 4.2.0-SNAPSHOT
|
||||
|
||||
=end
|
||||
|
||||
require 'date'
|
||||
|
||||
module Petstore
|
||||
class DogAllOf
|
||||
attr_accessor :breed
|
||||
|
||||
# Attribute mapping from ruby-style variable name to JSON key.
|
||||
def self.attribute_map
|
||||
{
|
||||
:'breed' => :'breed'
|
||||
}
|
||||
end
|
||||
|
||||
# Attribute type mapping.
|
||||
def self.openapi_types
|
||||
{
|
||||
:'breed' => :'String'
|
||||
}
|
||||
end
|
||||
|
||||
# Initializes the object
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
def initialize(attributes = {})
|
||||
if (!attributes.is_a?(Hash))
|
||||
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::DogAllOf` initialize method"
|
||||
end
|
||||
|
||||
# check to see if the attribute exists and convert string to symbol for hash key
|
||||
attributes = attributes.each_with_object({}) { |(k, v), h|
|
||||
if (!self.class.attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::DogAllOf`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
||||
end
|
||||
h[k.to_sym] = v
|
||||
}
|
||||
|
||||
if attributes.key?(:'breed')
|
||||
self.breed = attributes[:'breed']
|
||||
end
|
||||
end
|
||||
|
||||
# Show invalid properties with the reasons. Usually used together with valid?
|
||||
# @return Array for valid properties with the reasons
|
||||
def list_invalid_properties
|
||||
invalid_properties = Array.new
|
||||
invalid_properties
|
||||
end
|
||||
|
||||
# Check to see if the all the properties in the model are valid
|
||||
# @return true if the model is valid
|
||||
def valid?
|
||||
true
|
||||
end
|
||||
|
||||
# Checks equality by comparing each attribute.
|
||||
# @param [Object] Object to be compared
|
||||
def ==(o)
|
||||
return true if self.equal?(o)
|
||||
self.class == o.class &&
|
||||
breed == o.breed
|
||||
end
|
||||
|
||||
# @see the `==` method
|
||||
# @param [Object] Object to be compared
|
||||
def eql?(o)
|
||||
self == o
|
||||
end
|
||||
|
||||
# Calculates hash code according to all attributes.
|
||||
# @return [Integer] Hash code
|
||||
def hash
|
||||
[breed].hash
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def self.build_from_hash(attributes)
|
||||
new.build_from_hash(attributes)
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def build_from_hash(attributes)
|
||||
return nil unless attributes.is_a?(Hash)
|
||||
self.class.openapi_types.each_pair do |key, type|
|
||||
if type =~ /\AArray<(.*)>/i
|
||||
# check to ensure the input is an array given that the attribute
|
||||
# is documented as an array but the input is not
|
||||
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
||||
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
||||
end
|
||||
elsif !attributes[self.class.attribute_map[key]].nil?
|
||||
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
||||
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
||||
end
|
||||
|
||||
self
|
||||
end
|
||||
|
||||
# Deserializes the data based on type
|
||||
# @param string type Data type
|
||||
# @param string value Value to be deserialized
|
||||
# @return [Object] Deserialized data
|
||||
def _deserialize(type, value)
|
||||
case type.to_sym
|
||||
when :DateTime
|
||||
DateTime.parse(value)
|
||||
when :Date
|
||||
Date.parse(value)
|
||||
when :String
|
||||
value.to_s
|
||||
when :Integer
|
||||
value.to_i
|
||||
when :Float
|
||||
value.to_f
|
||||
when :Boolean
|
||||
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
when :Object
|
||||
# generic object (usually a Hash), return directly
|
||||
value
|
||||
when /\AArray<(?<inner_type>.+)>\z/
|
||||
inner_type = Regexp.last_match[:inner_type]
|
||||
value.map { |v| _deserialize(inner_type, v) }
|
||||
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
||||
k_type = Regexp.last_match[:k_type]
|
||||
v_type = Regexp.last_match[:v_type]
|
||||
{}.tap do |hash|
|
||||
value.each do |k, v|
|
||||
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
||||
end
|
||||
end
|
||||
else # model
|
||||
Petstore.const_get(type).build_from_hash(value)
|
||||
end
|
||||
end
|
||||
|
||||
# Returns the string representation of the object
|
||||
# @return [String] String presentation of the object
|
||||
def to_s
|
||||
to_hash.to_s
|
||||
end
|
||||
|
||||
# to_body is an alias to to_hash (backward compatibility)
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_body
|
||||
to_hash
|
||||
end
|
||||
|
||||
# Returns the object in the form of hash
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_hash
|
||||
hash = {}
|
||||
self.class.attribute_map.each_pair do |attr, param|
|
||||
value = self.send(attr)
|
||||
next if value.nil?
|
||||
hash[param] = _to_hash(value)
|
||||
end
|
||||
hash
|
||||
end
|
||||
|
||||
# Outputs non-array value in the form of hash
|
||||
# For object, use to_hash. Otherwise, just return the value
|
||||
# @param [Object] value Any valid value
|
||||
# @return [Hash] Returns the value in the form of hash
|
||||
def _to_hash(value)
|
||||
if value.is_a?(Array)
|
||||
value.compact.map { |v| _to_hash(v) }
|
||||
elsif value.is_a?(Hash)
|
||||
{}.tap do |hash|
|
||||
value.each { |k, v| hash[k] = _to_hash(v) }
|
||||
end
|
||||
elsif value.respond_to? :to_hash
|
||||
value.to_hash
|
||||
else
|
||||
value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
241
samples/client/petstore/ruby/lib/petstore/models/enum_arrays.rb
Normal file
241
samples/client/petstore/ruby/lib/petstore/models/enum_arrays.rb
Normal file
@ -0,0 +1,241 @@
|
||||
=begin
|
||||
#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: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
Generated by: https://openapi-generator.tech
|
||||
OpenAPI Generator version: 4.2.0-SNAPSHOT
|
||||
|
||||
=end
|
||||
|
||||
require 'date'
|
||||
|
||||
module Petstore
|
||||
class EnumArrays
|
||||
attr_accessor :just_symbol
|
||||
|
||||
attr_accessor :array_enum
|
||||
|
||||
class EnumAttributeValidator
|
||||
attr_reader :datatype
|
||||
attr_reader :allowable_values
|
||||
|
||||
def initialize(datatype, allowable_values)
|
||||
@allowable_values = allowable_values.map do |value|
|
||||
case datatype.to_s
|
||||
when /Integer/i
|
||||
value.to_i
|
||||
when /Float/i
|
||||
value.to_f
|
||||
else
|
||||
value
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def valid?(value)
|
||||
!value || allowable_values.include?(value)
|
||||
end
|
||||
end
|
||||
|
||||
# Attribute mapping from ruby-style variable name to JSON key.
|
||||
def self.attribute_map
|
||||
{
|
||||
:'just_symbol' => :'just_symbol',
|
||||
:'array_enum' => :'array_enum'
|
||||
}
|
||||
end
|
||||
|
||||
# Attribute type mapping.
|
||||
def self.openapi_types
|
||||
{
|
||||
:'just_symbol' => :'String',
|
||||
:'array_enum' => :'Array<String>'
|
||||
}
|
||||
end
|
||||
|
||||
# Initializes the object
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
def initialize(attributes = {})
|
||||
if (!attributes.is_a?(Hash))
|
||||
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::EnumArrays` initialize method"
|
||||
end
|
||||
|
||||
# check to see if the attribute exists and convert string to symbol for hash key
|
||||
attributes = attributes.each_with_object({}) { |(k, v), h|
|
||||
if (!self.class.attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::EnumArrays`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
||||
end
|
||||
h[k.to_sym] = v
|
||||
}
|
||||
|
||||
if attributes.key?(:'just_symbol')
|
||||
self.just_symbol = attributes[:'just_symbol']
|
||||
end
|
||||
|
||||
if attributes.key?(:'array_enum')
|
||||
if (value = attributes[:'array_enum']).is_a?(Array)
|
||||
self.array_enum = value
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Show invalid properties with the reasons. Usually used together with valid?
|
||||
# @return Array for valid properties with the reasons
|
||||
def list_invalid_properties
|
||||
invalid_properties = Array.new
|
||||
invalid_properties
|
||||
end
|
||||
|
||||
# Check to see if the all the properties in the model are valid
|
||||
# @return true if the model is valid
|
||||
def valid?
|
||||
just_symbol_validator = EnumAttributeValidator.new('String', [">=", "$"])
|
||||
return false unless just_symbol_validator.valid?(@just_symbol)
|
||||
true
|
||||
end
|
||||
|
||||
# Custom attribute writer method checking allowed values (enum).
|
||||
# @param [Object] just_symbol Object to be assigned
|
||||
def just_symbol=(just_symbol)
|
||||
validator = EnumAttributeValidator.new('String', [">=", "$"])
|
||||
unless validator.valid?(just_symbol)
|
||||
fail ArgumentError, "invalid value for \"just_symbol\", must be one of #{validator.allowable_values}."
|
||||
end
|
||||
@just_symbol = just_symbol
|
||||
end
|
||||
|
||||
# Checks equality by comparing each attribute.
|
||||
# @param [Object] Object to be compared
|
||||
def ==(o)
|
||||
return true if self.equal?(o)
|
||||
self.class == o.class &&
|
||||
just_symbol == o.just_symbol &&
|
||||
array_enum == o.array_enum
|
||||
end
|
||||
|
||||
# @see the `==` method
|
||||
# @param [Object] Object to be compared
|
||||
def eql?(o)
|
||||
self == o
|
||||
end
|
||||
|
||||
# Calculates hash code according to all attributes.
|
||||
# @return [Integer] Hash code
|
||||
def hash
|
||||
[just_symbol, array_enum].hash
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def self.build_from_hash(attributes)
|
||||
new.build_from_hash(attributes)
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def build_from_hash(attributes)
|
||||
return nil unless attributes.is_a?(Hash)
|
||||
self.class.openapi_types.each_pair do |key, type|
|
||||
if type =~ /\AArray<(.*)>/i
|
||||
# check to ensure the input is an array given that the attribute
|
||||
# is documented as an array but the input is not
|
||||
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
||||
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
||||
end
|
||||
elsif !attributes[self.class.attribute_map[key]].nil?
|
||||
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
||||
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
||||
end
|
||||
|
||||
self
|
||||
end
|
||||
|
||||
# Deserializes the data based on type
|
||||
# @param string type Data type
|
||||
# @param string value Value to be deserialized
|
||||
# @return [Object] Deserialized data
|
||||
def _deserialize(type, value)
|
||||
case type.to_sym
|
||||
when :DateTime
|
||||
DateTime.parse(value)
|
||||
when :Date
|
||||
Date.parse(value)
|
||||
when :String
|
||||
value.to_s
|
||||
when :Integer
|
||||
value.to_i
|
||||
when :Float
|
||||
value.to_f
|
||||
when :Boolean
|
||||
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
when :Object
|
||||
# generic object (usually a Hash), return directly
|
||||
value
|
||||
when /\AArray<(?<inner_type>.+)>\z/
|
||||
inner_type = Regexp.last_match[:inner_type]
|
||||
value.map { |v| _deserialize(inner_type, v) }
|
||||
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
||||
k_type = Regexp.last_match[:k_type]
|
||||
v_type = Regexp.last_match[:v_type]
|
||||
{}.tap do |hash|
|
||||
value.each do |k, v|
|
||||
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
||||
end
|
||||
end
|
||||
else # model
|
||||
Petstore.const_get(type).build_from_hash(value)
|
||||
end
|
||||
end
|
||||
|
||||
# Returns the string representation of the object
|
||||
# @return [String] String presentation of the object
|
||||
def to_s
|
||||
to_hash.to_s
|
||||
end
|
||||
|
||||
# to_body is an alias to to_hash (backward compatibility)
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_body
|
||||
to_hash
|
||||
end
|
||||
|
||||
# Returns the object in the form of hash
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_hash
|
||||
hash = {}
|
||||
self.class.attribute_map.each_pair do |attr, param|
|
||||
value = self.send(attr)
|
||||
next if value.nil?
|
||||
hash[param] = _to_hash(value)
|
||||
end
|
||||
hash
|
||||
end
|
||||
|
||||
# Outputs non-array value in the form of hash
|
||||
# For object, use to_hash. Otherwise, just return the value
|
||||
# @param [Object] value Any valid value
|
||||
# @return [Hash] Returns the value in the form of hash
|
||||
def _to_hash(value)
|
||||
if value.is_a?(Array)
|
||||
value.compact.map { |v| _to_hash(v) }
|
||||
elsif value.is_a?(Hash)
|
||||
{}.tap do |hash|
|
||||
value.each { |k, v| hash[k] = _to_hash(v) }
|
||||
end
|
||||
elsif value.respond_to? :to_hash
|
||||
value.to_hash
|
||||
else
|
||||
value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,37 @@
|
||||
=begin
|
||||
#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: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
Generated by: https://openapi-generator.tech
|
||||
OpenAPI Generator version: 4.2.0-SNAPSHOT
|
||||
|
||||
=end
|
||||
|
||||
require 'date'
|
||||
|
||||
module Petstore
|
||||
class EnumClass
|
||||
ABC = "_abc".freeze
|
||||
EFG = "-efg".freeze
|
||||
XYZ = "(xyz)".freeze
|
||||
|
||||
# Builds the enum from string
|
||||
# @param [String] The enum value in the form of the string
|
||||
# @return [String] The enum value
|
||||
def self.build_from_hash(value)
|
||||
new.build_from_hash(value)
|
||||
end
|
||||
|
||||
# Builds the enum from string
|
||||
# @param [String] The enum value in the form of the string
|
||||
# @return [String] The enum value
|
||||
def build_from_hash(value)
|
||||
constantValues = EnumClass.constants.select { |c| EnumClass::const_get(c) == value }
|
||||
raise "Invalid ENUM value #{value} for class #EnumClass" if constantValues.empty?
|
||||
value
|
||||
end
|
||||
end
|
||||
end
|
307
samples/client/petstore/ruby/lib/petstore/models/enum_test.rb
Normal file
307
samples/client/petstore/ruby/lib/petstore/models/enum_test.rb
Normal file
@ -0,0 +1,307 @@
|
||||
=begin
|
||||
#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: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
Generated by: https://openapi-generator.tech
|
||||
OpenAPI Generator version: 4.2.0-SNAPSHOT
|
||||
|
||||
=end
|
||||
|
||||
require 'date'
|
||||
|
||||
module Petstore
|
||||
class EnumTest
|
||||
attr_accessor :enum_string
|
||||
|
||||
attr_accessor :enum_string_required
|
||||
|
||||
attr_accessor :enum_integer
|
||||
|
||||
attr_accessor :enum_number
|
||||
|
||||
attr_accessor :outer_enum
|
||||
|
||||
class EnumAttributeValidator
|
||||
attr_reader :datatype
|
||||
attr_reader :allowable_values
|
||||
|
||||
def initialize(datatype, allowable_values)
|
||||
@allowable_values = allowable_values.map do |value|
|
||||
case datatype.to_s
|
||||
when /Integer/i
|
||||
value.to_i
|
||||
when /Float/i
|
||||
value.to_f
|
||||
else
|
||||
value
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def valid?(value)
|
||||
!value || allowable_values.include?(value)
|
||||
end
|
||||
end
|
||||
|
||||
# Attribute mapping from ruby-style variable name to JSON key.
|
||||
def self.attribute_map
|
||||
{
|
||||
:'enum_string' => :'enum_string',
|
||||
:'enum_string_required' => :'enum_string_required',
|
||||
:'enum_integer' => :'enum_integer',
|
||||
:'enum_number' => :'enum_number',
|
||||
:'outer_enum' => :'outerEnum'
|
||||
}
|
||||
end
|
||||
|
||||
# Attribute type mapping.
|
||||
def self.openapi_types
|
||||
{
|
||||
:'enum_string' => :'String',
|
||||
:'enum_string_required' => :'String',
|
||||
:'enum_integer' => :'Integer',
|
||||
:'enum_number' => :'Float',
|
||||
:'outer_enum' => :'OuterEnum'
|
||||
}
|
||||
end
|
||||
|
||||
# Initializes the object
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
def initialize(attributes = {})
|
||||
if (!attributes.is_a?(Hash))
|
||||
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::EnumTest` initialize method"
|
||||
end
|
||||
|
||||
# check to see if the attribute exists and convert string to symbol for hash key
|
||||
attributes = attributes.each_with_object({}) { |(k, v), h|
|
||||
if (!self.class.attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::EnumTest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
||||
end
|
||||
h[k.to_sym] = v
|
||||
}
|
||||
|
||||
if attributes.key?(:'enum_string')
|
||||
self.enum_string = attributes[:'enum_string']
|
||||
end
|
||||
|
||||
if attributes.key?(:'enum_string_required')
|
||||
self.enum_string_required = attributes[:'enum_string_required']
|
||||
end
|
||||
|
||||
if attributes.key?(:'enum_integer')
|
||||
self.enum_integer = attributes[:'enum_integer']
|
||||
end
|
||||
|
||||
if attributes.key?(:'enum_number')
|
||||
self.enum_number = attributes[:'enum_number']
|
||||
end
|
||||
|
||||
if attributes.key?(:'outer_enum')
|
||||
self.outer_enum = attributes[:'outer_enum']
|
||||
end
|
||||
end
|
||||
|
||||
# Show invalid properties with the reasons. Usually used together with valid?
|
||||
# @return Array for valid properties with the reasons
|
||||
def list_invalid_properties
|
||||
invalid_properties = Array.new
|
||||
if @enum_string_required.nil?
|
||||
invalid_properties.push('invalid value for "enum_string_required", enum_string_required cannot be nil.')
|
||||
end
|
||||
|
||||
invalid_properties
|
||||
end
|
||||
|
||||
# Check to see if the all the properties in the model are valid
|
||||
# @return true if the model is valid
|
||||
def valid?
|
||||
enum_string_validator = EnumAttributeValidator.new('String', ["UPPER", "lower", ""])
|
||||
return false unless enum_string_validator.valid?(@enum_string)
|
||||
return false if @enum_string_required.nil?
|
||||
enum_string_required_validator = EnumAttributeValidator.new('String', ["UPPER", "lower", ""])
|
||||
return false unless enum_string_required_validator.valid?(@enum_string_required)
|
||||
enum_integer_validator = EnumAttributeValidator.new('Integer', [1, -1])
|
||||
return false unless enum_integer_validator.valid?(@enum_integer)
|
||||
enum_number_validator = EnumAttributeValidator.new('Float', [1.1, -1.2])
|
||||
return false unless enum_number_validator.valid?(@enum_number)
|
||||
true
|
||||
end
|
||||
|
||||
# Custom attribute writer method checking allowed values (enum).
|
||||
# @param [Object] enum_string Object to be assigned
|
||||
def enum_string=(enum_string)
|
||||
validator = EnumAttributeValidator.new('String', ["UPPER", "lower", ""])
|
||||
unless validator.valid?(enum_string)
|
||||
fail ArgumentError, "invalid value for \"enum_string\", must be one of #{validator.allowable_values}."
|
||||
end
|
||||
@enum_string = enum_string
|
||||
end
|
||||
|
||||
# Custom attribute writer method checking allowed values (enum).
|
||||
# @param [Object] enum_string_required Object to be assigned
|
||||
def enum_string_required=(enum_string_required)
|
||||
validator = EnumAttributeValidator.new('String', ["UPPER", "lower", ""])
|
||||
unless validator.valid?(enum_string_required)
|
||||
fail ArgumentError, "invalid value for \"enum_string_required\", must be one of #{validator.allowable_values}."
|
||||
end
|
||||
@enum_string_required = enum_string_required
|
||||
end
|
||||
|
||||
# Custom attribute writer method checking allowed values (enum).
|
||||
# @param [Object] enum_integer Object to be assigned
|
||||
def enum_integer=(enum_integer)
|
||||
validator = EnumAttributeValidator.new('Integer', [1, -1])
|
||||
unless validator.valid?(enum_integer)
|
||||
fail ArgumentError, "invalid value for \"enum_integer\", must be one of #{validator.allowable_values}."
|
||||
end
|
||||
@enum_integer = enum_integer
|
||||
end
|
||||
|
||||
# Custom attribute writer method checking allowed values (enum).
|
||||
# @param [Object] enum_number Object to be assigned
|
||||
def enum_number=(enum_number)
|
||||
validator = EnumAttributeValidator.new('Float', [1.1, -1.2])
|
||||
unless validator.valid?(enum_number)
|
||||
fail ArgumentError, "invalid value for \"enum_number\", must be one of #{validator.allowable_values}."
|
||||
end
|
||||
@enum_number = enum_number
|
||||
end
|
||||
|
||||
# Checks equality by comparing each attribute.
|
||||
# @param [Object] Object to be compared
|
||||
def ==(o)
|
||||
return true if self.equal?(o)
|
||||
self.class == o.class &&
|
||||
enum_string == o.enum_string &&
|
||||
enum_string_required == o.enum_string_required &&
|
||||
enum_integer == o.enum_integer &&
|
||||
enum_number == o.enum_number &&
|
||||
outer_enum == o.outer_enum
|
||||
end
|
||||
|
||||
# @see the `==` method
|
||||
# @param [Object] Object to be compared
|
||||
def eql?(o)
|
||||
self == o
|
||||
end
|
||||
|
||||
# Calculates hash code according to all attributes.
|
||||
# @return [Integer] Hash code
|
||||
def hash
|
||||
[enum_string, enum_string_required, enum_integer, enum_number, outer_enum].hash
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def self.build_from_hash(attributes)
|
||||
new.build_from_hash(attributes)
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def build_from_hash(attributes)
|
||||
return nil unless attributes.is_a?(Hash)
|
||||
self.class.openapi_types.each_pair do |key, type|
|
||||
if type =~ /\AArray<(.*)>/i
|
||||
# check to ensure the input is an array given that the attribute
|
||||
# is documented as an array but the input is not
|
||||
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
||||
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
||||
end
|
||||
elsif !attributes[self.class.attribute_map[key]].nil?
|
||||
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
||||
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
||||
end
|
||||
|
||||
self
|
||||
end
|
||||
|
||||
# Deserializes the data based on type
|
||||
# @param string type Data type
|
||||
# @param string value Value to be deserialized
|
||||
# @return [Object] Deserialized data
|
||||
def _deserialize(type, value)
|
||||
case type.to_sym
|
||||
when :DateTime
|
||||
DateTime.parse(value)
|
||||
when :Date
|
||||
Date.parse(value)
|
||||
when :String
|
||||
value.to_s
|
||||
when :Integer
|
||||
value.to_i
|
||||
when :Float
|
||||
value.to_f
|
||||
when :Boolean
|
||||
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
when :Object
|
||||
# generic object (usually a Hash), return directly
|
||||
value
|
||||
when /\AArray<(?<inner_type>.+)>\z/
|
||||
inner_type = Regexp.last_match[:inner_type]
|
||||
value.map { |v| _deserialize(inner_type, v) }
|
||||
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
||||
k_type = Regexp.last_match[:k_type]
|
||||
v_type = Regexp.last_match[:v_type]
|
||||
{}.tap do |hash|
|
||||
value.each do |k, v|
|
||||
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
||||
end
|
||||
end
|
||||
else # model
|
||||
Petstore.const_get(type).build_from_hash(value)
|
||||
end
|
||||
end
|
||||
|
||||
# Returns the string representation of the object
|
||||
# @return [String] String presentation of the object
|
||||
def to_s
|
||||
to_hash.to_s
|
||||
end
|
||||
|
||||
# to_body is an alias to to_hash (backward compatibility)
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_body
|
||||
to_hash
|
||||
end
|
||||
|
||||
# Returns the object in the form of hash
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_hash
|
||||
hash = {}
|
||||
self.class.attribute_map.each_pair do |attr, param|
|
||||
value = self.send(attr)
|
||||
next if value.nil?
|
||||
hash[param] = _to_hash(value)
|
||||
end
|
||||
hash
|
||||
end
|
||||
|
||||
# Outputs non-array value in the form of hash
|
||||
# For object, use to_hash. Otherwise, just return the value
|
||||
# @param [Object] value Any valid value
|
||||
# @return [Hash] Returns the value in the form of hash
|
||||
def _to_hash(value)
|
||||
if value.is_a?(Array)
|
||||
value.compact.map { |v| _to_hash(v) }
|
||||
elsif value.is_a?(Hash)
|
||||
{}.tap do |hash|
|
||||
value.each { |k, v| hash[k] = _to_hash(v) }
|
||||
end
|
||||
elsif value.respond_to? :to_hash
|
||||
value.to_hash
|
||||
else
|
||||
value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
198
samples/client/petstore/ruby/lib/petstore/models/file.rb
Normal file
198
samples/client/petstore/ruby/lib/petstore/models/file.rb
Normal file
@ -0,0 +1,198 @@
|
||||
=begin
|
||||
#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: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
Generated by: https://openapi-generator.tech
|
||||
OpenAPI Generator version: 4.2.0-SNAPSHOT
|
||||
|
||||
=end
|
||||
|
||||
require 'date'
|
||||
|
||||
module Petstore
|
||||
# Must be named `File` for test.
|
||||
class File
|
||||
# Test capitalization
|
||||
attr_accessor :source_uri
|
||||
|
||||
# Attribute mapping from ruby-style variable name to JSON key.
|
||||
def self.attribute_map
|
||||
{
|
||||
:'source_uri' => :'sourceURI'
|
||||
}
|
||||
end
|
||||
|
||||
# Attribute type mapping.
|
||||
def self.openapi_types
|
||||
{
|
||||
:'source_uri' => :'String'
|
||||
}
|
||||
end
|
||||
|
||||
# Initializes the object
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
def initialize(attributes = {})
|
||||
if (!attributes.is_a?(Hash))
|
||||
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::File` initialize method"
|
||||
end
|
||||
|
||||
# check to see if the attribute exists and convert string to symbol for hash key
|
||||
attributes = attributes.each_with_object({}) { |(k, v), h|
|
||||
if (!self.class.attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::File`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
||||
end
|
||||
h[k.to_sym] = v
|
||||
}
|
||||
|
||||
if attributes.key?(:'source_uri')
|
||||
self.source_uri = attributes[:'source_uri']
|
||||
end
|
||||
end
|
||||
|
||||
# Show invalid properties with the reasons. Usually used together with valid?
|
||||
# @return Array for valid properties with the reasons
|
||||
def list_invalid_properties
|
||||
invalid_properties = Array.new
|
||||
invalid_properties
|
||||
end
|
||||
|
||||
# Check to see if the all the properties in the model are valid
|
||||
# @return true if the model is valid
|
||||
def valid?
|
||||
true
|
||||
end
|
||||
|
||||
# Checks equality by comparing each attribute.
|
||||
# @param [Object] Object to be compared
|
||||
def ==(o)
|
||||
return true if self.equal?(o)
|
||||
self.class == o.class &&
|
||||
source_uri == o.source_uri
|
||||
end
|
||||
|
||||
# @see the `==` method
|
||||
# @param [Object] Object to be compared
|
||||
def eql?(o)
|
||||
self == o
|
||||
end
|
||||
|
||||
# Calculates hash code according to all attributes.
|
||||
# @return [Integer] Hash code
|
||||
def hash
|
||||
[source_uri].hash
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def self.build_from_hash(attributes)
|
||||
new.build_from_hash(attributes)
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def build_from_hash(attributes)
|
||||
return nil unless attributes.is_a?(Hash)
|
||||
self.class.openapi_types.each_pair do |key, type|
|
||||
if type =~ /\AArray<(.*)>/i
|
||||
# check to ensure the input is an array given that the attribute
|
||||
# is documented as an array but the input is not
|
||||
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
||||
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
||||
end
|
||||
elsif !attributes[self.class.attribute_map[key]].nil?
|
||||
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
||||
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
||||
end
|
||||
|
||||
self
|
||||
end
|
||||
|
||||
# Deserializes the data based on type
|
||||
# @param string type Data type
|
||||
# @param string value Value to be deserialized
|
||||
# @return [Object] Deserialized data
|
||||
def _deserialize(type, value)
|
||||
case type.to_sym
|
||||
when :DateTime
|
||||
DateTime.parse(value)
|
||||
when :Date
|
||||
Date.parse(value)
|
||||
when :String
|
||||
value.to_s
|
||||
when :Integer
|
||||
value.to_i
|
||||
when :Float
|
||||
value.to_f
|
||||
when :Boolean
|
||||
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
when :Object
|
||||
# generic object (usually a Hash), return directly
|
||||
value
|
||||
when /\AArray<(?<inner_type>.+)>\z/
|
||||
inner_type = Regexp.last_match[:inner_type]
|
||||
value.map { |v| _deserialize(inner_type, v) }
|
||||
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
||||
k_type = Regexp.last_match[:k_type]
|
||||
v_type = Regexp.last_match[:v_type]
|
||||
{}.tap do |hash|
|
||||
value.each do |k, v|
|
||||
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
||||
end
|
||||
end
|
||||
else # model
|
||||
Petstore.const_get(type).build_from_hash(value)
|
||||
end
|
||||
end
|
||||
|
||||
# Returns the string representation of the object
|
||||
# @return [String] String presentation of the object
|
||||
def to_s
|
||||
to_hash.to_s
|
||||
end
|
||||
|
||||
# to_body is an alias to to_hash (backward compatibility)
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_body
|
||||
to_hash
|
||||
end
|
||||
|
||||
# Returns the object in the form of hash
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_hash
|
||||
hash = {}
|
||||
self.class.attribute_map.each_pair do |attr, param|
|
||||
value = self.send(attr)
|
||||
next if value.nil?
|
||||
hash[param] = _to_hash(value)
|
||||
end
|
||||
hash
|
||||
end
|
||||
|
||||
# Outputs non-array value in the form of hash
|
||||
# For object, use to_hash. Otherwise, just return the value
|
||||
# @param [Object] value Any valid value
|
||||
# @return [Hash] Returns the value in the form of hash
|
||||
def _to_hash(value)
|
||||
if value.is_a?(Array)
|
||||
value.compact.map { |v| _to_hash(v) }
|
||||
elsif value.is_a?(Hash)
|
||||
{}.tap do |hash|
|
||||
value.each { |k, v| hash[k] = _to_hash(v) }
|
||||
end
|
||||
elsif value.respond_to? :to_hash
|
||||
value.to_hash
|
||||
else
|
||||
value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,207 @@
|
||||
=begin
|
||||
#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: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
Generated by: https://openapi-generator.tech
|
||||
OpenAPI Generator version: 4.2.0-SNAPSHOT
|
||||
|
||||
=end
|
||||
|
||||
require 'date'
|
||||
|
||||
module Petstore
|
||||
class FileSchemaTestClass
|
||||
attr_accessor :file
|
||||
|
||||
attr_accessor :files
|
||||
|
||||
# Attribute mapping from ruby-style variable name to JSON key.
|
||||
def self.attribute_map
|
||||
{
|
||||
:'file' => :'file',
|
||||
:'files' => :'files'
|
||||
}
|
||||
end
|
||||
|
||||
# Attribute type mapping.
|
||||
def self.openapi_types
|
||||
{
|
||||
:'file' => :'File',
|
||||
:'files' => :'Array<File>'
|
||||
}
|
||||
end
|
||||
|
||||
# Initializes the object
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
def initialize(attributes = {})
|
||||
if (!attributes.is_a?(Hash))
|
||||
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::FileSchemaTestClass` initialize method"
|
||||
end
|
||||
|
||||
# check to see if the attribute exists and convert string to symbol for hash key
|
||||
attributes = attributes.each_with_object({}) { |(k, v), h|
|
||||
if (!self.class.attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::FileSchemaTestClass`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
||||
end
|
||||
h[k.to_sym] = v
|
||||
}
|
||||
|
||||
if attributes.key?(:'file')
|
||||
self.file = attributes[:'file']
|
||||
end
|
||||
|
||||
if attributes.key?(:'files')
|
||||
if (value = attributes[:'files']).is_a?(Array)
|
||||
self.files = value
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Show invalid properties with the reasons. Usually used together with valid?
|
||||
# @return Array for valid properties with the reasons
|
||||
def list_invalid_properties
|
||||
invalid_properties = Array.new
|
||||
invalid_properties
|
||||
end
|
||||
|
||||
# Check to see if the all the properties in the model are valid
|
||||
# @return true if the model is valid
|
||||
def valid?
|
||||
true
|
||||
end
|
||||
|
||||
# Checks equality by comparing each attribute.
|
||||
# @param [Object] Object to be compared
|
||||
def ==(o)
|
||||
return true if self.equal?(o)
|
||||
self.class == o.class &&
|
||||
file == o.file &&
|
||||
files == o.files
|
||||
end
|
||||
|
||||
# @see the `==` method
|
||||
# @param [Object] Object to be compared
|
||||
def eql?(o)
|
||||
self == o
|
||||
end
|
||||
|
||||
# Calculates hash code according to all attributes.
|
||||
# @return [Integer] Hash code
|
||||
def hash
|
||||
[file, files].hash
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def self.build_from_hash(attributes)
|
||||
new.build_from_hash(attributes)
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def build_from_hash(attributes)
|
||||
return nil unless attributes.is_a?(Hash)
|
||||
self.class.openapi_types.each_pair do |key, type|
|
||||
if type =~ /\AArray<(.*)>/i
|
||||
# check to ensure the input is an array given that the attribute
|
||||
# is documented as an array but the input is not
|
||||
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
||||
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
||||
end
|
||||
elsif !attributes[self.class.attribute_map[key]].nil?
|
||||
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
||||
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
||||
end
|
||||
|
||||
self
|
||||
end
|
||||
|
||||
# Deserializes the data based on type
|
||||
# @param string type Data type
|
||||
# @param string value Value to be deserialized
|
||||
# @return [Object] Deserialized data
|
||||
def _deserialize(type, value)
|
||||
case type.to_sym
|
||||
when :DateTime
|
||||
DateTime.parse(value)
|
||||
when :Date
|
||||
Date.parse(value)
|
||||
when :String
|
||||
value.to_s
|
||||
when :Integer
|
||||
value.to_i
|
||||
when :Float
|
||||
value.to_f
|
||||
when :Boolean
|
||||
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
when :Object
|
||||
# generic object (usually a Hash), return directly
|
||||
value
|
||||
when /\AArray<(?<inner_type>.+)>\z/
|
||||
inner_type = Regexp.last_match[:inner_type]
|
||||
value.map { |v| _deserialize(inner_type, v) }
|
||||
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
||||
k_type = Regexp.last_match[:k_type]
|
||||
v_type = Regexp.last_match[:v_type]
|
||||
{}.tap do |hash|
|
||||
value.each do |k, v|
|
||||
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
||||
end
|
||||
end
|
||||
else # model
|
||||
Petstore.const_get(type).build_from_hash(value)
|
||||
end
|
||||
end
|
||||
|
||||
# Returns the string representation of the object
|
||||
# @return [String] String presentation of the object
|
||||
def to_s
|
||||
to_hash.to_s
|
||||
end
|
||||
|
||||
# to_body is an alias to to_hash (backward compatibility)
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_body
|
||||
to_hash
|
||||
end
|
||||
|
||||
# Returns the object in the form of hash
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_hash
|
||||
hash = {}
|
||||
self.class.attribute_map.each_pair do |attr, param|
|
||||
value = self.send(attr)
|
||||
next if value.nil?
|
||||
hash[param] = _to_hash(value)
|
||||
end
|
||||
hash
|
||||
end
|
||||
|
||||
# Outputs non-array value in the form of hash
|
||||
# For object, use to_hash. Otherwise, just return the value
|
||||
# @param [Object] value Any valid value
|
||||
# @return [Hash] Returns the value in the form of hash
|
||||
def _to_hash(value)
|
||||
if value.is_a?(Array)
|
||||
value.compact.map { |v| _to_hash(v) }
|
||||
elsif value.is_a?(Hash)
|
||||
{}.tap do |hash|
|
||||
value.each { |k, v| hash[k] = _to_hash(v) }
|
||||
end
|
||||
elsif value.respond_to? :to_hash
|
||||
value.to_hash
|
||||
else
|
||||
value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
523
samples/client/petstore/ruby/lib/petstore/models/format_test.rb
Normal file
523
samples/client/petstore/ruby/lib/petstore/models/format_test.rb
Normal file
@ -0,0 +1,523 @@
|
||||
=begin
|
||||
#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: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
Generated by: https://openapi-generator.tech
|
||||
OpenAPI Generator version: 4.2.0-SNAPSHOT
|
||||
|
||||
=end
|
||||
|
||||
require 'date'
|
||||
|
||||
module Petstore
|
||||
class FormatTest
|
||||
attr_accessor :integer
|
||||
|
||||
attr_accessor :int32
|
||||
|
||||
attr_accessor :int64
|
||||
|
||||
attr_accessor :number
|
||||
|
||||
attr_accessor :float
|
||||
|
||||
attr_accessor :double
|
||||
|
||||
attr_accessor :string
|
||||
|
||||
attr_accessor :byte
|
||||
|
||||
attr_accessor :binary
|
||||
|
||||
attr_accessor :date
|
||||
|
||||
attr_accessor :date_time
|
||||
|
||||
attr_accessor :uuid
|
||||
|
||||
attr_accessor :password
|
||||
|
||||
attr_accessor :big_decimal
|
||||
|
||||
# Attribute mapping from ruby-style variable name to JSON key.
|
||||
def self.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',
|
||||
:'big_decimal' => :'BigDecimal'
|
||||
}
|
||||
end
|
||||
|
||||
# Attribute type mapping.
|
||||
def self.openapi_types
|
||||
{
|
||||
:'integer' => :'Integer',
|
||||
:'int32' => :'Integer',
|
||||
:'int64' => :'Integer',
|
||||
:'number' => :'Float',
|
||||
:'float' => :'Float',
|
||||
:'double' => :'Float',
|
||||
:'string' => :'String',
|
||||
:'byte' => :'String',
|
||||
:'binary' => :'File',
|
||||
:'date' => :'Date',
|
||||
:'date_time' => :'DateTime',
|
||||
:'uuid' => :'String',
|
||||
:'password' => :'String',
|
||||
:'big_decimal' => :'BigDecimal'
|
||||
}
|
||||
end
|
||||
|
||||
# Initializes the object
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
def initialize(attributes = {})
|
||||
if (!attributes.is_a?(Hash))
|
||||
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::FormatTest` initialize method"
|
||||
end
|
||||
|
||||
# check to see if the attribute exists and convert string to symbol for hash key
|
||||
attributes = attributes.each_with_object({}) { |(k, v), h|
|
||||
if (!self.class.attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::FormatTest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
||||
end
|
||||
h[k.to_sym] = v
|
||||
}
|
||||
|
||||
if attributes.key?(:'integer')
|
||||
self.integer = attributes[:'integer']
|
||||
end
|
||||
|
||||
if attributes.key?(:'int32')
|
||||
self.int32 = attributes[:'int32']
|
||||
end
|
||||
|
||||
if attributes.key?(:'int64')
|
||||
self.int64 = attributes[:'int64']
|
||||
end
|
||||
|
||||
if attributes.key?(:'number')
|
||||
self.number = attributes[:'number']
|
||||
end
|
||||
|
||||
if attributes.key?(:'float')
|
||||
self.float = attributes[:'float']
|
||||
end
|
||||
|
||||
if attributes.key?(:'double')
|
||||
self.double = attributes[:'double']
|
||||
end
|
||||
|
||||
if attributes.key?(:'string')
|
||||
self.string = attributes[:'string']
|
||||
end
|
||||
|
||||
if attributes.key?(:'byte')
|
||||
self.byte = attributes[:'byte']
|
||||
end
|
||||
|
||||
if attributes.key?(:'binary')
|
||||
self.binary = attributes[:'binary']
|
||||
end
|
||||
|
||||
if attributes.key?(:'date')
|
||||
self.date = attributes[:'date']
|
||||
end
|
||||
|
||||
if attributes.key?(:'date_time')
|
||||
self.date_time = attributes[:'date_time']
|
||||
end
|
||||
|
||||
if attributes.key?(:'uuid')
|
||||
self.uuid = attributes[:'uuid']
|
||||
end
|
||||
|
||||
if attributes.key?(:'password')
|
||||
self.password = attributes[:'password']
|
||||
end
|
||||
|
||||
if attributes.key?(:'big_decimal')
|
||||
self.big_decimal = attributes[:'big_decimal']
|
||||
end
|
||||
end
|
||||
|
||||
# Show invalid properties with the reasons. Usually used together with valid?
|
||||
# @return Array for valid properties with the reasons
|
||||
def list_invalid_properties
|
||||
invalid_properties = Array.new
|
||||
if !@integer.nil? && @integer > 100
|
||||
invalid_properties.push('invalid value for "integer", must be smaller than or equal to 100.')
|
||||
end
|
||||
|
||||
if !@integer.nil? && @integer < 10
|
||||
invalid_properties.push('invalid value for "integer", must be greater than or equal to 10.')
|
||||
end
|
||||
|
||||
if !@int32.nil? && @int32 > 200
|
||||
invalid_properties.push('invalid value for "int32", must be smaller than or equal to 200.')
|
||||
end
|
||||
|
||||
if !@int32.nil? && @int32 < 20
|
||||
invalid_properties.push('invalid value for "int32", must be greater than or equal to 20.')
|
||||
end
|
||||
|
||||
if @number.nil?
|
||||
invalid_properties.push('invalid value for "number", number cannot be nil.')
|
||||
end
|
||||
|
||||
if @number > 543.2
|
||||
invalid_properties.push('invalid value for "number", must be smaller than or equal to 543.2.')
|
||||
end
|
||||
|
||||
if @number < 32.1
|
||||
invalid_properties.push('invalid value for "number", must be greater than or equal to 32.1.')
|
||||
end
|
||||
|
||||
if !@float.nil? && @float > 987.6
|
||||
invalid_properties.push('invalid value for "float", must be smaller than or equal to 987.6.')
|
||||
end
|
||||
|
||||
if !@float.nil? && @float < 54.3
|
||||
invalid_properties.push('invalid value for "float", must be greater than or equal to 54.3.')
|
||||
end
|
||||
|
||||
if !@double.nil? && @double > 123.4
|
||||
invalid_properties.push('invalid value for "double", must be smaller than or equal to 123.4.')
|
||||
end
|
||||
|
||||
if !@double.nil? && @double < 67.8
|
||||
invalid_properties.push('invalid value for "double", must be greater than or equal to 67.8.')
|
||||
end
|
||||
|
||||
pattern = Regexp.new(/[a-z]/i)
|
||||
if !@string.nil? && @string !~ pattern
|
||||
invalid_properties.push("invalid value for \"string\", must conform to the pattern #{pattern}.")
|
||||
end
|
||||
|
||||
if @byte.nil?
|
||||
invalid_properties.push('invalid value for "byte", byte cannot be nil.')
|
||||
end
|
||||
|
||||
pattern = Regexp.new(/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/)
|
||||
if @byte !~ pattern
|
||||
invalid_properties.push("invalid value for \"byte\", must conform to the pattern #{pattern}.")
|
||||
end
|
||||
|
||||
if @date.nil?
|
||||
invalid_properties.push('invalid value for "date", date cannot be nil.')
|
||||
end
|
||||
|
||||
if @password.nil?
|
||||
invalid_properties.push('invalid value for "password", password cannot be nil.')
|
||||
end
|
||||
|
||||
if @password.to_s.length > 64
|
||||
invalid_properties.push('invalid value for "password", the character length must be smaller than or equal to 64.')
|
||||
end
|
||||
|
||||
if @password.to_s.length < 10
|
||||
invalid_properties.push('invalid value for "password", the character length must be great than or equal to 10.')
|
||||
end
|
||||
|
||||
invalid_properties
|
||||
end
|
||||
|
||||
# Check to see if the all the properties in the model are valid
|
||||
# @return true if the model is valid
|
||||
def valid?
|
||||
return false if !@integer.nil? && @integer > 100
|
||||
return false if !@integer.nil? && @integer < 10
|
||||
return false if !@int32.nil? && @int32 > 200
|
||||
return false if !@int32.nil? && @int32 < 20
|
||||
return false if @number.nil?
|
||||
return false if @number > 543.2
|
||||
return false if @number < 32.1
|
||||
return false if !@float.nil? && @float > 987.6
|
||||
return false if !@float.nil? && @float < 54.3
|
||||
return false if !@double.nil? && @double > 123.4
|
||||
return false if !@double.nil? && @double < 67.8
|
||||
return false if !@string.nil? && @string !~ Regexp.new(/[a-z]/i)
|
||||
return false if @byte.nil?
|
||||
return false if @byte !~ Regexp.new(/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/)
|
||||
return false if @date.nil?
|
||||
return false if @password.nil?
|
||||
return false if @password.to_s.length > 64
|
||||
return false if @password.to_s.length < 10
|
||||
true
|
||||
end
|
||||
|
||||
# Custom attribute writer method with validation
|
||||
# @param [Object] integer Value to be assigned
|
||||
def integer=(integer)
|
||||
if !integer.nil? && integer > 100
|
||||
fail ArgumentError, 'invalid value for "integer", must be smaller than or equal to 100.'
|
||||
end
|
||||
|
||||
if !integer.nil? && integer < 10
|
||||
fail ArgumentError, 'invalid value for "integer", must be greater than or equal to 10.'
|
||||
end
|
||||
|
||||
@integer = integer
|
||||
end
|
||||
|
||||
# Custom attribute writer method with validation
|
||||
# @param [Object] int32 Value to be assigned
|
||||
def int32=(int32)
|
||||
if !int32.nil? && int32 > 200
|
||||
fail ArgumentError, 'invalid value for "int32", must be smaller than or equal to 200.'
|
||||
end
|
||||
|
||||
if !int32.nil? && int32 < 20
|
||||
fail ArgumentError, 'invalid value for "int32", must be greater than or equal to 20.'
|
||||
end
|
||||
|
||||
@int32 = int32
|
||||
end
|
||||
|
||||
# Custom attribute writer method with validation
|
||||
# @param [Object] number Value to be assigned
|
||||
def number=(number)
|
||||
if number.nil?
|
||||
fail ArgumentError, 'number cannot be nil'
|
||||
end
|
||||
|
||||
if number > 543.2
|
||||
fail ArgumentError, 'invalid value for "number", must be smaller than or equal to 543.2.'
|
||||
end
|
||||
|
||||
if number < 32.1
|
||||
fail ArgumentError, 'invalid value for "number", must be greater than or equal to 32.1.'
|
||||
end
|
||||
|
||||
@number = number
|
||||
end
|
||||
|
||||
# Custom attribute writer method with validation
|
||||
# @param [Object] float Value to be assigned
|
||||
def float=(float)
|
||||
if !float.nil? && float > 987.6
|
||||
fail ArgumentError, 'invalid value for "float", must be smaller than or equal to 987.6.'
|
||||
end
|
||||
|
||||
if !float.nil? && float < 54.3
|
||||
fail ArgumentError, 'invalid value for "float", must be greater than or equal to 54.3.'
|
||||
end
|
||||
|
||||
@float = float
|
||||
end
|
||||
|
||||
# Custom attribute writer method with validation
|
||||
# @param [Object] double Value to be assigned
|
||||
def double=(double)
|
||||
if !double.nil? && double > 123.4
|
||||
fail ArgumentError, 'invalid value for "double", must be smaller than or equal to 123.4.'
|
||||
end
|
||||
|
||||
if !double.nil? && double < 67.8
|
||||
fail ArgumentError, 'invalid value for "double", must be greater than or equal to 67.8.'
|
||||
end
|
||||
|
||||
@double = double
|
||||
end
|
||||
|
||||
# Custom attribute writer method with validation
|
||||
# @param [Object] string Value to be assigned
|
||||
def string=(string)
|
||||
pattern = Regexp.new(/[a-z]/i)
|
||||
if !string.nil? && string !~ pattern
|
||||
fail ArgumentError, "invalid value for \"string\", must conform to the pattern #{pattern}."
|
||||
end
|
||||
|
||||
@string = string
|
||||
end
|
||||
|
||||
# Custom attribute writer method with validation
|
||||
# @param [Object] byte Value to be assigned
|
||||
def byte=(byte)
|
||||
if byte.nil?
|
||||
fail ArgumentError, 'byte cannot be nil'
|
||||
end
|
||||
|
||||
pattern = Regexp.new(/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/)
|
||||
if byte !~ pattern
|
||||
fail ArgumentError, "invalid value for \"byte\", must conform to the pattern #{pattern}."
|
||||
end
|
||||
|
||||
@byte = byte
|
||||
end
|
||||
|
||||
# Custom attribute writer method with validation
|
||||
# @param [Object] password Value to be assigned
|
||||
def password=(password)
|
||||
if password.nil?
|
||||
fail ArgumentError, 'password cannot be nil'
|
||||
end
|
||||
|
||||
if password.to_s.length > 64
|
||||
fail ArgumentError, 'invalid value for "password", the character length must be smaller than or equal to 64.'
|
||||
end
|
||||
|
||||
if password.to_s.length < 10
|
||||
fail ArgumentError, 'invalid value for "password", the character length must be great than or equal to 10.'
|
||||
end
|
||||
|
||||
@password = password
|
||||
end
|
||||
|
||||
# Checks equality by comparing each attribute.
|
||||
# @param [Object] Object to be compared
|
||||
def ==(o)
|
||||
return true if self.equal?(o)
|
||||
self.class == o.class &&
|
||||
integer == o.integer &&
|
||||
int32 == o.int32 &&
|
||||
int64 == o.int64 &&
|
||||
number == o.number &&
|
||||
float == o.float &&
|
||||
double == o.double &&
|
||||
string == o.string &&
|
||||
byte == o.byte &&
|
||||
binary == o.binary &&
|
||||
date == o.date &&
|
||||
date_time == o.date_time &&
|
||||
uuid == o.uuid &&
|
||||
password == o.password &&
|
||||
big_decimal == o.big_decimal
|
||||
end
|
||||
|
||||
# @see the `==` method
|
||||
# @param [Object] Object to be compared
|
||||
def eql?(o)
|
||||
self == o
|
||||
end
|
||||
|
||||
# Calculates hash code according to all attributes.
|
||||
# @return [Integer] Hash code
|
||||
def hash
|
||||
[integer, int32, int64, number, float, double, string, byte, binary, date, date_time, uuid, password, big_decimal].hash
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def self.build_from_hash(attributes)
|
||||
new.build_from_hash(attributes)
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def build_from_hash(attributes)
|
||||
return nil unless attributes.is_a?(Hash)
|
||||
self.class.openapi_types.each_pair do |key, type|
|
||||
if type =~ /\AArray<(.*)>/i
|
||||
# check to ensure the input is an array given that the attribute
|
||||
# is documented as an array but the input is not
|
||||
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
||||
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
||||
end
|
||||
elsif !attributes[self.class.attribute_map[key]].nil?
|
||||
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
||||
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
||||
end
|
||||
|
||||
self
|
||||
end
|
||||
|
||||
# Deserializes the data based on type
|
||||
# @param string type Data type
|
||||
# @param string value Value to be deserialized
|
||||
# @return [Object] Deserialized data
|
||||
def _deserialize(type, value)
|
||||
case type.to_sym
|
||||
when :DateTime
|
||||
DateTime.parse(value)
|
||||
when :Date
|
||||
Date.parse(value)
|
||||
when :String
|
||||
value.to_s
|
||||
when :Integer
|
||||
value.to_i
|
||||
when :Float
|
||||
value.to_f
|
||||
when :Boolean
|
||||
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
when :Object
|
||||
# generic object (usually a Hash), return directly
|
||||
value
|
||||
when /\AArray<(?<inner_type>.+)>\z/
|
||||
inner_type = Regexp.last_match[:inner_type]
|
||||
value.map { |v| _deserialize(inner_type, v) }
|
||||
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
||||
k_type = Regexp.last_match[:k_type]
|
||||
v_type = Regexp.last_match[:v_type]
|
||||
{}.tap do |hash|
|
||||
value.each do |k, v|
|
||||
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
||||
end
|
||||
end
|
||||
else # model
|
||||
Petstore.const_get(type).build_from_hash(value)
|
||||
end
|
||||
end
|
||||
|
||||
# Returns the string representation of the object
|
||||
# @return [String] String presentation of the object
|
||||
def to_s
|
||||
to_hash.to_s
|
||||
end
|
||||
|
||||
# to_body is an alias to to_hash (backward compatibility)
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_body
|
||||
to_hash
|
||||
end
|
||||
|
||||
# Returns the object in the form of hash
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_hash
|
||||
hash = {}
|
||||
self.class.attribute_map.each_pair do |attr, param|
|
||||
value = self.send(attr)
|
||||
next if value.nil?
|
||||
hash[param] = _to_hash(value)
|
||||
end
|
||||
hash
|
||||
end
|
||||
|
||||
# Outputs non-array value in the form of hash
|
||||
# For object, use to_hash. Otherwise, just return the value
|
||||
# @param [Object] value Any valid value
|
||||
# @return [Hash] Returns the value in the form of hash
|
||||
def _to_hash(value)
|
||||
if value.is_a?(Array)
|
||||
value.compact.map { |v| _to_hash(v) }
|
||||
elsif value.is_a?(Hash)
|
||||
{}.tap do |hash|
|
||||
value.each { |k, v| hash[k] = _to_hash(v) }
|
||||
end
|
||||
elsif value.respond_to? :to_hash
|
||||
value.to_hash
|
||||
else
|
||||
value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,205 @@
|
||||
=begin
|
||||
#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: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
Generated by: https://openapi-generator.tech
|
||||
OpenAPI Generator version: 4.2.0-SNAPSHOT
|
||||
|
||||
=end
|
||||
|
||||
require 'date'
|
||||
|
||||
module Petstore
|
||||
class HasOnlyReadOnly
|
||||
attr_accessor :bar
|
||||
|
||||
attr_accessor :foo
|
||||
|
||||
# Attribute mapping from ruby-style variable name to JSON key.
|
||||
def self.attribute_map
|
||||
{
|
||||
:'bar' => :'bar',
|
||||
:'foo' => :'foo'
|
||||
}
|
||||
end
|
||||
|
||||
# Attribute type mapping.
|
||||
def self.openapi_types
|
||||
{
|
||||
:'bar' => :'String',
|
||||
:'foo' => :'String'
|
||||
}
|
||||
end
|
||||
|
||||
# Initializes the object
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
def initialize(attributes = {})
|
||||
if (!attributes.is_a?(Hash))
|
||||
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::HasOnlyReadOnly` initialize method"
|
||||
end
|
||||
|
||||
# check to see if the attribute exists and convert string to symbol for hash key
|
||||
attributes = attributes.each_with_object({}) { |(k, v), h|
|
||||
if (!self.class.attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::HasOnlyReadOnly`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
||||
end
|
||||
h[k.to_sym] = v
|
||||
}
|
||||
|
||||
if attributes.key?(:'bar')
|
||||
self.bar = attributes[:'bar']
|
||||
end
|
||||
|
||||
if attributes.key?(:'foo')
|
||||
self.foo = attributes[:'foo']
|
||||
end
|
||||
end
|
||||
|
||||
# Show invalid properties with the reasons. Usually used together with valid?
|
||||
# @return Array for valid properties with the reasons
|
||||
def list_invalid_properties
|
||||
invalid_properties = Array.new
|
||||
invalid_properties
|
||||
end
|
||||
|
||||
# Check to see if the all the properties in the model are valid
|
||||
# @return true if the model is valid
|
||||
def valid?
|
||||
true
|
||||
end
|
||||
|
||||
# Checks equality by comparing each attribute.
|
||||
# @param [Object] Object to be compared
|
||||
def ==(o)
|
||||
return true if self.equal?(o)
|
||||
self.class == o.class &&
|
||||
bar == o.bar &&
|
||||
foo == o.foo
|
||||
end
|
||||
|
||||
# @see the `==` method
|
||||
# @param [Object] Object to be compared
|
||||
def eql?(o)
|
||||
self == o
|
||||
end
|
||||
|
||||
# Calculates hash code according to all attributes.
|
||||
# @return [Integer] Hash code
|
||||
def hash
|
||||
[bar, foo].hash
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def self.build_from_hash(attributes)
|
||||
new.build_from_hash(attributes)
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def build_from_hash(attributes)
|
||||
return nil unless attributes.is_a?(Hash)
|
||||
self.class.openapi_types.each_pair do |key, type|
|
||||
if type =~ /\AArray<(.*)>/i
|
||||
# check to ensure the input is an array given that the attribute
|
||||
# is documented as an array but the input is not
|
||||
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
||||
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
||||
end
|
||||
elsif !attributes[self.class.attribute_map[key]].nil?
|
||||
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
||||
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
||||
end
|
||||
|
||||
self
|
||||
end
|
||||
|
||||
# Deserializes the data based on type
|
||||
# @param string type Data type
|
||||
# @param string value Value to be deserialized
|
||||
# @return [Object] Deserialized data
|
||||
def _deserialize(type, value)
|
||||
case type.to_sym
|
||||
when :DateTime
|
||||
DateTime.parse(value)
|
||||
when :Date
|
||||
Date.parse(value)
|
||||
when :String
|
||||
value.to_s
|
||||
when :Integer
|
||||
value.to_i
|
||||
when :Float
|
||||
value.to_f
|
||||
when :Boolean
|
||||
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
when :Object
|
||||
# generic object (usually a Hash), return directly
|
||||
value
|
||||
when /\AArray<(?<inner_type>.+)>\z/
|
||||
inner_type = Regexp.last_match[:inner_type]
|
||||
value.map { |v| _deserialize(inner_type, v) }
|
||||
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
||||
k_type = Regexp.last_match[:k_type]
|
||||
v_type = Regexp.last_match[:v_type]
|
||||
{}.tap do |hash|
|
||||
value.each do |k, v|
|
||||
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
||||
end
|
||||
end
|
||||
else # model
|
||||
Petstore.const_get(type).build_from_hash(value)
|
||||
end
|
||||
end
|
||||
|
||||
# Returns the string representation of the object
|
||||
# @return [String] String presentation of the object
|
||||
def to_s
|
||||
to_hash.to_s
|
||||
end
|
||||
|
||||
# to_body is an alias to to_hash (backward compatibility)
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_body
|
||||
to_hash
|
||||
end
|
||||
|
||||
# Returns the object in the form of hash
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_hash
|
||||
hash = {}
|
||||
self.class.attribute_map.each_pair do |attr, param|
|
||||
value = self.send(attr)
|
||||
next if value.nil?
|
||||
hash[param] = _to_hash(value)
|
||||
end
|
||||
hash
|
||||
end
|
||||
|
||||
# Outputs non-array value in the form of hash
|
||||
# For object, use to_hash. Otherwise, just return the value
|
||||
# @param [Object] value Any valid value
|
||||
# @return [Hash] Returns the value in the form of hash
|
||||
def _to_hash(value)
|
||||
if value.is_a?(Array)
|
||||
value.compact.map { |v| _to_hash(v) }
|
||||
elsif value.is_a?(Hash)
|
||||
{}.tap do |hash|
|
||||
value.each { |k, v| hash[k] = _to_hash(v) }
|
||||
end
|
||||
elsif value.respond_to? :to_hash
|
||||
value.to_hash
|
||||
else
|
||||
value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
196
samples/client/petstore/ruby/lib/petstore/models/list.rb
Normal file
196
samples/client/petstore/ruby/lib/petstore/models/list.rb
Normal file
@ -0,0 +1,196 @@
|
||||
=begin
|
||||
#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: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
Generated by: https://openapi-generator.tech
|
||||
OpenAPI Generator version: 4.2.0-SNAPSHOT
|
||||
|
||||
=end
|
||||
|
||||
require 'date'
|
||||
|
||||
module Petstore
|
||||
class List
|
||||
attr_accessor :_123_list
|
||||
|
||||
# Attribute mapping from ruby-style variable name to JSON key.
|
||||
def self.attribute_map
|
||||
{
|
||||
:'_123_list' => :'123-list'
|
||||
}
|
||||
end
|
||||
|
||||
# Attribute type mapping.
|
||||
def self.openapi_types
|
||||
{
|
||||
:'_123_list' => :'String'
|
||||
}
|
||||
end
|
||||
|
||||
# Initializes the object
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
def initialize(attributes = {})
|
||||
if (!attributes.is_a?(Hash))
|
||||
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::List` initialize method"
|
||||
end
|
||||
|
||||
# check to see if the attribute exists and convert string to symbol for hash key
|
||||
attributes = attributes.each_with_object({}) { |(k, v), h|
|
||||
if (!self.class.attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::List`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
||||
end
|
||||
h[k.to_sym] = v
|
||||
}
|
||||
|
||||
if attributes.key?(:'_123_list')
|
||||
self._123_list = attributes[:'_123_list']
|
||||
end
|
||||
end
|
||||
|
||||
# Show invalid properties with the reasons. Usually used together with valid?
|
||||
# @return Array for valid properties with the reasons
|
||||
def list_invalid_properties
|
||||
invalid_properties = Array.new
|
||||
invalid_properties
|
||||
end
|
||||
|
||||
# Check to see if the all the properties in the model are valid
|
||||
# @return true if the model is valid
|
||||
def valid?
|
||||
true
|
||||
end
|
||||
|
||||
# Checks equality by comparing each attribute.
|
||||
# @param [Object] Object to be compared
|
||||
def ==(o)
|
||||
return true if self.equal?(o)
|
||||
self.class == o.class &&
|
||||
_123_list == o._123_list
|
||||
end
|
||||
|
||||
# @see the `==` method
|
||||
# @param [Object] Object to be compared
|
||||
def eql?(o)
|
||||
self == o
|
||||
end
|
||||
|
||||
# Calculates hash code according to all attributes.
|
||||
# @return [Integer] Hash code
|
||||
def hash
|
||||
[_123_list].hash
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def self.build_from_hash(attributes)
|
||||
new.build_from_hash(attributes)
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def build_from_hash(attributes)
|
||||
return nil unless attributes.is_a?(Hash)
|
||||
self.class.openapi_types.each_pair do |key, type|
|
||||
if type =~ /\AArray<(.*)>/i
|
||||
# check to ensure the input is an array given that the attribute
|
||||
# is documented as an array but the input is not
|
||||
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
||||
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
||||
end
|
||||
elsif !attributes[self.class.attribute_map[key]].nil?
|
||||
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
||||
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
||||
end
|
||||
|
||||
self
|
||||
end
|
||||
|
||||
# Deserializes the data based on type
|
||||
# @param string type Data type
|
||||
# @param string value Value to be deserialized
|
||||
# @return [Object] Deserialized data
|
||||
def _deserialize(type, value)
|
||||
case type.to_sym
|
||||
when :DateTime
|
||||
DateTime.parse(value)
|
||||
when :Date
|
||||
Date.parse(value)
|
||||
when :String
|
||||
value.to_s
|
||||
when :Integer
|
||||
value.to_i
|
||||
when :Float
|
||||
value.to_f
|
||||
when :Boolean
|
||||
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
when :Object
|
||||
# generic object (usually a Hash), return directly
|
||||
value
|
||||
when /\AArray<(?<inner_type>.+)>\z/
|
||||
inner_type = Regexp.last_match[:inner_type]
|
||||
value.map { |v| _deserialize(inner_type, v) }
|
||||
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
||||
k_type = Regexp.last_match[:k_type]
|
||||
v_type = Regexp.last_match[:v_type]
|
||||
{}.tap do |hash|
|
||||
value.each do |k, v|
|
||||
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
||||
end
|
||||
end
|
||||
else # model
|
||||
Petstore.const_get(type).build_from_hash(value)
|
||||
end
|
||||
end
|
||||
|
||||
# Returns the string representation of the object
|
||||
# @return [String] String presentation of the object
|
||||
def to_s
|
||||
to_hash.to_s
|
||||
end
|
||||
|
||||
# to_body is an alias to to_hash (backward compatibility)
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_body
|
||||
to_hash
|
||||
end
|
||||
|
||||
# Returns the object in the form of hash
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_hash
|
||||
hash = {}
|
||||
self.class.attribute_map.each_pair do |attr, param|
|
||||
value = self.send(attr)
|
||||
next if value.nil?
|
||||
hash[param] = _to_hash(value)
|
||||
end
|
||||
hash
|
||||
end
|
||||
|
||||
# Outputs non-array value in the form of hash
|
||||
# For object, use to_hash. Otherwise, just return the value
|
||||
# @param [Object] value Any valid value
|
||||
# @return [Hash] Returns the value in the form of hash
|
||||
def _to_hash(value)
|
||||
if value.is_a?(Array)
|
||||
value.compact.map { |v| _to_hash(v) }
|
||||
elsif value.is_a?(Hash)
|
||||
{}.tap do |hash|
|
||||
value.each { |k, v| hash[k] = _to_hash(v) }
|
||||
end
|
||||
elsif value.respond_to? :to_hash
|
||||
value.to_hash
|
||||
else
|
||||
value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
253
samples/client/petstore/ruby/lib/petstore/models/map_test.rb
Normal file
253
samples/client/petstore/ruby/lib/petstore/models/map_test.rb
Normal file
@ -0,0 +1,253 @@
|
||||
=begin
|
||||
#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: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
Generated by: https://openapi-generator.tech
|
||||
OpenAPI Generator version: 4.2.0-SNAPSHOT
|
||||
|
||||
=end
|
||||
|
||||
require 'date'
|
||||
|
||||
module Petstore
|
||||
class MapTest
|
||||
attr_accessor :map_map_of_string
|
||||
|
||||
attr_accessor :map_of_enum_string
|
||||
|
||||
attr_accessor :direct_map
|
||||
|
||||
attr_accessor :indirect_map
|
||||
|
||||
class EnumAttributeValidator
|
||||
attr_reader :datatype
|
||||
attr_reader :allowable_values
|
||||
|
||||
def initialize(datatype, allowable_values)
|
||||
@allowable_values = allowable_values.map do |value|
|
||||
case datatype.to_s
|
||||
when /Integer/i
|
||||
value.to_i
|
||||
when /Float/i
|
||||
value.to_f
|
||||
else
|
||||
value
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def valid?(value)
|
||||
!value || allowable_values.include?(value)
|
||||
end
|
||||
end
|
||||
|
||||
# Attribute mapping from ruby-style variable name to JSON key.
|
||||
def self.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'
|
||||
}
|
||||
end
|
||||
|
||||
# Attribute type mapping.
|
||||
def self.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>'
|
||||
}
|
||||
end
|
||||
|
||||
# Initializes the object
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
def initialize(attributes = {})
|
||||
if (!attributes.is_a?(Hash))
|
||||
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::MapTest` initialize method"
|
||||
end
|
||||
|
||||
# check to see if the attribute exists and convert string to symbol for hash key
|
||||
attributes = attributes.each_with_object({}) { |(k, v), h|
|
||||
if (!self.class.attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::MapTest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
||||
end
|
||||
h[k.to_sym] = v
|
||||
}
|
||||
|
||||
if attributes.key?(:'map_map_of_string')
|
||||
if (value = attributes[:'map_map_of_string']).is_a?(Hash)
|
||||
self.map_map_of_string = value
|
||||
end
|
||||
end
|
||||
|
||||
if attributes.key?(:'map_of_enum_string')
|
||||
if (value = attributes[:'map_of_enum_string']).is_a?(Hash)
|
||||
self.map_of_enum_string = value
|
||||
end
|
||||
end
|
||||
|
||||
if attributes.key?(:'direct_map')
|
||||
if (value = attributes[:'direct_map']).is_a?(Hash)
|
||||
self.direct_map = value
|
||||
end
|
||||
end
|
||||
|
||||
if attributes.key?(:'indirect_map')
|
||||
if (value = attributes[:'indirect_map']).is_a?(Hash)
|
||||
self.indirect_map = value
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Show invalid properties with the reasons. Usually used together with valid?
|
||||
# @return Array for valid properties with the reasons
|
||||
def list_invalid_properties
|
||||
invalid_properties = Array.new
|
||||
invalid_properties
|
||||
end
|
||||
|
||||
# Check to see if the all the properties in the model are valid
|
||||
# @return true if the model is valid
|
||||
def valid?
|
||||
true
|
||||
end
|
||||
|
||||
# Checks equality by comparing each attribute.
|
||||
# @param [Object] Object to be compared
|
||||
def ==(o)
|
||||
return true if self.equal?(o)
|
||||
self.class == o.class &&
|
||||
map_map_of_string == o.map_map_of_string &&
|
||||
map_of_enum_string == o.map_of_enum_string &&
|
||||
direct_map == o.direct_map &&
|
||||
indirect_map == o.indirect_map
|
||||
end
|
||||
|
||||
# @see the `==` method
|
||||
# @param [Object] Object to be compared
|
||||
def eql?(o)
|
||||
self == o
|
||||
end
|
||||
|
||||
# Calculates hash code according to all attributes.
|
||||
# @return [Integer] Hash code
|
||||
def hash
|
||||
[map_map_of_string, map_of_enum_string, direct_map, indirect_map].hash
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def self.build_from_hash(attributes)
|
||||
new.build_from_hash(attributes)
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def build_from_hash(attributes)
|
||||
return nil unless attributes.is_a?(Hash)
|
||||
self.class.openapi_types.each_pair do |key, type|
|
||||
if type =~ /\AArray<(.*)>/i
|
||||
# check to ensure the input is an array given that the attribute
|
||||
# is documented as an array but the input is not
|
||||
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
||||
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
||||
end
|
||||
elsif !attributes[self.class.attribute_map[key]].nil?
|
||||
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
||||
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
||||
end
|
||||
|
||||
self
|
||||
end
|
||||
|
||||
# Deserializes the data based on type
|
||||
# @param string type Data type
|
||||
# @param string value Value to be deserialized
|
||||
# @return [Object] Deserialized data
|
||||
def _deserialize(type, value)
|
||||
case type.to_sym
|
||||
when :DateTime
|
||||
DateTime.parse(value)
|
||||
when :Date
|
||||
Date.parse(value)
|
||||
when :String
|
||||
value.to_s
|
||||
when :Integer
|
||||
value.to_i
|
||||
when :Float
|
||||
value.to_f
|
||||
when :Boolean
|
||||
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
when :Object
|
||||
# generic object (usually a Hash), return directly
|
||||
value
|
||||
when /\AArray<(?<inner_type>.+)>\z/
|
||||
inner_type = Regexp.last_match[:inner_type]
|
||||
value.map { |v| _deserialize(inner_type, v) }
|
||||
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
||||
k_type = Regexp.last_match[:k_type]
|
||||
v_type = Regexp.last_match[:v_type]
|
||||
{}.tap do |hash|
|
||||
value.each do |k, v|
|
||||
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
||||
end
|
||||
end
|
||||
else # model
|
||||
Petstore.const_get(type).build_from_hash(value)
|
||||
end
|
||||
end
|
||||
|
||||
# Returns the string representation of the object
|
||||
# @return [String] String presentation of the object
|
||||
def to_s
|
||||
to_hash.to_s
|
||||
end
|
||||
|
||||
# to_body is an alias to to_hash (backward compatibility)
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_body
|
||||
to_hash
|
||||
end
|
||||
|
||||
# Returns the object in the form of hash
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_hash
|
||||
hash = {}
|
||||
self.class.attribute_map.each_pair do |attr, param|
|
||||
value = self.send(attr)
|
||||
next if value.nil?
|
||||
hash[param] = _to_hash(value)
|
||||
end
|
||||
hash
|
||||
end
|
||||
|
||||
# Outputs non-array value in the form of hash
|
||||
# For object, use to_hash. Otherwise, just return the value
|
||||
# @param [Object] value Any valid value
|
||||
# @return [Hash] Returns the value in the form of hash
|
||||
def _to_hash(value)
|
||||
if value.is_a?(Array)
|
||||
value.compact.map { |v| _to_hash(v) }
|
||||
elsif value.is_a?(Hash)
|
||||
{}.tap do |hash|
|
||||
value.each { |k, v| hash[k] = _to_hash(v) }
|
||||
end
|
||||
elsif value.respond_to? :to_hash
|
||||
value.to_hash
|
||||
else
|
||||
value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,216 @@
|
||||
=begin
|
||||
#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: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
Generated by: https://openapi-generator.tech
|
||||
OpenAPI Generator version: 4.2.0-SNAPSHOT
|
||||
|
||||
=end
|
||||
|
||||
require 'date'
|
||||
|
||||
module Petstore
|
||||
class MixedPropertiesAndAdditionalPropertiesClass
|
||||
attr_accessor :uuid
|
||||
|
||||
attr_accessor :date_time
|
||||
|
||||
attr_accessor :map
|
||||
|
||||
# Attribute mapping from ruby-style variable name to JSON key.
|
||||
def self.attribute_map
|
||||
{
|
||||
:'uuid' => :'uuid',
|
||||
:'date_time' => :'dateTime',
|
||||
:'map' => :'map'
|
||||
}
|
||||
end
|
||||
|
||||
# Attribute type mapping.
|
||||
def self.openapi_types
|
||||
{
|
||||
:'uuid' => :'String',
|
||||
:'date_time' => :'DateTime',
|
||||
:'map' => :'Hash<String, Animal>'
|
||||
}
|
||||
end
|
||||
|
||||
# Initializes the object
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
def initialize(attributes = {})
|
||||
if (!attributes.is_a?(Hash))
|
||||
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::MixedPropertiesAndAdditionalPropertiesClass` initialize method"
|
||||
end
|
||||
|
||||
# check to see if the attribute exists and convert string to symbol for hash key
|
||||
attributes = attributes.each_with_object({}) { |(k, v), h|
|
||||
if (!self.class.attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::MixedPropertiesAndAdditionalPropertiesClass`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
||||
end
|
||||
h[k.to_sym] = v
|
||||
}
|
||||
|
||||
if attributes.key?(:'uuid')
|
||||
self.uuid = attributes[:'uuid']
|
||||
end
|
||||
|
||||
if attributes.key?(:'date_time')
|
||||
self.date_time = attributes[:'date_time']
|
||||
end
|
||||
|
||||
if attributes.key?(:'map')
|
||||
if (value = attributes[:'map']).is_a?(Hash)
|
||||
self.map = value
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Show invalid properties with the reasons. Usually used together with valid?
|
||||
# @return Array for valid properties with the reasons
|
||||
def list_invalid_properties
|
||||
invalid_properties = Array.new
|
||||
invalid_properties
|
||||
end
|
||||
|
||||
# Check to see if the all the properties in the model are valid
|
||||
# @return true if the model is valid
|
||||
def valid?
|
||||
true
|
||||
end
|
||||
|
||||
# Checks equality by comparing each attribute.
|
||||
# @param [Object] Object to be compared
|
||||
def ==(o)
|
||||
return true if self.equal?(o)
|
||||
self.class == o.class &&
|
||||
uuid == o.uuid &&
|
||||
date_time == o.date_time &&
|
||||
map == o.map
|
||||
end
|
||||
|
||||
# @see the `==` method
|
||||
# @param [Object] Object to be compared
|
||||
def eql?(o)
|
||||
self == o
|
||||
end
|
||||
|
||||
# Calculates hash code according to all attributes.
|
||||
# @return [Integer] Hash code
|
||||
def hash
|
||||
[uuid, date_time, map].hash
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def self.build_from_hash(attributes)
|
||||
new.build_from_hash(attributes)
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def build_from_hash(attributes)
|
||||
return nil unless attributes.is_a?(Hash)
|
||||
self.class.openapi_types.each_pair do |key, type|
|
||||
if type =~ /\AArray<(.*)>/i
|
||||
# check to ensure the input is an array given that the attribute
|
||||
# is documented as an array but the input is not
|
||||
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
||||
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
||||
end
|
||||
elsif !attributes[self.class.attribute_map[key]].nil?
|
||||
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
||||
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
||||
end
|
||||
|
||||
self
|
||||
end
|
||||
|
||||
# Deserializes the data based on type
|
||||
# @param string type Data type
|
||||
# @param string value Value to be deserialized
|
||||
# @return [Object] Deserialized data
|
||||
def _deserialize(type, value)
|
||||
case type.to_sym
|
||||
when :DateTime
|
||||
DateTime.parse(value)
|
||||
when :Date
|
||||
Date.parse(value)
|
||||
when :String
|
||||
value.to_s
|
||||
when :Integer
|
||||
value.to_i
|
||||
when :Float
|
||||
value.to_f
|
||||
when :Boolean
|
||||
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
when :Object
|
||||
# generic object (usually a Hash), return directly
|
||||
value
|
||||
when /\AArray<(?<inner_type>.+)>\z/
|
||||
inner_type = Regexp.last_match[:inner_type]
|
||||
value.map { |v| _deserialize(inner_type, v) }
|
||||
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
||||
k_type = Regexp.last_match[:k_type]
|
||||
v_type = Regexp.last_match[:v_type]
|
||||
{}.tap do |hash|
|
||||
value.each do |k, v|
|
||||
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
||||
end
|
||||
end
|
||||
else # model
|
||||
Petstore.const_get(type).build_from_hash(value)
|
||||
end
|
||||
end
|
||||
|
||||
# Returns the string representation of the object
|
||||
# @return [String] String presentation of the object
|
||||
def to_s
|
||||
to_hash.to_s
|
||||
end
|
||||
|
||||
# to_body is an alias to to_hash (backward compatibility)
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_body
|
||||
to_hash
|
||||
end
|
||||
|
||||
# Returns the object in the form of hash
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_hash
|
||||
hash = {}
|
||||
self.class.attribute_map.each_pair do |attr, param|
|
||||
value = self.send(attr)
|
||||
next if value.nil?
|
||||
hash[param] = _to_hash(value)
|
||||
end
|
||||
hash
|
||||
end
|
||||
|
||||
# Outputs non-array value in the form of hash
|
||||
# For object, use to_hash. Otherwise, just return the value
|
||||
# @param [Object] value Any valid value
|
||||
# @return [Hash] Returns the value in the form of hash
|
||||
def _to_hash(value)
|
||||
if value.is_a?(Array)
|
||||
value.compact.map { |v| _to_hash(v) }
|
||||
elsif value.is_a?(Hash)
|
||||
{}.tap do |hash|
|
||||
value.each { |k, v| hash[k] = _to_hash(v) }
|
||||
end
|
||||
elsif value.respond_to? :to_hash
|
||||
value.to_hash
|
||||
else
|
||||
value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,206 @@
|
||||
=begin
|
||||
#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: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
Generated by: https://openapi-generator.tech
|
||||
OpenAPI Generator version: 4.2.0-SNAPSHOT
|
||||
|
||||
=end
|
||||
|
||||
require 'date'
|
||||
|
||||
module Petstore
|
||||
# Model for testing model name starting with number
|
||||
class Model200Response
|
||||
attr_accessor :name
|
||||
|
||||
attr_accessor :_class
|
||||
|
||||
# Attribute mapping from ruby-style variable name to JSON key.
|
||||
def self.attribute_map
|
||||
{
|
||||
:'name' => :'name',
|
||||
:'_class' => :'class'
|
||||
}
|
||||
end
|
||||
|
||||
# Attribute type mapping.
|
||||
def self.openapi_types
|
||||
{
|
||||
:'name' => :'Integer',
|
||||
:'_class' => :'String'
|
||||
}
|
||||
end
|
||||
|
||||
# Initializes the object
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
def initialize(attributes = {})
|
||||
if (!attributes.is_a?(Hash))
|
||||
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::Model200Response` initialize method"
|
||||
end
|
||||
|
||||
# check to see if the attribute exists and convert string to symbol for hash key
|
||||
attributes = attributes.each_with_object({}) { |(k, v), h|
|
||||
if (!self.class.attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::Model200Response`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
||||
end
|
||||
h[k.to_sym] = v
|
||||
}
|
||||
|
||||
if attributes.key?(:'name')
|
||||
self.name = attributes[:'name']
|
||||
end
|
||||
|
||||
if attributes.key?(:'_class')
|
||||
self._class = attributes[:'_class']
|
||||
end
|
||||
end
|
||||
|
||||
# Show invalid properties with the reasons. Usually used together with valid?
|
||||
# @return Array for valid properties with the reasons
|
||||
def list_invalid_properties
|
||||
invalid_properties = Array.new
|
||||
invalid_properties
|
||||
end
|
||||
|
||||
# Check to see if the all the properties in the model are valid
|
||||
# @return true if the model is valid
|
||||
def valid?
|
||||
true
|
||||
end
|
||||
|
||||
# Checks equality by comparing each attribute.
|
||||
# @param [Object] Object to be compared
|
||||
def ==(o)
|
||||
return true if self.equal?(o)
|
||||
self.class == o.class &&
|
||||
name == o.name &&
|
||||
_class == o._class
|
||||
end
|
||||
|
||||
# @see the `==` method
|
||||
# @param [Object] Object to be compared
|
||||
def eql?(o)
|
||||
self == o
|
||||
end
|
||||
|
||||
# Calculates hash code according to all attributes.
|
||||
# @return [Integer] Hash code
|
||||
def hash
|
||||
[name, _class].hash
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def self.build_from_hash(attributes)
|
||||
new.build_from_hash(attributes)
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def build_from_hash(attributes)
|
||||
return nil unless attributes.is_a?(Hash)
|
||||
self.class.openapi_types.each_pair do |key, type|
|
||||
if type =~ /\AArray<(.*)>/i
|
||||
# check to ensure the input is an array given that the attribute
|
||||
# is documented as an array but the input is not
|
||||
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
||||
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
||||
end
|
||||
elsif !attributes[self.class.attribute_map[key]].nil?
|
||||
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
||||
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
||||
end
|
||||
|
||||
self
|
||||
end
|
||||
|
||||
# Deserializes the data based on type
|
||||
# @param string type Data type
|
||||
# @param string value Value to be deserialized
|
||||
# @return [Object] Deserialized data
|
||||
def _deserialize(type, value)
|
||||
case type.to_sym
|
||||
when :DateTime
|
||||
DateTime.parse(value)
|
||||
when :Date
|
||||
Date.parse(value)
|
||||
when :String
|
||||
value.to_s
|
||||
when :Integer
|
||||
value.to_i
|
||||
when :Float
|
||||
value.to_f
|
||||
when :Boolean
|
||||
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
when :Object
|
||||
# generic object (usually a Hash), return directly
|
||||
value
|
||||
when /\AArray<(?<inner_type>.+)>\z/
|
||||
inner_type = Regexp.last_match[:inner_type]
|
||||
value.map { |v| _deserialize(inner_type, v) }
|
||||
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
||||
k_type = Regexp.last_match[:k_type]
|
||||
v_type = Regexp.last_match[:v_type]
|
||||
{}.tap do |hash|
|
||||
value.each do |k, v|
|
||||
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
||||
end
|
||||
end
|
||||
else # model
|
||||
Petstore.const_get(type).build_from_hash(value)
|
||||
end
|
||||
end
|
||||
|
||||
# Returns the string representation of the object
|
||||
# @return [String] String presentation of the object
|
||||
def to_s
|
||||
to_hash.to_s
|
||||
end
|
||||
|
||||
# to_body is an alias to to_hash (backward compatibility)
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_body
|
||||
to_hash
|
||||
end
|
||||
|
||||
# Returns the object in the form of hash
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_hash
|
||||
hash = {}
|
||||
self.class.attribute_map.each_pair do |attr, param|
|
||||
value = self.send(attr)
|
||||
next if value.nil?
|
||||
hash[param] = _to_hash(value)
|
||||
end
|
||||
hash
|
||||
end
|
||||
|
||||
# Outputs non-array value in the form of hash
|
||||
# For object, use to_hash. Otherwise, just return the value
|
||||
# @param [Object] value Any valid value
|
||||
# @return [Hash] Returns the value in the form of hash
|
||||
def _to_hash(value)
|
||||
if value.is_a?(Array)
|
||||
value.compact.map { |v| _to_hash(v) }
|
||||
elsif value.is_a?(Hash)
|
||||
{}.tap do |hash|
|
||||
value.each { |k, v| hash[k] = _to_hash(v) }
|
||||
end
|
||||
elsif value.respond_to? :to_hash
|
||||
value.to_hash
|
||||
else
|
||||
value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
197
samples/client/petstore/ruby/lib/petstore/models/model_return.rb
Normal file
197
samples/client/petstore/ruby/lib/petstore/models/model_return.rb
Normal file
@ -0,0 +1,197 @@
|
||||
=begin
|
||||
#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: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
Generated by: https://openapi-generator.tech
|
||||
OpenAPI Generator version: 4.2.0-SNAPSHOT
|
||||
|
||||
=end
|
||||
|
||||
require 'date'
|
||||
|
||||
module Petstore
|
||||
# Model for testing reserved words
|
||||
class ModelReturn
|
||||
attr_accessor :_return
|
||||
|
||||
# Attribute mapping from ruby-style variable name to JSON key.
|
||||
def self.attribute_map
|
||||
{
|
||||
:'_return' => :'return'
|
||||
}
|
||||
end
|
||||
|
||||
# Attribute type mapping.
|
||||
def self.openapi_types
|
||||
{
|
||||
:'_return' => :'Integer'
|
||||
}
|
||||
end
|
||||
|
||||
# Initializes the object
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
def initialize(attributes = {})
|
||||
if (!attributes.is_a?(Hash))
|
||||
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::ModelReturn` initialize method"
|
||||
end
|
||||
|
||||
# check to see if the attribute exists and convert string to symbol for hash key
|
||||
attributes = attributes.each_with_object({}) { |(k, v), h|
|
||||
if (!self.class.attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::ModelReturn`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
||||
end
|
||||
h[k.to_sym] = v
|
||||
}
|
||||
|
||||
if attributes.key?(:'_return')
|
||||
self._return = attributes[:'_return']
|
||||
end
|
||||
end
|
||||
|
||||
# Show invalid properties with the reasons. Usually used together with valid?
|
||||
# @return Array for valid properties with the reasons
|
||||
def list_invalid_properties
|
||||
invalid_properties = Array.new
|
||||
invalid_properties
|
||||
end
|
||||
|
||||
# Check to see if the all the properties in the model are valid
|
||||
# @return true if the model is valid
|
||||
def valid?
|
||||
true
|
||||
end
|
||||
|
||||
# Checks equality by comparing each attribute.
|
||||
# @param [Object] Object to be compared
|
||||
def ==(o)
|
||||
return true if self.equal?(o)
|
||||
self.class == o.class &&
|
||||
_return == o._return
|
||||
end
|
||||
|
||||
# @see the `==` method
|
||||
# @param [Object] Object to be compared
|
||||
def eql?(o)
|
||||
self == o
|
||||
end
|
||||
|
||||
# Calculates hash code according to all attributes.
|
||||
# @return [Integer] Hash code
|
||||
def hash
|
||||
[_return].hash
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def self.build_from_hash(attributes)
|
||||
new.build_from_hash(attributes)
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def build_from_hash(attributes)
|
||||
return nil unless attributes.is_a?(Hash)
|
||||
self.class.openapi_types.each_pair do |key, type|
|
||||
if type =~ /\AArray<(.*)>/i
|
||||
# check to ensure the input is an array given that the attribute
|
||||
# is documented as an array but the input is not
|
||||
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
||||
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
||||
end
|
||||
elsif !attributes[self.class.attribute_map[key]].nil?
|
||||
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
||||
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
||||
end
|
||||
|
||||
self
|
||||
end
|
||||
|
||||
# Deserializes the data based on type
|
||||
# @param string type Data type
|
||||
# @param string value Value to be deserialized
|
||||
# @return [Object] Deserialized data
|
||||
def _deserialize(type, value)
|
||||
case type.to_sym
|
||||
when :DateTime
|
||||
DateTime.parse(value)
|
||||
when :Date
|
||||
Date.parse(value)
|
||||
when :String
|
||||
value.to_s
|
||||
when :Integer
|
||||
value.to_i
|
||||
when :Float
|
||||
value.to_f
|
||||
when :Boolean
|
||||
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
when :Object
|
||||
# generic object (usually a Hash), return directly
|
||||
value
|
||||
when /\AArray<(?<inner_type>.+)>\z/
|
||||
inner_type = Regexp.last_match[:inner_type]
|
||||
value.map { |v| _deserialize(inner_type, v) }
|
||||
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
||||
k_type = Regexp.last_match[:k_type]
|
||||
v_type = Regexp.last_match[:v_type]
|
||||
{}.tap do |hash|
|
||||
value.each do |k, v|
|
||||
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
||||
end
|
||||
end
|
||||
else # model
|
||||
Petstore.const_get(type).build_from_hash(value)
|
||||
end
|
||||
end
|
||||
|
||||
# Returns the string representation of the object
|
||||
# @return [String] String presentation of the object
|
||||
def to_s
|
||||
to_hash.to_s
|
||||
end
|
||||
|
||||
# to_body is an alias to to_hash (backward compatibility)
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_body
|
||||
to_hash
|
||||
end
|
||||
|
||||
# Returns the object in the form of hash
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_hash
|
||||
hash = {}
|
||||
self.class.attribute_map.each_pair do |attr, param|
|
||||
value = self.send(attr)
|
||||
next if value.nil?
|
||||
hash[param] = _to_hash(value)
|
||||
end
|
||||
hash
|
||||
end
|
||||
|
||||
# Outputs non-array value in the form of hash
|
||||
# For object, use to_hash. Otherwise, just return the value
|
||||
# @param [Object] value Any valid value
|
||||
# @return [Hash] Returns the value in the form of hash
|
||||
def _to_hash(value)
|
||||
if value.is_a?(Array)
|
||||
value.compact.map { |v| _to_hash(v) }
|
||||
elsif value.is_a?(Hash)
|
||||
{}.tap do |hash|
|
||||
value.each { |k, v| hash[k] = _to_hash(v) }
|
||||
end
|
||||
elsif value.respond_to? :to_hash
|
||||
value.to_hash
|
||||
else
|
||||
value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
229
samples/client/petstore/ruby/lib/petstore/models/name.rb
Normal file
229
samples/client/petstore/ruby/lib/petstore/models/name.rb
Normal file
@ -0,0 +1,229 @@
|
||||
=begin
|
||||
#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: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
Generated by: https://openapi-generator.tech
|
||||
OpenAPI Generator version: 4.2.0-SNAPSHOT
|
||||
|
||||
=end
|
||||
|
||||
require 'date'
|
||||
|
||||
module Petstore
|
||||
# Model for testing model name same as property name
|
||||
class Name
|
||||
attr_accessor :name
|
||||
|
||||
attr_accessor :snake_case
|
||||
|
||||
attr_accessor :property
|
||||
|
||||
attr_accessor :_123_number
|
||||
|
||||
# Attribute mapping from ruby-style variable name to JSON key.
|
||||
def self.attribute_map
|
||||
{
|
||||
:'name' => :'name',
|
||||
:'snake_case' => :'snake_case',
|
||||
:'property' => :'property',
|
||||
:'_123_number' => :'123Number'
|
||||
}
|
||||
end
|
||||
|
||||
# Attribute type mapping.
|
||||
def self.openapi_types
|
||||
{
|
||||
:'name' => :'Integer',
|
||||
:'snake_case' => :'Integer',
|
||||
:'property' => :'String',
|
||||
:'_123_number' => :'Integer'
|
||||
}
|
||||
end
|
||||
|
||||
# Initializes the object
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
def initialize(attributes = {})
|
||||
if (!attributes.is_a?(Hash))
|
||||
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::Name` initialize method"
|
||||
end
|
||||
|
||||
# check to see if the attribute exists and convert string to symbol for hash key
|
||||
attributes = attributes.each_with_object({}) { |(k, v), h|
|
||||
if (!self.class.attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::Name`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
||||
end
|
||||
h[k.to_sym] = v
|
||||
}
|
||||
|
||||
if attributes.key?(:'name')
|
||||
self.name = attributes[:'name']
|
||||
end
|
||||
|
||||
if attributes.key?(:'snake_case')
|
||||
self.snake_case = attributes[:'snake_case']
|
||||
end
|
||||
|
||||
if attributes.key?(:'property')
|
||||
self.property = attributes[:'property']
|
||||
end
|
||||
|
||||
if attributes.key?(:'_123_number')
|
||||
self._123_number = attributes[:'_123_number']
|
||||
end
|
||||
end
|
||||
|
||||
# Show invalid properties with the reasons. Usually used together with valid?
|
||||
# @return Array for valid properties with the reasons
|
||||
def list_invalid_properties
|
||||
invalid_properties = Array.new
|
||||
if @name.nil?
|
||||
invalid_properties.push('invalid value for "name", name cannot be nil.')
|
||||
end
|
||||
|
||||
invalid_properties
|
||||
end
|
||||
|
||||
# Check to see if the all the properties in the model are valid
|
||||
# @return true if the model is valid
|
||||
def valid?
|
||||
return false if @name.nil?
|
||||
true
|
||||
end
|
||||
|
||||
# Checks equality by comparing each attribute.
|
||||
# @param [Object] Object to be compared
|
||||
def ==(o)
|
||||
return true if self.equal?(o)
|
||||
self.class == o.class &&
|
||||
name == o.name &&
|
||||
snake_case == o.snake_case &&
|
||||
property == o.property &&
|
||||
_123_number == o._123_number
|
||||
end
|
||||
|
||||
# @see the `==` method
|
||||
# @param [Object] Object to be compared
|
||||
def eql?(o)
|
||||
self == o
|
||||
end
|
||||
|
||||
# Calculates hash code according to all attributes.
|
||||
# @return [Integer] Hash code
|
||||
def hash
|
||||
[name, snake_case, property, _123_number].hash
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def self.build_from_hash(attributes)
|
||||
new.build_from_hash(attributes)
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def build_from_hash(attributes)
|
||||
return nil unless attributes.is_a?(Hash)
|
||||
self.class.openapi_types.each_pair do |key, type|
|
||||
if type =~ /\AArray<(.*)>/i
|
||||
# check to ensure the input is an array given that the attribute
|
||||
# is documented as an array but the input is not
|
||||
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
||||
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
||||
end
|
||||
elsif !attributes[self.class.attribute_map[key]].nil?
|
||||
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
||||
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
||||
end
|
||||
|
||||
self
|
||||
end
|
||||
|
||||
# Deserializes the data based on type
|
||||
# @param string type Data type
|
||||
# @param string value Value to be deserialized
|
||||
# @return [Object] Deserialized data
|
||||
def _deserialize(type, value)
|
||||
case type.to_sym
|
||||
when :DateTime
|
||||
DateTime.parse(value)
|
||||
when :Date
|
||||
Date.parse(value)
|
||||
when :String
|
||||
value.to_s
|
||||
when :Integer
|
||||
value.to_i
|
||||
when :Float
|
||||
value.to_f
|
||||
when :Boolean
|
||||
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
when :Object
|
||||
# generic object (usually a Hash), return directly
|
||||
value
|
||||
when /\AArray<(?<inner_type>.+)>\z/
|
||||
inner_type = Regexp.last_match[:inner_type]
|
||||
value.map { |v| _deserialize(inner_type, v) }
|
||||
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
||||
k_type = Regexp.last_match[:k_type]
|
||||
v_type = Regexp.last_match[:v_type]
|
||||
{}.tap do |hash|
|
||||
value.each do |k, v|
|
||||
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
||||
end
|
||||
end
|
||||
else # model
|
||||
Petstore.const_get(type).build_from_hash(value)
|
||||
end
|
||||
end
|
||||
|
||||
# Returns the string representation of the object
|
||||
# @return [String] String presentation of the object
|
||||
def to_s
|
||||
to_hash.to_s
|
||||
end
|
||||
|
||||
# to_body is an alias to to_hash (backward compatibility)
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_body
|
||||
to_hash
|
||||
end
|
||||
|
||||
# Returns the object in the form of hash
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_hash
|
||||
hash = {}
|
||||
self.class.attribute_map.each_pair do |attr, param|
|
||||
value = self.send(attr)
|
||||
next if value.nil?
|
||||
hash[param] = _to_hash(value)
|
||||
end
|
||||
hash
|
||||
end
|
||||
|
||||
# Outputs non-array value in the form of hash
|
||||
# For object, use to_hash. Otherwise, just return the value
|
||||
# @param [Object] value Any valid value
|
||||
# @return [Hash] Returns the value in the form of hash
|
||||
def _to_hash(value)
|
||||
if value.is_a?(Array)
|
||||
value.compact.map { |v| _to_hash(v) }
|
||||
elsif value.is_a?(Hash)
|
||||
{}.tap do |hash|
|
||||
value.each { |k, v| hash[k] = _to_hash(v) }
|
||||
end
|
||||
elsif value.respond_to? :to_hash
|
||||
value.to_hash
|
||||
else
|
||||
value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
196
samples/client/petstore/ruby/lib/petstore/models/number_only.rb
Normal file
196
samples/client/petstore/ruby/lib/petstore/models/number_only.rb
Normal file
@ -0,0 +1,196 @@
|
||||
=begin
|
||||
#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: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
Generated by: https://openapi-generator.tech
|
||||
OpenAPI Generator version: 4.2.0-SNAPSHOT
|
||||
|
||||
=end
|
||||
|
||||
require 'date'
|
||||
|
||||
module Petstore
|
||||
class NumberOnly
|
||||
attr_accessor :just_number
|
||||
|
||||
# Attribute mapping from ruby-style variable name to JSON key.
|
||||
def self.attribute_map
|
||||
{
|
||||
:'just_number' => :'JustNumber'
|
||||
}
|
||||
end
|
||||
|
||||
# Attribute type mapping.
|
||||
def self.openapi_types
|
||||
{
|
||||
:'just_number' => :'Float'
|
||||
}
|
||||
end
|
||||
|
||||
# Initializes the object
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
def initialize(attributes = {})
|
||||
if (!attributes.is_a?(Hash))
|
||||
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::NumberOnly` initialize method"
|
||||
end
|
||||
|
||||
# check to see if the attribute exists and convert string to symbol for hash key
|
||||
attributes = attributes.each_with_object({}) { |(k, v), h|
|
||||
if (!self.class.attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::NumberOnly`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
||||
end
|
||||
h[k.to_sym] = v
|
||||
}
|
||||
|
||||
if attributes.key?(:'just_number')
|
||||
self.just_number = attributes[:'just_number']
|
||||
end
|
||||
end
|
||||
|
||||
# Show invalid properties with the reasons. Usually used together with valid?
|
||||
# @return Array for valid properties with the reasons
|
||||
def list_invalid_properties
|
||||
invalid_properties = Array.new
|
||||
invalid_properties
|
||||
end
|
||||
|
||||
# Check to see if the all the properties in the model are valid
|
||||
# @return true if the model is valid
|
||||
def valid?
|
||||
true
|
||||
end
|
||||
|
||||
# Checks equality by comparing each attribute.
|
||||
# @param [Object] Object to be compared
|
||||
def ==(o)
|
||||
return true if self.equal?(o)
|
||||
self.class == o.class &&
|
||||
just_number == o.just_number
|
||||
end
|
||||
|
||||
# @see the `==` method
|
||||
# @param [Object] Object to be compared
|
||||
def eql?(o)
|
||||
self == o
|
||||
end
|
||||
|
||||
# Calculates hash code according to all attributes.
|
||||
# @return [Integer] Hash code
|
||||
def hash
|
||||
[just_number].hash
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def self.build_from_hash(attributes)
|
||||
new.build_from_hash(attributes)
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def build_from_hash(attributes)
|
||||
return nil unless attributes.is_a?(Hash)
|
||||
self.class.openapi_types.each_pair do |key, type|
|
||||
if type =~ /\AArray<(.*)>/i
|
||||
# check to ensure the input is an array given that the attribute
|
||||
# is documented as an array but the input is not
|
||||
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
||||
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
||||
end
|
||||
elsif !attributes[self.class.attribute_map[key]].nil?
|
||||
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
||||
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
||||
end
|
||||
|
||||
self
|
||||
end
|
||||
|
||||
# Deserializes the data based on type
|
||||
# @param string type Data type
|
||||
# @param string value Value to be deserialized
|
||||
# @return [Object] Deserialized data
|
||||
def _deserialize(type, value)
|
||||
case type.to_sym
|
||||
when :DateTime
|
||||
DateTime.parse(value)
|
||||
when :Date
|
||||
Date.parse(value)
|
||||
when :String
|
||||
value.to_s
|
||||
when :Integer
|
||||
value.to_i
|
||||
when :Float
|
||||
value.to_f
|
||||
when :Boolean
|
||||
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
when :Object
|
||||
# generic object (usually a Hash), return directly
|
||||
value
|
||||
when /\AArray<(?<inner_type>.+)>\z/
|
||||
inner_type = Regexp.last_match[:inner_type]
|
||||
value.map { |v| _deserialize(inner_type, v) }
|
||||
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
||||
k_type = Regexp.last_match[:k_type]
|
||||
v_type = Regexp.last_match[:v_type]
|
||||
{}.tap do |hash|
|
||||
value.each do |k, v|
|
||||
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
||||
end
|
||||
end
|
||||
else # model
|
||||
Petstore.const_get(type).build_from_hash(value)
|
||||
end
|
||||
end
|
||||
|
||||
# Returns the string representation of the object
|
||||
# @return [String] String presentation of the object
|
||||
def to_s
|
||||
to_hash.to_s
|
||||
end
|
||||
|
||||
# to_body is an alias to to_hash (backward compatibility)
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_body
|
||||
to_hash
|
||||
end
|
||||
|
||||
# Returns the object in the form of hash
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_hash
|
||||
hash = {}
|
||||
self.class.attribute_map.each_pair do |attr, param|
|
||||
value = self.send(attr)
|
||||
next if value.nil?
|
||||
hash[param] = _to_hash(value)
|
||||
end
|
||||
hash
|
||||
end
|
||||
|
||||
# Outputs non-array value in the form of hash
|
||||
# For object, use to_hash. Otherwise, just return the value
|
||||
# @param [Object] value Any valid value
|
||||
# @return [Hash] Returns the value in the form of hash
|
||||
def _to_hash(value)
|
||||
if value.is_a?(Array)
|
||||
value.compact.map { |v| _to_hash(v) }
|
||||
elsif value.is_a?(Hash)
|
||||
{}.tap do |hash|
|
||||
value.each { |k, v| hash[k] = _to_hash(v) }
|
||||
end
|
||||
elsif value.respond_to? :to_hash
|
||||
value.to_hash
|
||||
else
|
||||
value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
278
samples/client/petstore/ruby/lib/petstore/models/order.rb
Normal file
278
samples/client/petstore/ruby/lib/petstore/models/order.rb
Normal file
@ -0,0 +1,278 @@
|
||||
=begin
|
||||
#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: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
Generated by: https://openapi-generator.tech
|
||||
OpenAPI Generator version: 4.2.0-SNAPSHOT
|
||||
|
||||
=end
|
||||
|
||||
require 'date'
|
||||
|
||||
module Petstore
|
||||
class Order
|
||||
attr_accessor :id
|
||||
|
||||
attr_accessor :pet_id
|
||||
|
||||
attr_accessor :quantity
|
||||
|
||||
attr_accessor :ship_date
|
||||
|
||||
# Order Status
|
||||
attr_accessor :status
|
||||
|
||||
attr_accessor :complete
|
||||
|
||||
class EnumAttributeValidator
|
||||
attr_reader :datatype
|
||||
attr_reader :allowable_values
|
||||
|
||||
def initialize(datatype, allowable_values)
|
||||
@allowable_values = allowable_values.map do |value|
|
||||
case datatype.to_s
|
||||
when /Integer/i
|
||||
value.to_i
|
||||
when /Float/i
|
||||
value.to_f
|
||||
else
|
||||
value
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def valid?(value)
|
||||
!value || allowable_values.include?(value)
|
||||
end
|
||||
end
|
||||
|
||||
# Attribute mapping from ruby-style variable name to JSON key.
|
||||
def self.attribute_map
|
||||
{
|
||||
:'id' => :'id',
|
||||
:'pet_id' => :'petId',
|
||||
:'quantity' => :'quantity',
|
||||
:'ship_date' => :'shipDate',
|
||||
:'status' => :'status',
|
||||
:'complete' => :'complete'
|
||||
}
|
||||
end
|
||||
|
||||
# Attribute type mapping.
|
||||
def self.openapi_types
|
||||
{
|
||||
:'id' => :'Integer',
|
||||
:'pet_id' => :'Integer',
|
||||
:'quantity' => :'Integer',
|
||||
:'ship_date' => :'DateTime',
|
||||
:'status' => :'String',
|
||||
:'complete' => :'Boolean'
|
||||
}
|
||||
end
|
||||
|
||||
# Initializes the object
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
def initialize(attributes = {})
|
||||
if (!attributes.is_a?(Hash))
|
||||
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::Order` initialize method"
|
||||
end
|
||||
|
||||
# check to see if the attribute exists and convert string to symbol for hash key
|
||||
attributes = attributes.each_with_object({}) { |(k, v), h|
|
||||
if (!self.class.attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::Order`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
||||
end
|
||||
h[k.to_sym] = v
|
||||
}
|
||||
|
||||
if attributes.key?(:'id')
|
||||
self.id = attributes[:'id']
|
||||
end
|
||||
|
||||
if attributes.key?(:'pet_id')
|
||||
self.pet_id = attributes[:'pet_id']
|
||||
end
|
||||
|
||||
if attributes.key?(:'quantity')
|
||||
self.quantity = attributes[:'quantity']
|
||||
end
|
||||
|
||||
if attributes.key?(:'ship_date')
|
||||
self.ship_date = attributes[:'ship_date']
|
||||
end
|
||||
|
||||
if attributes.key?(:'status')
|
||||
self.status = attributes[:'status']
|
||||
end
|
||||
|
||||
if attributes.key?(:'complete')
|
||||
self.complete = attributes[:'complete']
|
||||
else
|
||||
self.complete = false
|
||||
end
|
||||
end
|
||||
|
||||
# Show invalid properties with the reasons. Usually used together with valid?
|
||||
# @return Array for valid properties with the reasons
|
||||
def list_invalid_properties
|
||||
invalid_properties = Array.new
|
||||
invalid_properties
|
||||
end
|
||||
|
||||
# Check to see if the all the properties in the model are valid
|
||||
# @return true if the model is valid
|
||||
def valid?
|
||||
status_validator = EnumAttributeValidator.new('String', ["placed", "approved", "delivered"])
|
||||
return false unless status_validator.valid?(@status)
|
||||
true
|
||||
end
|
||||
|
||||
# Custom attribute writer method checking allowed values (enum).
|
||||
# @param [Object] status Object to be assigned
|
||||
def status=(status)
|
||||
validator = EnumAttributeValidator.new('String', ["placed", "approved", "delivered"])
|
||||
unless validator.valid?(status)
|
||||
fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}."
|
||||
end
|
||||
@status = status
|
||||
end
|
||||
|
||||
# Checks equality by comparing each attribute.
|
||||
# @param [Object] Object to be compared
|
||||
def ==(o)
|
||||
return true if self.equal?(o)
|
||||
self.class == o.class &&
|
||||
id == o.id &&
|
||||
pet_id == o.pet_id &&
|
||||
quantity == o.quantity &&
|
||||
ship_date == o.ship_date &&
|
||||
status == o.status &&
|
||||
complete == o.complete
|
||||
end
|
||||
|
||||
# @see the `==` method
|
||||
# @param [Object] Object to be compared
|
||||
def eql?(o)
|
||||
self == o
|
||||
end
|
||||
|
||||
# Calculates hash code according to all attributes.
|
||||
# @return [Integer] Hash code
|
||||
def hash
|
||||
[id, pet_id, quantity, ship_date, status, complete].hash
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def self.build_from_hash(attributes)
|
||||
new.build_from_hash(attributes)
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def build_from_hash(attributes)
|
||||
return nil unless attributes.is_a?(Hash)
|
||||
self.class.openapi_types.each_pair do |key, type|
|
||||
if type =~ /\AArray<(.*)>/i
|
||||
# check to ensure the input is an array given that the attribute
|
||||
# is documented as an array but the input is not
|
||||
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
||||
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
||||
end
|
||||
elsif !attributes[self.class.attribute_map[key]].nil?
|
||||
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
||||
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
||||
end
|
||||
|
||||
self
|
||||
end
|
||||
|
||||
# Deserializes the data based on type
|
||||
# @param string type Data type
|
||||
# @param string value Value to be deserialized
|
||||
# @return [Object] Deserialized data
|
||||
def _deserialize(type, value)
|
||||
case type.to_sym
|
||||
when :DateTime
|
||||
DateTime.parse(value)
|
||||
when :Date
|
||||
Date.parse(value)
|
||||
when :String
|
||||
value.to_s
|
||||
when :Integer
|
||||
value.to_i
|
||||
when :Float
|
||||
value.to_f
|
||||
when :Boolean
|
||||
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
when :Object
|
||||
# generic object (usually a Hash), return directly
|
||||
value
|
||||
when /\AArray<(?<inner_type>.+)>\z/
|
||||
inner_type = Regexp.last_match[:inner_type]
|
||||
value.map { |v| _deserialize(inner_type, v) }
|
||||
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
||||
k_type = Regexp.last_match[:k_type]
|
||||
v_type = Regexp.last_match[:v_type]
|
||||
{}.tap do |hash|
|
||||
value.each do |k, v|
|
||||
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
||||
end
|
||||
end
|
||||
else # model
|
||||
Petstore.const_get(type).build_from_hash(value)
|
||||
end
|
||||
end
|
||||
|
||||
# Returns the string representation of the object
|
||||
# @return [String] String presentation of the object
|
||||
def to_s
|
||||
to_hash.to_s
|
||||
end
|
||||
|
||||
# to_body is an alias to to_hash (backward compatibility)
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_body
|
||||
to_hash
|
||||
end
|
||||
|
||||
# Returns the object in the form of hash
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_hash
|
||||
hash = {}
|
||||
self.class.attribute_map.each_pair do |attr, param|
|
||||
value = self.send(attr)
|
||||
next if value.nil?
|
||||
hash[param] = _to_hash(value)
|
||||
end
|
||||
hash
|
||||
end
|
||||
|
||||
# Outputs non-array value in the form of hash
|
||||
# For object, use to_hash. Otherwise, just return the value
|
||||
# @param [Object] value Any valid value
|
||||
# @return [Hash] Returns the value in the form of hash
|
||||
def _to_hash(value)
|
||||
if value.is_a?(Array)
|
||||
value.compact.map { |v| _to_hash(v) }
|
||||
elsif value.is_a?(Hash)
|
||||
{}.tap do |hash|
|
||||
value.each { |k, v| hash[k] = _to_hash(v) }
|
||||
end
|
||||
elsif value.respond_to? :to_hash
|
||||
value.to_hash
|
||||
else
|
||||
value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,214 @@
|
||||
=begin
|
||||
#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: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
Generated by: https://openapi-generator.tech
|
||||
OpenAPI Generator version: 4.2.0-SNAPSHOT
|
||||
|
||||
=end
|
||||
|
||||
require 'date'
|
||||
|
||||
module Petstore
|
||||
class OuterComposite
|
||||
attr_accessor :my_number
|
||||
|
||||
attr_accessor :my_string
|
||||
|
||||
attr_accessor :my_boolean
|
||||
|
||||
# Attribute mapping from ruby-style variable name to JSON key.
|
||||
def self.attribute_map
|
||||
{
|
||||
:'my_number' => :'my_number',
|
||||
:'my_string' => :'my_string',
|
||||
:'my_boolean' => :'my_boolean'
|
||||
}
|
||||
end
|
||||
|
||||
# Attribute type mapping.
|
||||
def self.openapi_types
|
||||
{
|
||||
:'my_number' => :'Float',
|
||||
:'my_string' => :'String',
|
||||
:'my_boolean' => :'Boolean'
|
||||
}
|
||||
end
|
||||
|
||||
# Initializes the object
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
def initialize(attributes = {})
|
||||
if (!attributes.is_a?(Hash))
|
||||
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::OuterComposite` initialize method"
|
||||
end
|
||||
|
||||
# check to see if the attribute exists and convert string to symbol for hash key
|
||||
attributes = attributes.each_with_object({}) { |(k, v), h|
|
||||
if (!self.class.attribute_map.key?(k.to_sym))
|
||||
fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::OuterComposite`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
||||
end
|
||||
h[k.to_sym] = v
|
||||
}
|
||||
|
||||
if attributes.key?(:'my_number')
|
||||
self.my_number = attributes[:'my_number']
|
||||
end
|
||||
|
||||
if attributes.key?(:'my_string')
|
||||
self.my_string = attributes[:'my_string']
|
||||
end
|
||||
|
||||
if attributes.key?(:'my_boolean')
|
||||
self.my_boolean = attributes[:'my_boolean']
|
||||
end
|
||||
end
|
||||
|
||||
# Show invalid properties with the reasons. Usually used together with valid?
|
||||
# @return Array for valid properties with the reasons
|
||||
def list_invalid_properties
|
||||
invalid_properties = Array.new
|
||||
invalid_properties
|
||||
end
|
||||
|
||||
# Check to see if the all the properties in the model are valid
|
||||
# @return true if the model is valid
|
||||
def valid?
|
||||
true
|
||||
end
|
||||
|
||||
# Checks equality by comparing each attribute.
|
||||
# @param [Object] Object to be compared
|
||||
def ==(o)
|
||||
return true if self.equal?(o)
|
||||
self.class == o.class &&
|
||||
my_number == o.my_number &&
|
||||
my_string == o.my_string &&
|
||||
my_boolean == o.my_boolean
|
||||
end
|
||||
|
||||
# @see the `==` method
|
||||
# @param [Object] Object to be compared
|
||||
def eql?(o)
|
||||
self == o
|
||||
end
|
||||
|
||||
# Calculates hash code according to all attributes.
|
||||
# @return [Integer] Hash code
|
||||
def hash
|
||||
[my_number, my_string, my_boolean].hash
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def self.build_from_hash(attributes)
|
||||
new.build_from_hash(attributes)
|
||||
end
|
||||
|
||||
# Builds the object from hash
|
||||
# @param [Hash] attributes Model attributes in the form of hash
|
||||
# @return [Object] Returns the model itself
|
||||
def build_from_hash(attributes)
|
||||
return nil unless attributes.is_a?(Hash)
|
||||
self.class.openapi_types.each_pair do |key, type|
|
||||
if type =~ /\AArray<(.*)>/i
|
||||
# check to ensure the input is an array given that the attribute
|
||||
# is documented as an array but the input is not
|
||||
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
||||
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
||||
end
|
||||
elsif !attributes[self.class.attribute_map[key]].nil?
|
||||
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
||||
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
||||
end
|
||||
|
||||
self
|
||||
end
|
||||
|
||||
# Deserializes the data based on type
|
||||
# @param string type Data type
|
||||
# @param string value Value to be deserialized
|
||||
# @return [Object] Deserialized data
|
||||
def _deserialize(type, value)
|
||||
case type.to_sym
|
||||
when :DateTime
|
||||
DateTime.parse(value)
|
||||
when :Date
|
||||
Date.parse(value)
|
||||
when :String
|
||||
value.to_s
|
||||
when :Integer
|
||||
value.to_i
|
||||
when :Float
|
||||
value.to_f
|
||||
when :Boolean
|
||||
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
when :Object
|
||||
# generic object (usually a Hash), return directly
|
||||
value
|
||||
when /\AArray<(?<inner_type>.+)>\z/
|
||||
inner_type = Regexp.last_match[:inner_type]
|
||||
value.map { |v| _deserialize(inner_type, v) }
|
||||
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
||||
k_type = Regexp.last_match[:k_type]
|
||||
v_type = Regexp.last_match[:v_type]
|
||||
{}.tap do |hash|
|
||||
value.each do |k, v|
|
||||
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
||||
end
|
||||
end
|
||||
else # model
|
||||
Petstore.const_get(type).build_from_hash(value)
|
||||
end
|
||||
end
|
||||
|
||||
# Returns the string representation of the object
|
||||
# @return [String] String presentation of the object
|
||||
def to_s
|
||||
to_hash.to_s
|
||||
end
|
||||
|
||||
# to_body is an alias to to_hash (backward compatibility)
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_body
|
||||
to_hash
|
||||
end
|
||||
|
||||
# Returns the object in the form of hash
|
||||
# @return [Hash] Returns the object in the form of hash
|
||||
def to_hash
|
||||
hash = {}
|
||||
self.class.attribute_map.each_pair do |attr, param|
|
||||
value = self.send(attr)
|
||||
next if value.nil?
|
||||
hash[param] = _to_hash(value)
|
||||
end
|
||||
hash
|
||||
end
|
||||
|
||||
# Outputs non-array value in the form of hash
|
||||
# For object, use to_hash. Otherwise, just return the value
|
||||
# @param [Object] value Any valid value
|
||||
# @return [Hash] Returns the value in the form of hash
|
||||
def _to_hash(value)
|
||||
if value.is_a?(Array)
|
||||
value.compact.map { |v| _to_hash(v) }
|
||||
elsif value.is_a?(Hash)
|
||||
{}.tap do |hash|
|
||||
value.each { |k, v| hash[k] = _to_hash(v) }
|
||||
end
|
||||
elsif value.respond_to? :to_hash
|
||||
value.to_hash
|
||||
else
|
||||
value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,37 @@
|
||||
=begin
|
||||
#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: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
|
||||
Generated by: https://openapi-generator.tech
|
||||
OpenAPI Generator version: 4.2.0-SNAPSHOT
|
||||
|
||||
=end
|
||||
|
||||
require 'date'
|
||||
|
||||
module Petstore
|
||||
class OuterEnum
|
||||
PLACED = "placed".freeze
|
||||
APPROVED = "approved".freeze
|
||||
DELIVERED = "delivered".freeze
|
||||
|
||||
# Builds the enum from string
|
||||
# @param [String] The enum value in the form of the string
|
||||
# @return [String] The enum value
|
||||
def self.build_from_hash(value)
|
||||
new.build_from_hash(value)
|
||||
end
|
||||
|
||||
# Builds the enum from string
|
||||
# @param [String] The enum value in the form of the string
|
||||
# @return [String] The enum value
|
||||
def build_from_hash(value)
|
||||
constantValues = OuterEnum.constants.select { |c| OuterEnum::const_get(c) == value }
|
||||
raise "Invalid ENUM value #{value} for class #OuterEnum" if constantValues.empty?
|
||||
value
|
||||
end
|
||||
end
|
||||
end
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user