[Ruby][Faraday] Various improvements (#3520)

* update ruby faraday oas v2 samples

* skip some default tests in faraday

* add ruby faraday oas v3 client

* add tests, fix url

* add tests to CI

* fix file upload

* undo changes to ruby-client-petstore.sh

* test faraday first

* combine gemspec tempaltes

* test ruby faraday in drone.io

* use smaller image

* update bundler

* use official ruby image

* skip bundler installation

* skip autotest

* install make

* use different image

* skip ruby tests in drone.io
This commit is contained in:
William Cheng 2019-08-02 07:00:29 +08:00 committed by GitHub
parent 93ddf6e2ef
commit ca85ecb283
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
330 changed files with 28442 additions and 1432 deletions

View File

@ -0,0 +1,43 @@
#!/bin/sh
SCRIPT="$0"
echo "# START SCRIPT: $SCRIPT"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
fi
# purge lib/doc folder
echo "purge ruby petstore lib, docs folder"
rm -Rf samples/openapi3/client/petstore/ruby-faraday/lib
rm -Rf samples/openapi3/client/petstore/ruby-faraday/docs
# purge test files other than integration test
# NOTE: spec/custom/*.rb and spec/petstore_helper.rb are not generated files
echo "purge ruby petstore spec"
find samples/openapi3/client/petstore/ruby-faraday/spec -type d -not -name spec -not -name custom | xargs rm -Rf
find samples/openapi3/client/petstore/ruby-faraday/spec -type f -not -name petstore_helper.rb -not -iwholename '*/spec/custom/*' | xargs rm -Rf
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate -t modules/openapi-generator/src/main/resources/ruby-client -i modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml -g ruby -c bin/openapi3/ruby-petstore-faraday.json -o samples/openapi3/client/petstore/ruby-faraday --additional-properties skipFormModel=true $@"
java $JAVA_OPTS -jar $executable $ags

View File

@ -0,0 +1,6 @@
{
"gemName": "petstore",
"moduleName": "Petstore",
"library": "faraday",
"gemVersion": "1.0.0"
}

View File

@ -1,5 +1,6 @@
{
"gemName": "petstore",
"moduleName": "Petstore",
"library": "faraday",
"gemVersion": "1.0.0"
}

View File

@ -232,14 +232,14 @@ public class RubyClientCodegen extends AbstractRubyCodegen {
supportingFiles.add(new SupportingFile("Gemfile.mustache", "", "Gemfile"));
supportingFiles.add(new SupportingFile("rubocop.mustache", "", ".rubocop.yml"));
supportingFiles.add(new SupportingFile("travis.mustache", "", ".travis.yml"));
supportingFiles.add(new SupportingFile("gemspec.mustache", "", gemName + ".gemspec"));
if (TYPHOEUS.equals(getLibrary())) {
supportingFiles.add(new SupportingFile("api_client.mustache", gemFolder, "api_client.rb"));
supportingFiles.add(new SupportingFile("gemspec.mustache", "", gemName + ".gemspec"));
supportingFiles.add(new SupportingFile("Gemfile.lock.mustache", "", "Gemfile.lock"));
} else if (FARADAY.equals(getLibrary())) {
supportingFiles.add(new SupportingFile("faraday_api_client.mustache", gemFolder, "api_client.rb"));
supportingFiles.add(new SupportingFile("faraday_gemspec.mustache", "", gemName + ".gemspec"));
additionalProperties.put("isFaraday", Boolean.TRUE);
} else {
throw new RuntimeException("Invalid HTTP library " + getLibrary() + ". Only faraday, typhoeus are supported.");
}

View File

@ -43,6 +43,7 @@ describe {{moduleName}}::ApiClient do
end
end
{{^isFaraday}}
describe 'params_encoding in #build_request' do
let(:config) { {{moduleName}}::Configuration.new }
let(:api_client) { {{moduleName}}::ApiClient.new(config) }
@ -81,6 +82,7 @@ describe {{moduleName}}::ApiClient do
end
end
{{/isFaraday}}
describe '#deserialize' do
it "handles Array<Integer>" do
api_client = {{moduleName}}::ApiClient.new

View File

@ -41,34 +41,34 @@ module {{moduleName}}
connection = Faraday.new(:url => config.base_url) do |conn|
conn.basic_auth(config.username, config.password)
if opts[:header_params]["Content-Type"] == "multipart/form-data"
conn.request :multipart
conn.request :url_encoded
conn.request :multipart
conn.request :url_encoded
end
conn.adapter(Faraday.default_adapter)
end
begin
response = connection.public_send(http_method.to_sym.downcase) do |req|
build_request(http_method, path, req, opts)
end
response = connection.public_send(http_method.to_sym.downcase) do |req|
build_request(http_method, path, req, opts)
end
if @config.debugging
@config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
end
if @config.debugging
@config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
end
unless response.success?
if response.status == 0
# Errors from libcurl will be made visible here
fail ApiError.new(:code => 0,
:message => response.return_message)
else
fail ApiError.new(:code => response.status,
:response_headers => response.headers,
:response_body => response.body),
response.reason_phrase
end
unless response.success?
if response.status == 0
# Errors from libcurl will be made visible here
fail ApiError.new(:code => 0,
:message => response.return_message)
else
fail ApiError.new(:code => response.status,
:response_headers => response.headers,
:response_body => response.body),
response.reason_phrase
end
end
rescue Faraday::TimeoutError
fail ApiError.new('Connection timed out')
fail ApiError.new('Connection timed out')
end
if opts[:return_type]
@ -126,7 +126,7 @@ module {{moduleName}}
end
request.headers = header_params
request.body = req_body
request.url path
request.url url
request.params = query_params
download_file(request) if opts[:return_type] == 'File'
request
@ -277,13 +277,15 @@ module {{moduleName}}
# @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'
if header_params['Content-Type'] == 'application/x-www-form-urlencoded'
data = URI.encode_www_form(form_params)
elsif header_params['Content-Type'] == 'multipart/form-data'
data = {}
form_params.each do |key, value|
case value
when ::File, ::Tempfile
data[key] = Faraday::UploadIO.new(value.path, '')
# TODO hardcode to application/octet-stream, need better way to detect content type
data[key] = Faraday::UploadIO.new(value.path, 'application/octet-stream', value.path)
when ::Array, nil
# let Faraday handle Array and nil parameters
data[key] = value

View File

@ -1,38 +0,0 @@
# -*- encoding: utf-8 -*-
=begin
{{> api_info}}
=end
$:.push File.expand_path("../lib", __FILE__)
require "{{gemName}}/version"
Gem::Specification.new do |s|
s.name = "{{gemName}}{{^gemName}}{{{appName}}}{{/gemName}}"
s.version = {{moduleName}}::VERSION
s.platform = Gem::Platform::RUBY
s.authors = ["{{gemAuthor}}{{^gemAuthor}}OpenAPI-Generator{{/gemAuthor}}"]
s.email = ["{{gemAuthorEmail}}{{^gemAuthorEmail}}{{infoEmail}}{{/gemAuthorEmail}}"]
s.homepage = "{{gemHomepage}}{{^gemHomepage}}https://openapi-generator.tech{{/gemHomepage}}"
s.summary = "{{gemSummary}}{{^gemSummary}}{{{appName}}} Ruby Gem{{/gemSummary}}"
s.description = "{{gemDescription}}{{^gemDescription}}{{{appDescription}}}{{^appDescription}}{{{appName}}} Ruby Gem{{/appDescription}}{{/gemDescription}}"
{{#gemLicense}}
s.license = '{{{gemLicense}}}'
{{/gemLicense}}
{{^gemLicense}}
s.license = "Unlicense"
{{/gemLicense}}
s.required_ruby_version = "{{{gemRequiredRubyVersion}}}{{^gemRequiredRubyVersion}}>= 1.9{{/gemRequiredRubyVersion}}"
s.add_runtime_dependency 'faraday', '>= 0.14.0'
s.add_runtime_dependency 'json', '~> 2.1', '>= 2.1.0'
s.add_development_dependency 'rspec', '~> 3.6', '>= 3.6.0'
s.add_development_dependency 'vcr', '~> 3.0', '>= 3.0.1'
s.add_development_dependency 'webmock', '~> 1.24', '>= 1.24.3'
s.files = `find *`.split("\n").uniq.sort.select { |f| !f.empty? }
s.test_files = `find spec/*`.split("\n")
s.executables = []
s.require_paths = ["lib"]
end

View File

@ -24,7 +24,12 @@ Gem::Specification.new do |s|
{{/gemLicense}}
s.required_ruby_version = "{{{gemRequiredRubyVersion}}}{{^gemRequiredRubyVersion}}>= 1.9{{/gemRequiredRubyVersion}}"
{{#isFaraday}}
s.add_runtime_dependency 'faraday', '>= 0.14.0'
{{/isFaraday}}
{{^isFaraday}}
s.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1'
{{/isFaraday}}
s.add_runtime_dependency 'json', '~> 2.1', '>= 2.1.0'
s.add_development_dependency 'rspec', '~> 3.6', '>= 3.6.0'

View File

@ -1 +1 @@
3.3.3-SNAPSHOT
4.1.0-SNAPSHOT

View File

@ -1,7 +1,7 @@
# This file is based on https://github.com/rails/rails/blob/master/.rubocop.yml (MIT license)
# Automatically generated by OpenAPI Generator (https://openapi-generator.tech)
AllCops:
TargetRubyVersion: 2.2
TargetRubyVersion: 2.4
# RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
# to ignore them, so only the ones explicitly set in this file are enabled.
DisabledByDefault: true
@ -46,7 +46,7 @@ Layout/EmptyLinesAroundMethodBody:
Layout/EmptyLinesAroundModuleBody:
Enabled: true
Layout/FirstParameterIndentation:
Layout/IndentFirstArgument:
Enabled: true
# Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.

View File

@ -0,0 +1,11 @@
language: ruby
cache: bundler
rvm:
- 2.3
- 2.4
- 2.5
script:
- bundle install --path vendor/bundle
- bundle exec rspec
- gem build petstore.gemspec
- gem install ./petstore-1.0.0.gem

View File

@ -5,4 +5,5 @@ gemspec
group :development, :test do
gem 'rake', '~> 12.0.0'
gem 'pry-byebug'
gem 'rubocop', '~> 0.66.0'
end

View File

@ -25,6 +25,7 @@ Then either install the gem locally:
```shell
gem install ./petstore-1.0.0.gem
```
(for development, run `gem install --dev ./petstore-1.0.0.gem` to install the development dependencies)
or publish the gem to a gem hosting service, e.g. [RubyGems](https://rubygems.org/).
@ -50,16 +51,17 @@ ruby -Ilib script.rb
## Getting Started
Please follow the [installation](#installation) procedure and then run the following code:
```ruby
# Load the gem
require 'petstore'
api_instance = Petstore::AnotherFakeApi.new
client = Petstore::Client.new # Client | client model
body = Petstore::Client.new # Client | client model
begin
#To test special tags
result = api_instance.call_123_test_special_tags(client)
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}"
@ -74,6 +76,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*
Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*Petstore::AnotherFakeApi* | [**call_123_test_special_tags**](docs/AnotherFakeApi.md#call_123_test_special_tags) | **PATCH** /another-fake/dummy | To test special tags
*Petstore::FakeApi* | [**create_xml_item**](docs/FakeApi.md#create_xml_item) | **POST** /fake/create_xml_item | creates an XmlItem
*Petstore::FakeApi* | [**fake_outer_boolean_serialize**](docs/FakeApi.md#fake_outer_boolean_serialize) | **POST** /fake/outer/boolean |
*Petstore::FakeApi* | [**fake_outer_composite_serialize**](docs/FakeApi.md#fake_outer_composite_serialize) | **POST** /fake/outer/composite |
*Petstore::FakeApi* | [**fake_outer_number_serialize**](docs/FakeApi.md#fake_outer_number_serialize) | **POST** /fake/outer/number |
@ -112,19 +115,27 @@ Class | Method | HTTP request | Description
## Documentation for Models
- [Petstore::AdditionalPropertiesAnyType](docs/AdditionalPropertiesAnyType.md)
- [Petstore::AdditionalPropertiesArray](docs/AdditionalPropertiesArray.md)
- [Petstore::AdditionalPropertiesBoolean](docs/AdditionalPropertiesBoolean.md)
- [Petstore::AdditionalPropertiesClass](docs/AdditionalPropertiesClass.md)
- [Petstore::AdditionalPropertiesInteger](docs/AdditionalPropertiesInteger.md)
- [Petstore::AdditionalPropertiesNumber](docs/AdditionalPropertiesNumber.md)
- [Petstore::AdditionalPropertiesObject](docs/AdditionalPropertiesObject.md)
- [Petstore::AdditionalPropertiesString](docs/AdditionalPropertiesString.md)
- [Petstore::Animal](docs/Animal.md)
- [Petstore::AnimalFarm](docs/AnimalFarm.md)
- [Petstore::ApiResponse](docs/ApiResponse.md)
- [Petstore::ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md)
- [Petstore::ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md)
- [Petstore::ArrayTest](docs/ArrayTest.md)
- [Petstore::Capitalization](docs/Capitalization.md)
- [Petstore::Cat](docs/Cat.md)
- [Petstore::CatAllOf](docs/CatAllOf.md)
- [Petstore::Category](docs/Category.md)
- [Petstore::ClassModel](docs/ClassModel.md)
- [Petstore::Client](docs/Client.md)
- [Petstore::Dog](docs/Dog.md)
- [Petstore::DogAllOf](docs/DogAllOf.md)
- [Petstore::EnumArrays](docs/EnumArrays.md)
- [Petstore::EnumClass](docs/EnumClass.md)
- [Petstore::EnumTest](docs/EnumTest.md)
@ -145,9 +156,11 @@ Class | Method | HTTP request | Description
- [Petstore::Pet](docs/Pet.md)
- [Petstore::ReadOnlyFirst](docs/ReadOnlyFirst.md)
- [Petstore::SpecialModelName](docs/SpecialModelName.md)
- [Petstore::StringBooleanMap](docs/StringBooleanMap.md)
- [Petstore::Tag](docs/Tag.md)
- [Petstore::TypeHolderDefault](docs/TypeHolderDefault.md)
- [Petstore::TypeHolderExample](docs/TypeHolderExample.md)
- [Petstore::User](docs/User.md)
- [Petstore::XmlItem](docs/XmlItem.md)
## Documentation for Authorization
@ -155,12 +168,14 @@ Class | Method | HTTP request | Description
### api_key
- **Type**: API key
- **API key parameter name**: api_key
- **Location**: HTTP header
### api_key_query
- **Type**: API key
- **API key parameter name**: api_key_query
- **Location**: URL query string
@ -171,6 +186,7 @@ Class | Method | HTTP request | Description
### petstore_auth
- **Type**: OAuth
- **Flow**: implicit
- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog

View File

@ -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)
```

View File

@ -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)
```

View File

@ -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)
```

View File

@ -1,9 +1,37 @@
# Petstore::AdditionalPropertiesClass
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**map_property** | **Hash&lt;String, String&gt;** | | [optional]
**map_of_map_property** | **Hash&lt;String, Hash&lt;String, String&gt;&gt;** | | [optional]
**map_string** | **Hash&lt;String, String&gt;** | | [optional]
**map_number** | **Hash&lt;String, Float&gt;** | | [optional]
**map_integer** | **Hash&lt;String, Integer&gt;** | | [optional]
**map_boolean** | **Hash&lt;String, Boolean&gt;** | | [optional]
**map_array_integer** | **Hash&lt;String, Array&lt;Integer&gt;&gt;** | | [optional]
**map_array_anytype** | **Hash&lt;String, Array&lt;Object&gt;&gt;** | | [optional]
**map_map_string** | **Hash&lt;String, Hash&lt;String, String&gt;&gt;** | | [optional]
**map_map_anytype** | **Hash&lt;String, Hash&lt;String, Object&gt;&gt;** | | [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)
```

View File

@ -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)
```

View File

@ -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)
```

View File

@ -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)
```

View File

@ -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)
```

View File

@ -1,9 +1,19 @@
# Petstore::Animal
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**class_name** | **String** | |
**color** | **String** | | [optional] [default to &#39;red&#39;]
## Code Sample
```ruby
require 'Petstore'
instance = Petstore::Animal.new(class_name: null,
color: null)
```

View File

@ -7,24 +7,27 @@ 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(client)
## 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
client = Petstore::Client.new # Client | client model
body = Petstore::Client.new # Client | client model
begin
#To test special tags
result = api_instance.call_123_test_special_tags(client)
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}"
@ -33,9 +36,10 @@ end
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**client** | [**Client**](Client.md)| client model |
**body** | [**Client**](Client.md)| client model |
### Return type
@ -47,8 +51,6 @@ No authorization required
### HTTP request headers
- **Content-Type**: application/json
- **Accept**: application/json
- **Content-Type**: application/json
- **Accept**: application/json

View File

@ -1,10 +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)
```

View File

@ -1,8 +1,17 @@
# Petstore::ArrayOfArrayOfNumberOnly
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**array_array_number** | **Array&lt;Array&lt;Float&gt;&gt;** | | [optional]
## Code Sample
```ruby
require 'Petstore'
instance = Petstore::ArrayOfArrayOfNumberOnly.new(array_array_number: null)
```

View File

@ -1,8 +1,17 @@
# Petstore::ArrayOfNumberOnly
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**array_number** | **Array&lt;Float&gt;** | | [optional]
## Code Sample
```ruby
require 'Petstore'
instance = Petstore::ArrayOfNumberOnly.new(array_number: null)
```

View File

@ -1,10 +1,21 @@
# Petstore::ArrayTest
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**array_of_string** | **Array&lt;String&gt;** | | [optional]
**array_array_of_integer** | **Array&lt;Array&lt;Integer&gt;&gt;** | | [optional]
**array_array_of_model** | **Array&lt;Array&lt;ReadOnlyFirst&gt;&gt;** | | [optional]
## Code Sample
```ruby
require 'Petstore'
instance = Petstore::ArrayTest.new(array_of_string: null,
array_array_of_integer: null,
array_array_of_model: null)
```

View File

@ -1,6 +1,7 @@
# Petstore::Capitalization
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**small_camel** | **String** | | [optional]
@ -10,4 +11,17 @@ Name | Type | Description | Notes
**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)
```

View File

@ -1,10 +1,17 @@
# Petstore::Cat
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**class_name** | **String** | |
**color** | **String** | | [optional] [default to &#39;red&#39;]
**declawed** | **BOOLEAN** | | [optional]
**declawed** | **Boolean** | | [optional]
## Code Sample
```ruby
require 'Petstore'
instance = Petstore::Cat.new(declawed: null)
```

View 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)
```

View File

@ -1,9 +1,19 @@
# Petstore::Category
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **Integer** | | [optional]
**name** | **String** | | [default to &#39;default-name&#39;]
## Code Sample
```ruby
require 'Petstore'
instance = Petstore::Category.new(id: null,
name: null)
```

View File

@ -1,8 +1,17 @@
# Petstore::ClassModel
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**_class** | **String** | | [optional]
## Code Sample
```ruby
require 'Petstore'
instance = Petstore::ClassModel.new(_class: null)
```

View File

@ -1,8 +1,17 @@
# Petstore::Client
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**client** | **String** | | [optional]
## Code Sample
```ruby
require 'Petstore'
instance = Petstore::Client.new(client: null)
```

View File

@ -1,10 +1,17 @@
# Petstore::Dog
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**class_name** | **String** | |
**color** | **String** | | [optional] [default to &#39;red&#39;]
**breed** | **String** | | [optional]
## Code Sample
```ruby
require 'Petstore'
instance = Petstore::Dog.new(breed: null)
```

View 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)
```

View File

@ -1,9 +1,19 @@
# Petstore::EnumArrays
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**just_symbol** | **String** | | [optional]
**array_enum** | **Array&lt;String&gt;** | | [optional]
## Code Sample
```ruby
require 'Petstore'
instance = Petstore::EnumArrays.new(just_symbol: null,
array_enum: null)
```

View File

@ -1,7 +1,16 @@
# Petstore::EnumClass
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
## Code Sample
```ruby
require 'Petstore'
instance = Petstore::EnumClass.new()
```

View File

@ -1,6 +1,7 @@
# Petstore::EnumTest
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**enum_string** | **String** | | [optional]
@ -9,4 +10,16 @@ Name | Type | Description | Notes
**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)
```

View File

@ -4,6 +4,7 @@ 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 |
@ -18,21 +19,70 @@ Method | HTTP request | Description
[**test_json_form_data**](FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data
# **fake_outer_boolean_serialize**
> BOOLEAN fake_outer_boolean_serialize(opts)
## 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
body: true # Boolean | Input boolean as post body
}
begin
@ -45,13 +95,14 @@ end
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**body** | **BOOLEAN**| Input boolean as post body | [optional]
**body** | **Boolean**| Input boolean as post body | [optional]
### Return type
**BOOLEAN**
**Boolean**
### Authorization
@ -59,12 +110,12 @@ No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: */*
- **Content-Type**: Not defined
- **Accept**: */*
## fake_outer_composite_serialize
# **fake_outer_composite_serialize**
> OuterComposite fake_outer_composite_serialize(opts)
@ -72,13 +123,14 @@ No authorization required
Test serialization of object with outer number type
### Example
```ruby
# load the gem
require 'petstore'
api_instance = Petstore::FakeApi.new
opts = {
outer_composite: Petstore::OuterComposite.new # OuterComposite | Input composite as post body
body: Petstore::OuterComposite.new # OuterComposite | Input composite as post body
}
begin
@ -91,9 +143,10 @@ end
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**outer_composite** | [**OuterComposite**](OuterComposite.md)| Input composite as post body | [optional]
**body** | [**OuterComposite**](OuterComposite.md)| Input composite as post body | [optional]
### Return type
@ -105,12 +158,12 @@ No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: */*
- **Content-Type**: Not defined
- **Accept**: */*
## fake_outer_number_serialize
# **fake_outer_number_serialize**
> Float fake_outer_number_serialize(opts)
@ -118,6 +171,7 @@ No authorization required
Test serialization of outer number types
### Example
```ruby
# load the gem
require 'petstore'
@ -137,6 +191,7 @@ end
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**body** | **Float**| Input number as post body | [optional]
@ -151,12 +206,12 @@ No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: */*
- **Content-Type**: Not defined
- **Accept**: */*
## fake_outer_string_serialize
# **fake_outer_string_serialize**
> String fake_outer_string_serialize(opts)
@ -164,6 +219,7 @@ No authorization required
Test serialization of outer string types
### Example
```ruby
# load the gem
require 'petstore'
@ -183,6 +239,7 @@ end
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**body** | **String**| Input string as post body | [optional]
@ -197,28 +254,29 @@ No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: */*
- **Content-Type**: Not defined
- **Accept**: */*
## test_body_with_file_schema
# **test_body_with_file_schema**
> test_body_with_file_schema(file_schema_test_class)
> 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
file_schema_test_class = Petstore::FileSchemaTestClass.new # FileSchemaTestClass |
body = Petstore::FileSchemaTestClass.new # FileSchemaTestClass |
begin
api_instance.test_body_with_file_schema(file_schema_test_class)
api_instance.test_body_with_file_schema(body)
rescue Petstore::ApiError => e
puts "Exception when calling FakeApi->test_body_with_file_schema: #{e}"
end
@ -226,9 +284,10 @@ end
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**file_schema_test_class** | [**FileSchemaTestClass**](FileSchemaTestClass.md)| |
**body** | [**FileSchemaTestClass**](FileSchemaTestClass.md)| |
### Return type
@ -240,27 +299,28 @@ No authorization required
### HTTP request headers
- **Content-Type**: application/json
- **Accept**: Not defined
- **Content-Type**: application/json
- **Accept**: Not defined
## test_body_with_query_params
# **test_body_with_query_params**
> test_body_with_query_params(query, user)
> test_body_with_query_params(query, body)
### Example
```ruby
# load the gem
require 'petstore'
api_instance = Petstore::FakeApi.new
query = 'query_example' # String |
user = Petstore::User.new # User |
body = Petstore::User.new # User |
begin
api_instance.test_body_with_query_params(query, user)
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
@ -268,10 +328,11 @@ end
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**query** | **String**| |
**user** | [**User**](User.md)| |
**body** | [**User**](User.md)| |
### Return type
@ -283,29 +344,30 @@ No authorization required
### HTTP request headers
- **Content-Type**: application/json
- **Accept**: Not defined
- **Content-Type**: application/json
- **Accept**: Not defined
## test_client_model
# **test_client_model**
> Client test_client_model(client)
> 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
client = Petstore::Client.new # Client | client model
body = Petstore::Client.new # Client | client model
begin
#To test \"client\" model
result = api_instance.test_client_model(client)
result = api_instance.test_client_model(body)
p result
rescue Petstore::ApiError => e
puts "Exception when calling FakeApi->test_client_model: #{e}"
@ -314,9 +376,10 @@ end
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**client** | [**Client**](Client.md)| client model |
**body** | [**Client**](Client.md)| client model |
### Return type
@ -328,12 +391,12 @@ No authorization required
### HTTP request headers
- **Content-Type**: application/json
- **Accept**: application/json
- **Content-Type**: application/json
- **Accept**: application/json
## test_endpoint_parameters
# **test_endpoint_parameters**
> test_endpoint_parameters(number, double, pattern_without_delimiter, byte, opts)
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
@ -341,6 +404,7 @@ Fake endpoint for testing various parameters 假端點 偽のエンドポイン
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
### Example
```ruby
# load the gem
require 'petstore'
@ -379,6 +443,7 @@ end
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**number** | **Float**| None |
@ -406,12 +471,12 @@ nil (empty response body)
### HTTP request headers
- **Content-Type**: application/x-www-form-urlencoded
- **Accept**: Not defined
- **Content-Type**: application/x-www-form-urlencoded
- **Accept**: Not defined
## test_enum_parameters
# **test_enum_parameters**
> test_enum_parameters(opts)
To test enum parameters
@ -419,6 +484,7 @@ To test enum parameters
To test enum parameters
### Example
```ruby
# load the gem
require 'petstore'
@ -445,6 +511,7 @@ end
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**enum_header_string_array** | [**Array&lt;String&gt;**](String.md)| Header parameter enum test (string array) | [optional]
@ -466,12 +533,12 @@ No authorization required
### HTTP request headers
- **Content-Type**: application/x-www-form-urlencoded
- **Accept**: Not defined
- **Content-Type**: application/x-www-form-urlencoded
- **Accept**: Not defined
## test_group_parameters
# **test_group_parameters**
> test_group_parameters(required_string_group, required_boolean_group, required_int64_group, opts)
Fake endpoint to test group parameters (optional)
@ -479,17 +546,18 @@ 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_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
boolean_group: true, # Boolean | Boolean in group parameters
int64_group: 56 # Integer | Integer in group parameters
}
@ -503,13 +571,14 @@ 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_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]
**boolean_group** | **Boolean**| Boolean in group parameters | [optional]
**int64_group** | **Integer**| Integer in group parameters | [optional]
### Return type
@ -522,27 +591,28 @@ No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: Not defined
- **Content-Type**: Not defined
- **Accept**: Not defined
## test_inline_additional_properties
# **test_inline_additional_properties**
> test_inline_additional_properties(request_body)
> test_inline_additional_properties(param)
test inline additionalProperties
### Example
```ruby
# load the gem
require 'petstore'
api_instance = Petstore::FakeApi.new
request_body = {'key' => 'request_body_example'} # Hash<String, String> | request body
param = {'key' => 'param_example'} # Hash<String, String> | request body
begin
#test inline additionalProperties
api_instance.test_inline_additional_properties(request_body)
api_instance.test_inline_additional_properties(param)
rescue Petstore::ApiError => e
puts "Exception when calling FakeApi->test_inline_additional_properties: #{e}"
end
@ -550,9 +620,10 @@ end
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**request_body** | [**Hash&lt;String, String&gt;**](String.md)| request body |
**param** | [**Hash&lt;String, String&gt;**](String.md)| request body |
### Return type
@ -564,17 +635,18 @@ No authorization required
### HTTP request headers
- **Content-Type**: application/json
- **Accept**: Not defined
- **Content-Type**: application/json
- **Accept**: Not defined
## test_json_form_data
# **test_json_form_data**
> test_json_form_data(param, param2)
test json serialization of form data
### Example
```ruby
# load the gem
require 'petstore'
@ -593,6 +665,7 @@ end
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**param** | **String**| field1 |
@ -608,8 +681,6 @@ No authorization required
### HTTP request headers
- **Content-Type**: application/x-www-form-urlencoded
- **Accept**: Not defined
- **Content-Type**: application/x-www-form-urlencoded
- **Accept**: Not defined

View File

@ -7,14 +7,17 @@ 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(client)
## 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'
@ -27,11 +30,11 @@ Petstore.configure do |config|
end
api_instance = Petstore::FakeClassnameTags123Api.new
client = Petstore::Client.new # Client | client model
body = Petstore::Client.new # Client | client model
begin
#To test class name in snake case
result = api_instance.test_classname(client)
result = api_instance.test_classname(body)
p result
rescue Petstore::ApiError => e
puts "Exception when calling FakeClassnameTags123Api->test_classname: #{e}"
@ -40,9 +43,10 @@ end
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**client** | [**Client**](Client.md)| client model |
**body** | [**Client**](Client.md)| client model |
### Return type
@ -54,8 +58,6 @@ Name | Type | Description | Notes
### HTTP request headers
- **Content-Type**: application/json
- **Accept**: application/json
- **Content-Type**: application/json
- **Accept**: application/json

View File

@ -1,8 +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)
```

View File

@ -1,9 +1,19 @@
# Petstore::FileSchemaTestClass
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**file** | **File** | | [optional]
**files** | **Array&lt;File&gt;** | | [optional]
## Code Sample
```ruby
require 'Petstore'
instance = Petstore::FileSchemaTestClass.new(file: null,
files: null)
```

View File

@ -1,6 +1,7 @@
# Petstore::FormatTest
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**integer** | **Integer** | | [optional]
@ -17,4 +18,24 @@ Name | Type | Description | Notes
**uuid** | **String** | | [optional]
**password** | **String** | |
## 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)
```

View File

@ -1,9 +1,19 @@
# Petstore::HasOnlyReadOnly
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**bar** | **String** | | [optional]
**foo** | **String** | | [optional]
## Code Sample
```ruby
require 'Petstore'
instance = Petstore::HasOnlyReadOnly.new(bar: null,
foo: null)
```

View File

@ -1,8 +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)
```

View File

@ -1,11 +1,23 @@
# Petstore::MapTest
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**map_map_of_string** | **Hash&lt;String, Hash&lt;String, String&gt;&gt;** | | [optional]
**map_of_enum_string** | **Hash&lt;String, String&gt;** | | [optional]
**direct_map** | **Hash&lt;String, BOOLEAN&gt;** | | [optional]
**indirect_map** | **Hash&lt;String, BOOLEAN&gt;** | | [optional]
**direct_map** | **Hash&lt;String, Boolean&gt;** | | [optional]
**indirect_map** | **Hash&lt;String, Boolean&gt;** | | [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)
```

View File

@ -1,10 +1,21 @@
# Petstore::MixedPropertiesAndAdditionalPropertiesClass
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**uuid** | **String** | | [optional]
**date_time** | **DateTime** | | [optional]
**map** | [**Hash&lt;String, Animal&gt;**](Animal.md) | | [optional]
## Code Sample
```ruby
require 'Petstore'
instance = Petstore::MixedPropertiesAndAdditionalPropertiesClass.new(uuid: null,
date_time: null,
map: null)
```

View File

@ -1,9 +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)
```

View File

@ -1,8 +1,17 @@
# Petstore::ModelReturn
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**_return** | **Integer** | | [optional]
## Code Sample
```ruby
require 'Petstore'
instance = Petstore::ModelReturn.new(_return: null)
```

View File

@ -1,6 +1,7 @@
# Petstore::Name
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**name** | **Integer** | |
@ -8,4 +9,15 @@ Name | Type | Description | Notes
**property** | **String** | | [optional]
**_123_number** | **Integer** | | [optional]
## Code Sample
```ruby
require 'Petstore'
instance = Petstore::Name.new(name: null,
snake_case: null,
property: null,
_123_number: null)
```

View File

@ -1,8 +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)
```

View File

@ -1,6 +1,7 @@
# Petstore::Order
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **Integer** | | [optional]
@ -8,6 +9,19 @@ Name | Type | Description | Notes
**quantity** | **Integer** | | [optional]
**ship_date** | **DateTime** | | [optional]
**status** | **String** | Order Status | [optional]
**complete** | **BOOLEAN** | | [optional] [default to false]
**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)
```

View File

@ -1,10 +1,21 @@
# Petstore::OuterComposite
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**my_number** | **Float** | | [optional]
**my_string** | **String** | | [optional]
**my_boolean** | **BOOLEAN** | | [optional]
**my_boolean** | **Boolean** | | [optional]
## Code Sample
```ruby
require 'Petstore'
instance = Petstore::OuterComposite.new(my_number: null,
my_string: null,
my_boolean: null)
```

View File

@ -1,7 +1,16 @@
# Petstore::OuterEnum
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
## Code Sample
```ruby
require 'Petstore'
instance = Petstore::OuterEnum.new()
```

View File

@ -1,6 +1,7 @@
# Petstore::Pet
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **Integer** | | [optional]
@ -10,4 +11,17 @@ Name | Type | Description | Notes
**tags** | [**Array&lt;Tag&gt;**](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)
```

View File

@ -15,12 +15,15 @@ Method | HTTP request | Description
[**upload_file_with_required_file**](PetApi.md#upload_file_with_required_file) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required)
# **add_pet**
> add_pet(pet)
## add_pet
> add_pet(body)
Add a new pet to the store
### Example
```ruby
# load the gem
require 'petstore'
@ -31,11 +34,11 @@ Petstore.configure do |config|
end
api_instance = Petstore::PetApi.new
pet = Petstore::Pet.new # Pet | Pet object that needs to be added to the store
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(pet)
api_instance.add_pet(body)
rescue Petstore::ApiError => e
puts "Exception when calling PetApi->add_pet: #{e}"
end
@ -43,9 +46,10 @@ end
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store |
**body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store |
### Return type
@ -57,17 +61,18 @@ nil (empty response body)
### HTTP request headers
- **Content-Type**: application/json, application/xml
- **Accept**: Not defined
- **Content-Type**: application/json, application/xml
- **Accept**: Not defined
## delete_pet
# **delete_pet**
> delete_pet(pet_id, opts)
Deletes a pet
### Example
```ruby
# load the gem
require 'petstore'
@ -93,6 +98,7 @@ end
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**pet_id** | **Integer**| Pet id to delete |
@ -108,12 +114,12 @@ nil (empty response body)
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: Not defined
- **Content-Type**: Not defined
- **Accept**: Not defined
## find_pets_by_status
# **find_pets_by_status**
> Array&lt;Pet&gt; find_pets_by_status(status)
Finds Pets by status
@ -121,6 +127,7 @@ Finds Pets by status
Multiple status values can be provided with comma separated strings
### Example
```ruby
# load the gem
require 'petstore'
@ -144,6 +151,7 @@ end
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**status** | [**Array&lt;String&gt;**](String.md)| Status values that need to be considered for filter |
@ -158,12 +166,12 @@ Name | Type | Description | Notes
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/xml, application/json
- **Content-Type**: Not defined
- **Accept**: application/xml, application/json
## find_pets_by_tags
# **find_pets_by_tags**
> Array&lt;Pet&gt; find_pets_by_tags(tags)
Finds Pets by tags
@ -171,6 +179,7 @@ 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'
@ -194,6 +203,7 @@ end
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**tags** | [**Array&lt;String&gt;**](String.md)| Tags to filter by |
@ -208,12 +218,12 @@ Name | Type | Description | Notes
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/xml, application/json
- **Content-Type**: Not defined
- **Accept**: application/xml, application/json
## get_pet_by_id
# **get_pet_by_id**
> Pet get_pet_by_id(pet_id)
Find pet by ID
@ -221,6 +231,7 @@ Find pet by ID
Returns a single pet
### Example
```ruby
# load the gem
require 'petstore'
@ -246,6 +257,7 @@ end
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**pet_id** | **Integer**| ID of pet to return |
@ -260,17 +272,18 @@ Name | Type | Description | Notes
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/xml, application/json
- **Content-Type**: Not defined
- **Accept**: application/xml, application/json
## update_pet
# **update_pet**
> update_pet(pet)
> update_pet(body)
Update an existing pet
### Example
```ruby
# load the gem
require 'petstore'
@ -281,11 +294,11 @@ Petstore.configure do |config|
end
api_instance = Petstore::PetApi.new
pet = Petstore::Pet.new # Pet | Pet object that needs to be added to the store
body = Petstore::Pet.new # Pet | Pet object that needs to be added to the store
begin
#Update an existing pet
api_instance.update_pet(pet)
api_instance.update_pet(body)
rescue Petstore::ApiError => e
puts "Exception when calling PetApi->update_pet: #{e}"
end
@ -293,9 +306,10 @@ end
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store |
**body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store |
### Return type
@ -307,17 +321,18 @@ nil (empty response body)
### HTTP request headers
- **Content-Type**: application/json, application/xml
- **Accept**: Not defined
- **Content-Type**: application/json, application/xml
- **Accept**: Not defined
## update_pet_with_form
# **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'
@ -344,6 +359,7 @@ end
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**pet_id** | **Integer**| ID of pet that needs to be updated |
@ -360,17 +376,18 @@ nil (empty response body)
### HTTP request headers
- **Content-Type**: application/x-www-form-urlencoded
- **Accept**: Not defined
- **Content-Type**: application/x-www-form-urlencoded
- **Accept**: Not defined
## upload_file
# **upload_file**
> ApiResponse upload_file(pet_id, opts)
uploads an image
### Example
```ruby
# load the gem
require 'petstore'
@ -398,6 +415,7 @@ end
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**pet_id** | **Integer**| ID of pet to update |
@ -414,17 +432,18 @@ Name | Type | Description | Notes
### HTTP request headers
- **Content-Type**: multipart/form-data
- **Accept**: application/json
- **Content-Type**: multipart/form-data
- **Accept**: application/json
## upload_file_with_required_file
# **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'
@ -452,6 +471,7 @@ end
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**pet_id** | **Integer**| ID of pet to update |
@ -468,8 +488,6 @@ Name | Type | Description | Notes
### HTTP request headers
- **Content-Type**: multipart/form-data
- **Accept**: application/json
- **Content-Type**: multipart/form-data
- **Accept**: application/json

View File

@ -1,9 +1,19 @@
# Petstore::ReadOnlyFirst
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**bar** | **String** | | [optional]
**baz** | **String** | | [optional]
## Code Sample
```ruby
require 'Petstore'
instance = Petstore::ReadOnlyFirst.new(bar: null,
baz: null)
```

View File

@ -1,8 +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)
```

View File

@ -10,7 +10,9 @@ Method | HTTP request | Description
[**place_order**](StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet
# **delete_order**
## delete_order
> delete_order(order_id)
Delete purchase order by ID
@ -18,6 +20,7 @@ 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'
@ -35,6 +38,7 @@ end
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**order_id** | **String**| ID of the order that needs to be deleted |
@ -49,12 +53,12 @@ No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: Not defined
- **Content-Type**: Not defined
- **Accept**: Not defined
## get_inventory
# **get_inventory**
> Hash&lt;String, Integer&gt; get_inventory
Returns pet inventories by status
@ -62,6 +66,7 @@ Returns pet inventories by status
Returns a map of status codes to quantities
### Example
```ruby
# load the gem
require 'petstore'
@ -85,6 +90,7 @@ end
```
### Parameters
This endpoint does not need any parameter.
### Return type
@ -97,12 +103,12 @@ This endpoint does not need any parameter.
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json
- **Content-Type**: Not defined
- **Accept**: application/json
## get_order_by_id
# **get_order_by_id**
> Order get_order_by_id(order_id)
Find purchase order by ID
@ -110,6 +116,7 @@ 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'
@ -128,6 +135,7 @@ end
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**order_id** | **Integer**| ID of pet that needs to be fetched |
@ -142,27 +150,28 @@ No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/xml, application/json
- **Content-Type**: Not defined
- **Accept**: application/xml, application/json
## place_order
# **place_order**
> Order place_order(order)
> Order place_order(body)
Place an order for a pet
### Example
```ruby
# load the gem
require 'petstore'
api_instance = Petstore::StoreApi.new
order = Petstore::Order.new # Order | order placed for purchasing the pet
body = Petstore::Order.new # Order | order placed for purchasing the pet
begin
#Place an order for a pet
result = api_instance.place_order(order)
result = api_instance.place_order(body)
p result
rescue Petstore::ApiError => e
puts "Exception when calling StoreApi->place_order: #{e}"
@ -171,9 +180,10 @@ end
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**order** | [**Order**](Order.md)| order placed for purchasing the pet |
**body** | [**Order**](Order.md)| order placed for purchasing the pet |
### Return type
@ -185,8 +195,6 @@ No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/xml, application/json
- **Content-Type**: Not defined
- **Accept**: application/xml, application/json

View File

@ -1,9 +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)
```

View File

@ -0,0 +1,25 @@
# Petstore::TypeHolderDefault
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**string_item** | **String** | | [default to &#39;what&#39;]
**number_item** | **Float** | |
**integer_item** | **Integer** | |
**bool_item** | **Boolean** | | [default to true]
**array_item** | **Array&lt;Integer&gt;** | |
## Code Sample
```ruby
require 'Petstore'
instance = Petstore::TypeHolderDefault.new(string_item: null,
number_item: null,
integer_item: null,
bool_item: null,
array_item: null)
```

View File

@ -0,0 +1,25 @@
# Petstore::TypeHolderExample
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**string_item** | **String** | |
**number_item** | **Float** | |
**integer_item** | **Integer** | |
**bool_item** | **Boolean** | |
**array_item** | **Array&lt;Integer&gt;** | |
## Code Sample
```ruby
require 'Petstore'
instance = Petstore::TypeHolderExample.new(string_item: what,
number_item: 1.234,
integer_item: -2,
bool_item: true,
array_item: [0, 1, 2, 3])
```

View File

@ -1,6 +1,7 @@
# Petstore::User
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **Integer** | | [optional]
@ -12,4 +13,19 @@ Name | Type | Description | Notes
**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)
```

View File

@ -14,24 +14,27 @@ Method | HTTP request | Description
[**update_user**](UserApi.md#update_user) | **PUT** /user/{username} | Updated user
# **create_user**
> create_user(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
user = Petstore::User.new # User | Created user object
body = Petstore::User.new # User | Created user object
begin
#Create user
api_instance.create_user(user)
api_instance.create_user(body)
rescue Petstore::ApiError => e
puts "Exception when calling UserApi->create_user: #{e}"
end
@ -39,9 +42,10 @@ end
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**user** | [**User**](User.md)| Created user object |
**body** | [**User**](User.md)| Created user object |
### Return type
@ -53,27 +57,28 @@ No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: Not defined
- **Content-Type**: Not defined
- **Accept**: Not defined
## create_users_with_array_input
# **create_users_with_array_input**
> create_users_with_array_input(user)
> 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
user = nil # Array<User> | List of user object
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(user)
api_instance.create_users_with_array_input(body)
rescue Petstore::ApiError => e
puts "Exception when calling UserApi->create_users_with_array_input: #{e}"
end
@ -81,9 +86,10 @@ end
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**user** | [**Array&lt;User&gt;**](Array.md)| List of user object |
**body** | [**Array&lt;User&gt;**](User.md)| List of user object |
### Return type
@ -95,27 +101,28 @@ No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: Not defined
- **Content-Type**: Not defined
- **Accept**: Not defined
## create_users_with_list_input
# **create_users_with_list_input**
> create_users_with_list_input(user)
> 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
user = nil # Array<User> | List of user object
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(user)
api_instance.create_users_with_list_input(body)
rescue Petstore::ApiError => e
puts "Exception when calling UserApi->create_users_with_list_input: #{e}"
end
@ -123,9 +130,10 @@ end
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**user** | [**Array&lt;User&gt;**](Array.md)| List of user object |
**body** | [**Array&lt;User&gt;**](User.md)| List of user object |
### Return type
@ -137,12 +145,12 @@ No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: Not defined
- **Content-Type**: Not defined
- **Accept**: Not defined
## delete_user
# **delete_user**
> delete_user(username)
Delete user
@ -150,6 +158,7 @@ Delete user
This can only be done by the logged in user.
### Example
```ruby
# load the gem
require 'petstore'
@ -167,6 +176,7 @@ end
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**username** | **String**| The name that needs to be deleted |
@ -181,17 +191,18 @@ No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: Not defined
- **Content-Type**: Not defined
- **Accept**: Not defined
## get_user_by_name
# **get_user_by_name**
> User get_user_by_name(username)
Get user by user name
### Example
```ruby
# load the gem
require 'petstore'
@ -210,6 +221,7 @@ end
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**username** | **String**| The name that needs to be fetched. Use user1 for testing. |
@ -224,17 +236,18 @@ No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/xml, application/json
- **Content-Type**: Not defined
- **Accept**: application/xml, application/json
## login_user
# **login_user**
> String login_user(username, password)
Logs user into the system
### Example
```ruby
# load the gem
require 'petstore'
@ -254,6 +267,7 @@ end
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**username** | **String**| The user name for login |
@ -269,17 +283,18 @@ No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/xml, application/json
- **Content-Type**: Not defined
- **Accept**: application/xml, application/json
## logout_user
# **logout_user**
> logout_user
Logs out current logged in user session
### Example
```ruby
# load the gem
require 'petstore'
@ -295,6 +310,7 @@ end
```
### Parameters
This endpoint does not need any parameter.
### Return type
@ -307,30 +323,31 @@ No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: Not defined
- **Content-Type**: Not defined
- **Accept**: Not defined
## update_user
# **update_user**
> update_user(username, 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
user = Petstore::User.new # User | Updated user object
body = Petstore::User.new # User | Updated user object
begin
#Updated user
api_instance.update_user(username, user)
api_instance.update_user(username, body)
rescue Petstore::ApiError => e
puts "Exception when calling UserApi->update_user: #{e}"
end
@ -338,10 +355,11 @@ end
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**username** | **String**| name that need to be deleted |
**user** | [**User**](User.md)| Updated user object |
**body** | [**User**](User.md)| Updated user object |
### Return type
@ -353,8 +371,6 @@ No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: Not defined
- **Content-Type**: Not defined
- **Accept**: Not defined

View 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&lt;Integer&gt;** | | [optional]
**name_string** | **String** | | [optional]
**name_number** | **Float** | | [optional]
**name_integer** | **Integer** | | [optional]
**name_boolean** | **Boolean** | | [optional]
**name_array** | **Array&lt;Integer&gt;** | | [optional]
**name_wrapped_array** | **Array&lt;Integer&gt;** | | [optional]
**prefix_string** | **String** | | [optional]
**prefix_number** | **Float** | | [optional]
**prefix_integer** | **Integer** | | [optional]
**prefix_boolean** | **Boolean** | | [optional]
**prefix_array** | **Array&lt;Integer&gt;** | | [optional]
**prefix_wrapped_array** | **Array&lt;Integer&gt;** | | [optional]
**namespace_string** | **String** | | [optional]
**namespace_number** | **Float** | | [optional]
**namespace_integer** | **Integer** | | [optional]
**namespace_boolean** | **Boolean** | | [optional]
**namespace_array** | **Array&lt;Integer&gt;** | | [optional]
**namespace_wrapped_array** | **Array&lt;Integer&gt;** | | [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&lt;Integer&gt;** | | [optional]
**prefix_ns_wrapped_array** | **Array&lt;Integer&gt;** | | [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)
```

View File

@ -3,10 +3,10 @@
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 3.3.3-SNAPSHOT
OpenAPI Generator version: 4.1.0-SNAPSHOT
=end
@ -17,19 +17,27 @@ 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/animal_farm'
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'
@ -50,9 +58,11 @@ require 'petstore/models/outer_enum'
require 'petstore/models/pet'
require 'petstore/models/read_only_first'
require 'petstore/models/special_model_name'
require 'petstore/models/string_boolean_map'
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'

View File

@ -3,14 +3,14 @@
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 3.3.3-SNAPSHOT
OpenAPI Generator version: 4.1.0-SNAPSHOT
=end
require 'uri'
require 'cgi'
module Petstore
class AnotherFakeApi
@ -21,58 +21,66 @@ module Petstore
end
# To test special tags
# To test special tags and operation ID starting with number
# @param client client model
# @param body [Client] client model
# @param [Hash] opts the optional parameters
# @return [Client]
def call_123_test_special_tags(client, opts = {})
data, _status_code, _headers = call_123_test_special_tags_with_http_info(client, opts)
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 client client model
# @param body [Client] client model
# @param [Hash] opts the optional parameters
# @return [Array<(Client, Fixnum, Hash)>] Client data, response status code and response headers
def call_123_test_special_tags_with_http_info(client, opts = {})
# @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 'client' is set
if @api_client.config.client_side_validation && client.nil?
fail ArgumentError, "Missing the required parameter 'client' when calling AnotherFakeApi.call_123_test_special_tags"
# 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 = {}
query_params = opts[:query_params] || {}
# header parameters
header_params = {}
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 = {}
form_params = opts[:form_params] || {}
# http body (model)
post_body = @api_client.object_to_http_body(client)
auth_names = []
data, status_code, headers = @api_client.call_api(:PATCH, local_var_path,
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 => 'Client')
: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

View File

@ -3,14 +3,14 @@
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 3.3.3-SNAPSHOT
OpenAPI Generator version: 4.1.0-SNAPSHOT
=end
require 'uri'
require 'cgi'
module Petstore
class FakeApi
@ -19,10 +19,72 @@ module Petstore
def initialize(api_client = ApiClient.default)
@api_client = api_client
end
# creates an XmlItem
# this route creates an XmlItem
# @param xml_item [XmlItem] XmlItem Body
# @param [Hash] opts the optional parameters
# @return [nil]
def create_xml_item(xml_item, opts = {})
create_xml_item_with_http_info(xml_item, opts)
nil
end
# creates an XmlItem
# this route creates an XmlItem
# @param xml_item [XmlItem] XmlItem Body
# @param [Hash] opts the optional parameters
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
def create_xml_item_with_http_info(xml_item, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FakeApi.create_xml_item ...'
end
# verify the required parameter 'xml_item' is set
if @api_client.config.client_side_validation && xml_item.nil?
fail ArgumentError, "Missing the required parameter 'xml_item' when calling FakeApi.create_xml_item"
end
# resource path
local_var_path = '/fake/create_xml_item'
# 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/xml', 'application/xml; charset=utf-8', 'application/xml; charset=utf-16', 'text/xml', 'text/xml; charset=utf-8', 'text/xml; charset=utf-16'])
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:body] || @api_client.object_to_http_body(xml_item)
# 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: FakeApi#create_xml_item\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Test serialization of outer boolean types
# @param [Hash] opts the optional parameters
# @option opts [BOOLEAN] :body Input boolean as post body
# @return [BOOLEAN]
# @option opts [Boolean] :body Input boolean as post body
# @return [Boolean]
def fake_outer_boolean_serialize(opts = {})
data, _status_code, _headers = fake_outer_boolean_serialize_with_http_info(opts)
data
@ -30,8 +92,8 @@ module Petstore
# Test serialization of outer boolean types
# @param [Hash] opts the optional parameters
# @option opts [BOOLEAN] :body Input boolean as post body
# @return [Array<(BOOLEAN, Fixnum, Hash)>] BOOLEAN data, response status code and response headers
# @option opts [Boolean] :body Input boolean as post body
# @return [Array<(Boolean, Integer, Hash)>] Boolean data, response status code and response headers
def fake_outer_boolean_serialize_with_http_info(opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FakeApi.fake_outer_boolean_serialize ...'
@ -40,26 +102,35 @@ module Petstore
local_var_path = '/fake/outer/boolean'
# query parameters
query_params = {}
query_params = opts[:query_params] || {}
# header parameters
header_params = {}
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['*/*'])
# form parameters
form_params = {}
form_params = opts[:form_params] || {}
# http body (model)
post_body = @api_client.object_to_http_body(opts[:'body'])
auth_names = []
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
post_body = opts[:body] || @api_client.object_to_http_body(opts[:'body'])
# return_type
return_type = opts[:return_type] || 'Boolean'
# 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 => 'BOOLEAN')
: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: FakeApi#fake_outer_boolean_serialize\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
@ -68,7 +139,7 @@ module Petstore
# Test serialization of object with outer number type
# @param [Hash] opts the optional parameters
# @option opts [OuterComposite] :outer_composite Input composite as post body
# @option opts [OuterComposite] :body Input composite as post body
# @return [OuterComposite]
def fake_outer_composite_serialize(opts = {})
data, _status_code, _headers = fake_outer_composite_serialize_with_http_info(opts)
@ -77,8 +148,8 @@ module Petstore
# Test serialization of object with outer number type
# @param [Hash] opts the optional parameters
# @option opts [OuterComposite] :outer_composite Input composite as post body
# @return [Array<(OuterComposite, Fixnum, Hash)>] OuterComposite data, response status code and response headers
# @option opts [OuterComposite] :body Input composite as post body
# @return [Array<(OuterComposite, Integer, Hash)>] OuterComposite data, response status code and response headers
def fake_outer_composite_serialize_with_http_info(opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FakeApi.fake_outer_composite_serialize ...'
@ -87,26 +158,35 @@ module Petstore
local_var_path = '/fake/outer/composite'
# query parameters
query_params = {}
query_params = opts[:query_params] || {}
# header parameters
header_params = {}
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['*/*'])
# form parameters
form_params = {}
form_params = opts[:form_params] || {}
# http body (model)
post_body = @api_client.object_to_http_body(opts[:'outer_composite'])
auth_names = []
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
post_body = opts[:body] || @api_client.object_to_http_body(opts[:'body'])
# return_type
return_type = opts[:return_type] || 'OuterComposite'
# 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 => 'OuterComposite')
: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: FakeApi#fake_outer_composite_serialize\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
@ -125,7 +205,7 @@ module Petstore
# Test serialization of outer number types
# @param [Hash] opts the optional parameters
# @option opts [Float] :body Input number as post body
# @return [Array<(Float, Fixnum, Hash)>] Float data, response status code and response headers
# @return [Array<(Float, Integer, Hash)>] Float data, response status code and response headers
def fake_outer_number_serialize_with_http_info(opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FakeApi.fake_outer_number_serialize ...'
@ -134,26 +214,35 @@ module Petstore
local_var_path = '/fake/outer/number'
# query parameters
query_params = {}
query_params = opts[:query_params] || {}
# header parameters
header_params = {}
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['*/*'])
# form parameters
form_params = {}
form_params = opts[:form_params] || {}
# http body (model)
post_body = @api_client.object_to_http_body(opts[:'body'])
auth_names = []
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
post_body = opts[:body] || @api_client.object_to_http_body(opts[:'body'])
# return_type
return_type = opts[:return_type] || 'Float'
# 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 => 'Float')
: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: FakeApi#fake_outer_number_serialize\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
@ -172,7 +261,7 @@ module Petstore
# Test serialization of outer string types
# @param [Hash] opts the optional parameters
# @option opts [String] :body Input string as post body
# @return [Array<(String, Fixnum, Hash)>] String data, response status code and response headers
# @return [Array<(String, Integer, Hash)>] String data, response status code and response headers
def fake_outer_string_serialize_with_http_info(opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FakeApi.fake_outer_string_serialize ...'
@ -181,26 +270,35 @@ module Petstore
local_var_path = '/fake/outer/string'
# query parameters
query_params = {}
query_params = opts[:query_params] || {}
# header parameters
header_params = {}
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['*/*'])
# form parameters
form_params = {}
form_params = opts[:form_params] || {}
# http body (model)
post_body = @api_client.object_to_http_body(opts[:'body'])
auth_names = []
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
post_body = opts[:body] || @api_client.object_to_http_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 => 'String')
: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: FakeApi#fake_outer_string_serialize\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
@ -208,69 +306,79 @@ module Petstore
end
# For this test, the body for this request much reference a schema named `File`.
# @param file_schema_test_class
# @param body [FileSchemaTestClass]
# @param [Hash] opts the optional parameters
# @return [nil]
def test_body_with_file_schema(file_schema_test_class, opts = {})
test_body_with_file_schema_with_http_info(file_schema_test_class, opts)
def test_body_with_file_schema(body, opts = {})
test_body_with_file_schema_with_http_info(body, opts)
nil
end
# For this test, the body for this request much reference a schema named &#x60;File&#x60;.
# @param file_schema_test_class
# @param body [FileSchemaTestClass]
# @param [Hash] opts the optional parameters
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def test_body_with_file_schema_with_http_info(file_schema_test_class, opts = {})
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
def test_body_with_file_schema_with_http_info(body, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FakeApi.test_body_with_file_schema ...'
end
# verify the required parameter 'file_schema_test_class' is set
if @api_client.config.client_side_validation && file_schema_test_class.nil?
fail ArgumentError, "Missing the required parameter 'file_schema_test_class' when calling FakeApi.test_body_with_file_schema"
# 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 FakeApi.test_body_with_file_schema"
end
# resource path
local_var_path = '/fake/body-with-file-schema'
# query parameters
query_params = {}
query_params = opts[:query_params] || {}
# header parameters
header_params = {}
header_params = opts[:header_params] || {}
# HTTP header 'Content-Type'
header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
# form parameters
form_params = {}
form_params = opts[:form_params] || {}
# http body (model)
post_body = @api_client.object_to_http_body(file_schema_test_class)
auth_names = []
data, status_code, headers = @api_client.call_api(:PUT, local_var_path,
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)
: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: FakeApi#test_body_with_file_schema\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# @param query
# @param user
# @param query [String]
# @param body [User]
# @param [Hash] opts the optional parameters
# @return [nil]
def test_body_with_query_params(query, user, opts = {})
test_body_with_query_params_with_http_info(query, user, opts)
def test_body_with_query_params(query, body, opts = {})
test_body_with_query_params_with_http_info(query, body, opts)
nil
end
# @param query
# @param user
# @param query [String]
# @param body [User]
# @param [Hash] opts the optional parameters
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def test_body_with_query_params_with_http_info(query, user, opts = {})
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
def test_body_with_query_params_with_http_info(query, body, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FakeApi.test_body_with_query_params ...'
end
@ -278,34 +386,44 @@ module Petstore
if @api_client.config.client_side_validation && query.nil?
fail ArgumentError, "Missing the required parameter 'query' when calling FakeApi.test_body_with_query_params"
end
# verify the required parameter 'user' is set
if @api_client.config.client_side_validation && user.nil?
fail ArgumentError, "Missing the required parameter 'user' when calling FakeApi.test_body_with_query_params"
# 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 FakeApi.test_body_with_query_params"
end
# resource path
local_var_path = '/fake/body-with-query-params'
# query parameters
query_params = {}
query_params = opts[:query_params] || {}
query_params[:'query'] = query
# header parameters
header_params = {}
header_params = opts[:header_params] || {}
# HTTP header 'Content-Type'
header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
# form parameters
form_params = {}
form_params = opts[:form_params] || {}
# http body (model)
post_body = @api_client.object_to_http_body(user)
auth_names = []
data, status_code, headers = @api_client.call_api(:PUT, local_var_path,
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)
: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: FakeApi#test_body_with_query_params\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
@ -314,53 +432,62 @@ module Petstore
# To test \"client\" model
# To test \"client\" model
# @param client client model
# @param body [Client] client model
# @param [Hash] opts the optional parameters
# @return [Client]
def test_client_model(client, opts = {})
data, _status_code, _headers = test_client_model_with_http_info(client, opts)
def test_client_model(body, opts = {})
data, _status_code, _headers = test_client_model_with_http_info(body, opts)
data
end
# To test \&quot;client\&quot; model
# To test \&quot;client\&quot; model
# @param client client model
# @param body [Client] client model
# @param [Hash] opts the optional parameters
# @return [Array<(Client, Fixnum, Hash)>] Client data, response status code and response headers
def test_client_model_with_http_info(client, opts = {})
# @return [Array<(Client, Integer, Hash)>] Client data, response status code and response headers
def test_client_model_with_http_info(body, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FakeApi.test_client_model ...'
end
# verify the required parameter 'client' is set
if @api_client.config.client_side_validation && client.nil?
fail ArgumentError, "Missing the required parameter 'client' when calling FakeApi.test_client_model"
# 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 FakeApi.test_client_model"
end
# resource path
local_var_path = '/fake'
# query parameters
query_params = {}
query_params = opts[:query_params] || {}
# header parameters
header_params = {}
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 = {}
form_params = opts[:form_params] || {}
# http body (model)
post_body = @api_client.object_to_http_body(client)
auth_names = []
data, status_code, headers = @api_client.call_api(:PATCH, local_var_path,
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 => 'Client')
: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: FakeApi#test_client_model\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
@ -369,10 +496,10 @@ module Petstore
# Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
# Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
# @param number None
# @param double None
# @param pattern_without_delimiter None
# @param byte None
# @param number [Float] None
# @param double [Float] None
# @param pattern_without_delimiter [String] None
# @param byte [String] None
# @param [Hash] opts the optional parameters
# @option opts [Integer] :integer None
# @option opts [Integer] :int32 None
@ -392,10 +519,10 @@ module Petstore
# Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
# Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
# @param number None
# @param double None
# @param pattern_without_delimiter None
# @param byte None
# @param number [Float] None
# @param double [Float] None
# @param pattern_without_delimiter [String] None
# @param byte [String] None
# @param [Hash] opts the optional parameters
# @option opts [Integer] :integer None
# @option opts [Integer] :int32 None
@ -407,7 +534,7 @@ module Petstore
# @option opts [DateTime] :date_time None
# @option opts [String] :password None
# @option opts [String] :callback None
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
def test_endpoint_parameters_with_http_info(number, double, pattern_without_delimiter, byte, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FakeApi.test_endpoint_parameters ...'
@ -440,8 +567,9 @@ module Petstore
if @api_client.config.client_side_validation && pattern_without_delimiter.nil?
fail ArgumentError, "Missing the required parameter 'pattern_without_delimiter' when calling FakeApi.test_endpoint_parameters"
end
if @api_client.config.client_side_validation && pattern_without_delimiter !~ Regexp.new(/^[A-Z].*/)
fail ArgumentError, "invalid value for 'pattern_without_delimiter' when calling FakeApi.test_endpoint_parameters, must conform to the pattern /^[A-Z].*/."
pattern = Regexp.new(/^[A-Z].*/)
if @api_client.config.client_side_validation && pattern_without_delimiter !~ pattern
fail ArgumentError, "invalid value for 'pattern_without_delimiter' when calling FakeApi.test_endpoint_parameters, must conform to the pattern #{pattern}."
end
# verify the required parameter 'byte' is set
@ -468,8 +596,9 @@ module Petstore
fail ArgumentError, 'invalid value for "opts[:"float"]" when calling FakeApi.test_endpoint_parameters, must be smaller than or equal to 987.6.'
end
if @api_client.config.client_side_validation && !opts[:'string'].nil? && opts[:'string'] !~ Regexp.new(/[a-z]/i)
fail ArgumentError, "invalid value for 'opts[:\"string\"]' when calling FakeApi.test_endpoint_parameters, must conform to the pattern /[a-z]/i."
pattern = Regexp.new(/[a-z]/i)
if @api_client.config.client_side_validation && !opts[:'string'].nil? && opts[:'string'] !~ pattern
fail ArgumentError, "invalid value for 'opts[:\"string\"]' when calling FakeApi.test_endpoint_parameters, must conform to the pattern #{pattern}."
end
if @api_client.config.client_side_validation && !opts[:'password'].nil? && opts[:'password'].to_s.length > 64
@ -484,15 +613,15 @@ module Petstore
local_var_path = '/fake'
# query parameters
query_params = {}
query_params = opts[:query_params] || {}
# header parameters
header_params = {}
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 = {}
form_params = opts[:form_params] || {}
form_params['number'] = number
form_params['double'] = double
form_params['pattern_without_delimiter'] = pattern_without_delimiter
@ -509,14 +638,24 @@ module Petstore
form_params['callback'] = opts[:'callback'] if !opts[:'callback'].nil?
# http body (model)
post_body = nil
auth_names = ['http_basic_test']
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
post_body = opts[:body]
# return_type
return_type = opts[:return_type]
# auth_names
auth_names = opts[:auth_names] || ['http_basic_test']
new_options = opts.merge(
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names)
: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: FakeApi#test_endpoint_parameters\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
@ -551,66 +690,84 @@ module Petstore
# @option opts [Float] :enum_query_double Query parameter enum test (double)
# @option opts [Array<String>] :enum_form_string_array Form parameter enum test (string array)
# @option opts [String] :enum_form_string Form parameter enum test (string)
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
def test_enum_parameters_with_http_info(opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FakeApi.test_enum_parameters ...'
end
if @api_client.config.client_side_validation && opts[:'enum_header_string_array'] && !opts[:'enum_header_string_array'].all? { |item| ['>', '$'].include?(item) }
fail ArgumentError, 'invalid value for "enum_header_string_array", must include one of >, $'
allowable_values = [">", "$"]
if @api_client.config.client_side_validation && opts[:'enum_header_string_array'] && !opts[:'enum_header_string_array'].all? { |item| allowable_values.include?(item) }
fail ArgumentError, "invalid value for \"enum_header_string_array\", must include one of #{allowable_values}"
end
if @api_client.config.client_side_validation && opts[:'enum_header_string'] && !['_abc', '-efg', '(xyz)'].include?(opts[:'enum_header_string'])
fail ArgumentError, 'invalid value for "enum_header_string", must be one of _abc, -efg, (xyz)'
allowable_values = ["_abc", "-efg", "(xyz)"]
if @api_client.config.client_side_validation && opts[:'enum_header_string'] && !allowable_values.include?(opts[:'enum_header_string'])
fail ArgumentError, "invalid value for \"enum_header_string\", must be one of #{allowable_values}"
end
if @api_client.config.client_side_validation && opts[:'enum_query_string_array'] && !opts[:'enum_query_string_array'].all? { |item| ['>', '$'].include?(item) }
fail ArgumentError, 'invalid value for "enum_query_string_array", must include one of >, $'
allowable_values = [">", "$"]
if @api_client.config.client_side_validation && opts[:'enum_query_string_array'] && !opts[:'enum_query_string_array'].all? { |item| allowable_values.include?(item) }
fail ArgumentError, "invalid value for \"enum_query_string_array\", must include one of #{allowable_values}"
end
if @api_client.config.client_side_validation && opts[:'enum_query_string'] && !['_abc', '-efg', '(xyz)'].include?(opts[:'enum_query_string'])
fail ArgumentError, 'invalid value for "enum_query_string", must be one of _abc, -efg, (xyz)'
allowable_values = ["_abc", "-efg", "(xyz)"]
if @api_client.config.client_side_validation && opts[:'enum_query_string'] && !allowable_values.include?(opts[:'enum_query_string'])
fail ArgumentError, "invalid value for \"enum_query_string\", must be one of #{allowable_values}"
end
if @api_client.config.client_side_validation && opts[:'enum_query_integer'] && !['1', '-2'].include?(opts[:'enum_query_integer'])
fail ArgumentError, 'invalid value for "enum_query_integer", must be one of 1, -2'
allowable_values = [1, -2]
if @api_client.config.client_side_validation && opts[:'enum_query_integer'] && !allowable_values.include?(opts[:'enum_query_integer'])
fail ArgumentError, "invalid value for \"enum_query_integer\", must be one of #{allowable_values}"
end
if @api_client.config.client_side_validation && opts[:'enum_query_double'] && !['1.1', '-1.2'].include?(opts[:'enum_query_double'])
fail ArgumentError, 'invalid value for "enum_query_double", must be one of 1.1, -1.2'
allowable_values = [1.1, -1.2]
if @api_client.config.client_side_validation && opts[:'enum_query_double'] && !allowable_values.include?(opts[:'enum_query_double'])
fail ArgumentError, "invalid value for \"enum_query_double\", must be one of #{allowable_values}"
end
if @api_client.config.client_side_validation && opts[:'enum_form_string_array'] && !opts[:'enum_form_string_array'].all? { |item| ['>', '$'].include?(item) }
fail ArgumentError, 'invalid value for "enum_form_string_array", must include one of >, $'
allowable_values = [">", "$"]
if @api_client.config.client_side_validation && opts[:'enum_form_string_array'] && !opts[:'enum_form_string_array'].all? { |item| allowable_values.include?(item) }
fail ArgumentError, "invalid value for \"enum_form_string_array\", must include one of #{allowable_values}"
end
if @api_client.config.client_side_validation && opts[:'enum_form_string'] && !['_abc', '-efg', '(xyz)'].include?(opts[:'enum_form_string'])
fail ArgumentError, 'invalid value for "enum_form_string", must be one of _abc, -efg, (xyz)'
allowable_values = ["_abc", "-efg", "(xyz)"]
if @api_client.config.client_side_validation && opts[:'enum_form_string'] && !allowable_values.include?(opts[:'enum_form_string'])
fail ArgumentError, "invalid value for \"enum_form_string\", must be one of #{allowable_values}"
end
# resource path
local_var_path = '/fake'
# query parameters
query_params = {}
query_params = opts[:query_params] || {}
query_params[:'enum_query_string_array'] = @api_client.build_collection_param(opts[:'enum_query_string_array'], :csv) if !opts[:'enum_query_string_array'].nil?
query_params[:'enum_query_string'] = opts[:'enum_query_string'] if !opts[:'enum_query_string'].nil?
query_params[:'enum_query_integer'] = opts[:'enum_query_integer'] if !opts[:'enum_query_integer'].nil?
query_params[:'enum_query_double'] = opts[:'enum_query_double'] if !opts[:'enum_query_double'].nil?
# header parameters
header_params = {}
header_params = opts[:header_params] || {}
# HTTP header 'Content-Type'
header_params['Content-Type'] = @api_client.select_header_content_type(['application/x-www-form-urlencoded'])
header_params[:'enum_header_string_array'] = @api_client.build_collection_param(opts[:'enum_header_string_array'], :csv) if !opts[:'enum_header_string_array'].nil?
header_params[:'enum_header_string'] = opts[:'enum_header_string'] if !opts[:'enum_header_string'].nil?
# form parameters
form_params = {}
form_params = opts[:form_params] || {}
form_params['enum_form_string_array'] = @api_client.build_collection_param(opts[:'enum_form_string_array'], :csv) if !opts[:'enum_form_string_array'].nil?
form_params['enum_form_string'] = opts[:'enum_form_string'] if !opts[:'enum_form_string'].nil?
# http body (model)
post_body = nil
auth_names = []
data, status_code, headers = @api_client.call_api(:GET, local_var_path,
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)
: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: FakeApi#test_enum_parameters\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
@ -619,12 +776,12 @@ module Petstore
# Fake endpoint to test group parameters (optional)
# Fake endpoint to test group parameters (optional)
# @param required_string_group Required String in group parameters
# @param required_boolean_group Required Boolean in group parameters
# @param required_int64_group Required Integer in group parameters
# @param required_string_group [Integer] Required String in group parameters
# @param required_boolean_group [Boolean] Required Boolean in group parameters
# @param required_int64_group [Integer] Required Integer in group parameters
# @param [Hash] opts the optional parameters
# @option opts [Integer] :string_group String in group parameters
# @option opts [BOOLEAN] :boolean_group Boolean in group parameters
# @option opts [Boolean] :boolean_group Boolean in group parameters
# @option opts [Integer] :int64_group Integer in group parameters
# @return [nil]
def test_group_parameters(required_string_group, required_boolean_group, required_int64_group, opts = {})
@ -634,14 +791,14 @@ module Petstore
# Fake endpoint to test group parameters (optional)
# Fake endpoint to test group parameters (optional)
# @param required_string_group Required String in group parameters
# @param required_boolean_group Required Boolean in group parameters
# @param required_int64_group Required Integer in group parameters
# @param required_string_group [Integer] Required String in group parameters
# @param required_boolean_group [Boolean] Required Boolean in group parameters
# @param required_int64_group [Integer] Required Integer in group parameters
# @param [Hash] opts the optional parameters
# @option opts [Integer] :string_group String in group parameters
# @option opts [BOOLEAN] :boolean_group Boolean in group parameters
# @option opts [Boolean] :boolean_group Boolean in group parameters
# @option opts [Integer] :int64_group Integer in group parameters
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
def test_group_parameters_with_http_info(required_string_group, required_boolean_group, required_int64_group, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FakeApi.test_group_parameters ...'
@ -662,29 +819,39 @@ module Petstore
local_var_path = '/fake'
# query parameters
query_params = {}
query_params = opts[:query_params] || {}
query_params[:'required_string_group'] = required_string_group
query_params[:'required_int64_group'] = required_int64_group
query_params[:'string_group'] = opts[:'string_group'] if !opts[:'string_group'].nil?
query_params[:'int64_group'] = opts[:'int64_group'] if !opts[:'int64_group'].nil?
# header parameters
header_params = {}
header_params = opts[:header_params] || {}
header_params[:'required_boolean_group'] = required_boolean_group
header_params[:'boolean_group'] = opts[:'boolean_group'] if !opts[:'boolean_group'].nil?
# form parameters
form_params = {}
form_params = opts[:form_params] || {}
# http body (model)
post_body = nil
auth_names = []
data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,
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)
: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: FakeApi#test_group_parameters\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
@ -692,49 +859,59 @@ module Petstore
end
# test inline additionalProperties
# @param request_body request body
# @param param [Hash<String, String>] request body
# @param [Hash] opts the optional parameters
# @return [nil]
def test_inline_additional_properties(request_body, opts = {})
test_inline_additional_properties_with_http_info(request_body, opts)
def test_inline_additional_properties(param, opts = {})
test_inline_additional_properties_with_http_info(param, opts)
nil
end
# test inline additionalProperties
# @param request_body request body
# @param param [Hash<String, String>] request body
# @param [Hash] opts the optional parameters
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def test_inline_additional_properties_with_http_info(request_body, opts = {})
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
def test_inline_additional_properties_with_http_info(param, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FakeApi.test_inline_additional_properties ...'
end
# verify the required parameter 'request_body' is set
if @api_client.config.client_side_validation && request_body.nil?
fail ArgumentError, "Missing the required parameter 'request_body' when calling FakeApi.test_inline_additional_properties"
# verify the required parameter 'param' is set
if @api_client.config.client_side_validation && param.nil?
fail ArgumentError, "Missing the required parameter 'param' when calling FakeApi.test_inline_additional_properties"
end
# resource path
local_var_path = '/fake/inline-additionalProperties'
# query parameters
query_params = {}
query_params = opts[:query_params] || {}
# header parameters
header_params = {}
header_params = opts[:header_params] || {}
# HTTP header 'Content-Type'
header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
# form parameters
form_params = {}
form_params = opts[:form_params] || {}
# http body (model)
post_body = @api_client.object_to_http_body(request_body)
auth_names = []
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
post_body = opts[:body] || @api_client.object_to_http_body(param)
# 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)
: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: FakeApi#test_inline_additional_properties\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
@ -742,8 +919,8 @@ module Petstore
end
# test json serialization of form data
# @param param field1
# @param param2 field2
# @param param [String] field1
# @param param2 [String] field2
# @param [Hash] opts the optional parameters
# @return [nil]
def test_json_form_data(param, param2, opts = {})
@ -752,10 +929,10 @@ module Petstore
end
# test json serialization of form data
# @param param field1
# @param param2 field2
# @param param [String] field1
# @param param2 [String] field2
# @param [Hash] opts the optional parameters
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
def test_json_form_data_with_http_info(param, param2, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: FakeApi.test_json_form_data ...'
@ -772,32 +949,41 @@ module Petstore
local_var_path = '/fake/jsonFormData'
# query parameters
query_params = {}
query_params = opts[:query_params] || {}
# header parameters
header_params = {}
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 = {}
form_params = opts[:form_params] || {}
form_params['param'] = param
form_params['param2'] = param2
# http body (model)
post_body = nil
auth_names = []
data, status_code, headers = @api_client.call_api(:GET, local_var_path,
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)
: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: FakeApi#test_json_form_data\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
end
end

View File

@ -3,14 +3,14 @@
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 3.3.3-SNAPSHOT
OpenAPI Generator version: 4.1.0-SNAPSHOT
=end
require 'uri'
require 'cgi'
module Petstore
class FakeClassnameTags123Api
@ -21,58 +21,66 @@ module Petstore
end
# To test class name in snake case
# To test class name in snake case
# @param client client model
# @param body [Client] client model
# @param [Hash] opts the optional parameters
# @return [Client]
def test_classname(client, opts = {})
data, _status_code, _headers = test_classname_with_http_info(client, opts)
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 client client model
# @param body [Client] client model
# @param [Hash] opts the optional parameters
# @return [Array<(Client, Fixnum, Hash)>] Client data, response status code and response headers
def test_classname_with_http_info(client, opts = {})
# @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 'client' is set
if @api_client.config.client_side_validation && client.nil?
fail ArgumentError, "Missing the required parameter 'client' when calling FakeClassnameTags123Api.test_classname"
# 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 = {}
query_params = opts[:query_params] || {}
# header parameters
header_params = {}
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 = {}
form_params = opts[:form_params] || {}
# http body (model)
post_body = @api_client.object_to_http_body(client)
auth_names = ['api_key_query']
data, status_code, headers = @api_client.call_api(:PATCH, local_var_path,
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 => 'Client')
: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

View File

@ -3,14 +3,14 @@
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 3.3.3-SNAPSHOT
OpenAPI Generator version: 4.1.0-SNAPSHOT
=end
require 'uri'
require 'cgi'
module Petstore
class PetApi
@ -20,49 +20,59 @@ module Petstore
@api_client = api_client
end
# Add a new pet to the store
# @param pet Pet object that needs to be added 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(pet, opts = {})
add_pet_with_http_info(pet, opts)
def add_pet(body, opts = {})
add_pet_with_http_info(body, opts)
nil
end
# Add a new pet to the store
# @param pet Pet object that needs to be added 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, Fixnum, Hash)>] nil, response status code and response headers
def add_pet_with_http_info(pet, opts = {})
# @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 'pet' is set
if @api_client.config.client_side_validation && pet.nil?
fail ArgumentError, "Missing the required parameter 'pet' when calling PetApi.add_pet"
# 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 = {}
query_params = opts[:query_params] || {}
# header parameters
header_params = {}
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 = {}
form_params = opts[:form_params] || {}
# http body (model)
post_body = @api_client.object_to_http_body(pet)
auth_names = ['petstore_auth']
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
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)
: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
@ -70,7 +80,7 @@ module Petstore
end
# Deletes a pet
# @param pet_id Pet id to delete
# @param pet_id [Integer] Pet id to delete
# @param [Hash] opts the optional parameters
# @option opts [String] :api_key
# @return [nil]
@ -80,10 +90,10 @@ module Petstore
end
# Deletes a pet
# @param pet_id Pet id to delete
# @param pet_id [Integer] Pet id to delete
# @param [Hash] opts the optional parameters
# @option opts [String] :api_key
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
# @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 ...'
@ -93,27 +103,37 @@ module Petstore
fail ArgumentError, "Missing the required parameter 'pet_id' when calling PetApi.delete_pet"
end
# resource path
local_var_path = '/pet/{petId}'.sub('{' + 'petId' + '}', pet_id.to_s)
local_var_path = '/pet/{petId}'.sub('{' + 'petId' + '}', CGI.escape(pet_id.to_s).gsub('%2F', '/'))
# query parameters
query_params = {}
query_params = opts[:query_params] || {}
# header parameters
header_params = {}
header_params = opts[:header_params] || {}
header_params[:'api_key'] = opts[:'api_key'] if !opts[:'api_key'].nil?
# form parameters
form_params = {}
form_params = opts[:form_params] || {}
# http body (model)
post_body = nil
auth_names = ['petstore_auth']
data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,
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)
: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
@ -122,7 +142,7 @@ module Petstore
# Finds Pets by status
# Multiple status values can be provided with comma separated strings
# @param status Status values that need to be considered for filter
# @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 = {})
@ -132,9 +152,9 @@ module Petstore
# Finds Pets by status
# Multiple status values can be provided with comma separated strings
# @param status Status values that need to be considered for filter
# @param status [Array<String>] Status values that need to be considered for filter
# @param [Hash] opts the optional parameters
# @return [Array<(Array<Pet>, Fixnum, Hash)>] Array<Pet> data, response status code and response headers
# @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 ...'
@ -147,27 +167,36 @@ module Petstore
local_var_path = '/pet/findByStatus'
# query parameters
query_params = {}
query_params = opts[:query_params] || {}
query_params[:'status'] = @api_client.build_collection_param(status, :csv)
# header parameters
header_params = {}
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 = {}
form_params = opts[:form_params] || {}
# http body (model)
post_body = nil
auth_names = ['petstore_auth']
data, status_code, headers = @api_client.call_api(:GET, local_var_path,
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 => 'Array<Pet>')
: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
@ -176,7 +205,7 @@ module Petstore
# Finds Pets by tags
# Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
# @param tags Tags to filter by
# @param tags [Array<String>] Tags to filter by
# @param [Hash] opts the optional parameters
# @return [Array<Pet>]
def find_pets_by_tags(tags, opts = {})
@ -186,9 +215,9 @@ module Petstore
# Finds Pets by tags
# Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
# @param tags Tags to filter by
# @param tags [Array<String>] Tags to filter by
# @param [Hash] opts the optional parameters
# @return [Array<(Array<Pet>, Fixnum, Hash)>] Array<Pet> data, response status code and response headers
# @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 ...'
@ -201,27 +230,36 @@ module Petstore
local_var_path = '/pet/findByTags'
# query parameters
query_params = {}
query_params = opts[:query_params] || {}
query_params[:'tags'] = @api_client.build_collection_param(tags, :csv)
# header parameters
header_params = {}
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 = {}
form_params = opts[:form_params] || {}
# http body (model)
post_body = nil
auth_names = ['petstore_auth']
data, status_code, headers = @api_client.call_api(:GET, local_var_path,
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 => 'Array<Pet>')
: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
@ -230,7 +268,7 @@ module Petstore
# Find pet by ID
# Returns a single pet
# @param pet_id ID of pet to return
# @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 = {})
@ -240,9 +278,9 @@ module Petstore
# Find pet by ID
# Returns a single pet
# @param pet_id ID of pet to return
# @param pet_id [Integer] ID of pet to return
# @param [Hash] opts the optional parameters
# @return [Array<(Pet, Fixnum, Hash)>] Pet data, response status code and response headers
# @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 ...'
@ -252,29 +290,38 @@ module Petstore
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' + '}', pet_id.to_s)
local_var_path = '/pet/{petId}'.sub('{' + 'petId' + '}', CGI.escape(pet_id.to_s).gsub('%2F', '/'))
# query parameters
query_params = {}
query_params = opts[:query_params] || {}
# header parameters
header_params = {}
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 = {}
form_params = opts[:form_params] || {}
# http body (model)
post_body = nil
auth_names = ['api_key']
data, status_code, headers = @api_client.call_api(:GET, local_var_path,
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 => 'Pet')
: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
@ -282,49 +329,59 @@ module Petstore
end
# Update an existing pet
# @param pet Pet object that needs to be added 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 update_pet(pet, opts = {})
update_pet_with_http_info(pet, opts)
def update_pet(body, opts = {})
update_pet_with_http_info(body, opts)
nil
end
# Update an existing pet
# @param pet Pet object that needs to be added 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, Fixnum, Hash)>] nil, response status code and response headers
def update_pet_with_http_info(pet, opts = {})
# @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 'pet' is set
if @api_client.config.client_side_validation && pet.nil?
fail ArgumentError, "Missing the required parameter 'pet' when calling PetApi.update_pet"
# 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 = {}
query_params = opts[:query_params] || {}
# header parameters
header_params = {}
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 = {}
form_params = opts[:form_params] || {}
# http body (model)
post_body = @api_client.object_to_http_body(pet)
auth_names = ['petstore_auth']
data, status_code, headers = @api_client.call_api(:PUT, local_var_path,
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)
: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
@ -332,7 +389,7 @@ module Petstore
end
# Updates a pet in the store with form data
# @param pet_id ID of pet that needs to be updated
# @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
@ -343,11 +400,11 @@ module Petstore
end
# Updates a pet in the store with form data
# @param pet_id ID of pet that needs to be updated
# @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, Fixnum, Hash)>] nil, response status code and response headers
# @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 ...'
@ -357,30 +414,40 @@ module Petstore
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' + '}', pet_id.to_s)
local_var_path = '/pet/{petId}'.sub('{' + 'petId' + '}', CGI.escape(pet_id.to_s).gsub('%2F', '/'))
# query parameters
query_params = {}
query_params = opts[:query_params] || {}
# header parameters
header_params = {}
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 = {}
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 = nil
auth_names = ['petstore_auth']
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
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)
: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
@ -388,7 +455,7 @@ module Petstore
end
# uploads an image
# @param pet_id ID of pet to update
# @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
@ -399,11 +466,11 @@ module Petstore
end
# uploads an image
# @param pet_id ID of pet to update
# @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, Fixnum, Hash)>] ApiResponse data, response status code and response headers
# @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 ...'
@ -413,33 +480,42 @@ module Petstore
fail ArgumentError, "Missing the required parameter 'pet_id' when calling PetApi.upload_file"
end
# resource path
local_var_path = '/pet/{petId}/uploadImage'.sub('{' + 'petId' + '}', pet_id.to_s)
local_var_path = '/pet/{petId}/uploadImage'.sub('{' + 'petId' + '}', CGI.escape(pet_id.to_s).gsub('%2F', '/'))
# query parameters
query_params = {}
query_params = opts[:query_params] || {}
# header parameters
header_params = {}
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 = {}
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 = nil
auth_names = ['petstore_auth']
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
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 => 'ApiResponse')
: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
@ -447,8 +523,8 @@ module Petstore
end
# uploads an image (required)
# @param pet_id ID of pet to update
# @param required_file file to upload
# @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]
@ -458,11 +534,11 @@ module Petstore
end
# uploads an image (required)
# @param pet_id ID of pet to update
# @param required_file file to upload
# @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, Fixnum, Hash)>] ApiResponse data, response status code and response headers
# @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 ...'
@ -476,38 +552,46 @@ module Petstore
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' + '}', pet_id.to_s)
local_var_path = '/fake/{petId}/uploadImageWithRequiredFile'.sub('{' + 'petId' + '}', CGI.escape(pet_id.to_s).gsub('%2F', '/'))
# query parameters
query_params = {}
query_params = opts[:query_params] || {}
# header parameters
header_params = {}
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 = {}
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 = nil
auth_names = ['petstore_auth']
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
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 => 'ApiResponse')
: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

View File

@ -3,14 +3,14 @@
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 3.3.3-SNAPSHOT
OpenAPI Generator version: 4.1.0-SNAPSHOT
=end
require 'uri'
require 'cgi'
module Petstore
class StoreApi
@ -21,7 +21,7 @@ module Petstore
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 ID of the order that needs to be deleted
# @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 = {})
@ -31,9 +31,9 @@ module Petstore
# Delete purchase order by ID
# For valid response try integer IDs with value &lt; 1000. Anything above 1000 or nonintegers will generate API errors
# @param order_id ID of the order that needs to be deleted
# @param order_id [String] ID of the order that needs to be deleted
# @param [Hash] opts the optional parameters
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
# @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 ...'
@ -43,26 +43,36 @@ module Petstore
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' + '}', order_id.to_s)
local_var_path = '/store/order/{order_id}'.sub('{' + 'order_id' + '}', CGI.escape(order_id.to_s).gsub('%2F', '/'))
# query parameters
query_params = {}
query_params = opts[:query_params] || {}
# header parameters
header_params = {}
header_params = opts[:header_params] || {}
# form parameters
form_params = {}
form_params = opts[:form_params] || {}
# http body (model)
post_body = nil
auth_names = []
data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,
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)
: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
@ -81,7 +91,7 @@ module Petstore
# Returns pet inventories by status
# Returns a map of status codes to quantities
# @param [Hash] opts the optional parameters
# @return [Array<(Hash<String, Integer>, Fixnum, Hash)>] Hash<String, Integer> data, response status code and response headers
# @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 ...'
@ -90,26 +100,35 @@ module Petstore
local_var_path = '/store/inventory'
# query parameters
query_params = {}
query_params = opts[:query_params] || {}
# header parameters
header_params = {}
header_params = opts[:header_params] || {}
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
# form parameters
form_params = {}
form_params = opts[:form_params] || {}
# http body (model)
post_body = nil
auth_names = ['api_key']
data, status_code, headers = @api_client.call_api(:GET, local_var_path,
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 => 'Hash<String, Integer>')
: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
@ -118,7 +137,7 @@ module Petstore
# Find purchase order by ID
# For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
# @param order_id ID of pet that needs to be fetched
# @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 = {})
@ -128,9 +147,9 @@ module Petstore
# Find purchase order by ID
# For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions
# @param order_id ID of pet that needs to be fetched
# @param order_id [Integer] ID of pet that needs to be fetched
# @param [Hash] opts the optional parameters
# @return [Array<(Order, Fixnum, Hash)>] Order data, response status code and response headers
# @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 ...'
@ -148,29 +167,38 @@ module Petstore
end
# resource path
local_var_path = '/store/order/{order_id}'.sub('{' + 'order_id' + '}', order_id.to_s)
local_var_path = '/store/order/{order_id}'.sub('{' + 'order_id' + '}', CGI.escape(order_id.to_s).gsub('%2F', '/'))
# query parameters
query_params = {}
query_params = opts[:query_params] || {}
# header parameters
header_params = {}
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 = {}
form_params = opts[:form_params] || {}
# http body (model)
post_body = nil
auth_names = []
data, status_code, headers = @api_client.call_api(:GET, local_var_path,
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 => 'Order')
: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
@ -178,55 +206,63 @@ module Petstore
end
# Place an order for a pet
# @param order order placed for purchasing the pet
# @param body [Order] order placed for purchasing the pet
# @param [Hash] opts the optional parameters
# @return [Order]
def place_order(order, opts = {})
data, _status_code, _headers = place_order_with_http_info(order, opts)
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 order order placed for purchasing the pet
# @param body [Order] order placed for purchasing the pet
# @param [Hash] opts the optional parameters
# @return [Array<(Order, Fixnum, Hash)>] Order data, response status code and response headers
def place_order_with_http_info(order, opts = {})
# @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 'order' is set
if @api_client.config.client_side_validation && order.nil?
fail ArgumentError, "Missing the required parameter 'order' when calling StoreApi.place_order"
# 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 = {}
query_params = opts[:query_params] || {}
# header parameters
header_params = {}
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 = {}
form_params = opts[:form_params] || {}
# http body (model)
post_body = @api_client.object_to_http_body(order)
auth_names = []
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
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 => 'Order')
: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

View File

@ -3,14 +3,14 @@
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 3.3.3-SNAPSHOT
OpenAPI Generator version: 4.1.0-SNAPSHOT
=end
require 'uri'
require 'cgi'
module Petstore
class UserApi
@ -21,48 +21,58 @@ module Petstore
end
# Create user
# This can only be done by the logged in user.
# @param user Created user object
# @param body [User] Created user object
# @param [Hash] opts the optional parameters
# @return [nil]
def create_user(user, opts = {})
create_user_with_http_info(user, opts)
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 user Created user object
# @param body [User] Created user object
# @param [Hash] opts the optional parameters
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def create_user_with_http_info(user, opts = {})
# @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 'user' is set
if @api_client.config.client_side_validation && user.nil?
fail ArgumentError, "Missing the required parameter 'user' when calling UserApi.create_user"
# 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 = {}
query_params = opts[:query_params] || {}
# header parameters
header_params = {}
header_params = opts[:header_params] || {}
# form parameters
form_params = {}
form_params = opts[:form_params] || {}
# http body (model)
post_body = @api_client.object_to_http_body(user)
auth_names = []
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
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)
: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
@ -70,47 +80,57 @@ module Petstore
end
# Creates list of users with given input array
# @param user List of user object
# @param body [Array<User>] List of user object
# @param [Hash] opts the optional parameters
# @return [nil]
def create_users_with_array_input(user, opts = {})
create_users_with_array_input_with_http_info(user, opts)
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 user List of user object
# @param body [Array<User>] List of user object
# @param [Hash] opts the optional parameters
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def create_users_with_array_input_with_http_info(user, opts = {})
# @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 'user' is set
if @api_client.config.client_side_validation && user.nil?
fail ArgumentError, "Missing the required parameter 'user' when calling UserApi.create_users_with_array_input"
# 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 = {}
query_params = opts[:query_params] || {}
# header parameters
header_params = {}
header_params = opts[:header_params] || {}
# form parameters
form_params = {}
form_params = opts[:form_params] || {}
# http body (model)
post_body = @api_client.object_to_http_body(user)
auth_names = []
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
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)
: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
@ -118,47 +138,57 @@ module Petstore
end
# Creates list of users with given input array
# @param user List of user object
# @param body [Array<User>] List of user object
# @param [Hash] opts the optional parameters
# @return [nil]
def create_users_with_list_input(user, opts = {})
create_users_with_list_input_with_http_info(user, opts)
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 user List of user object
# @param body [Array<User>] List of user object
# @param [Hash] opts the optional parameters
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def create_users_with_list_input_with_http_info(user, opts = {})
# @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 'user' is set
if @api_client.config.client_side_validation && user.nil?
fail ArgumentError, "Missing the required parameter 'user' when calling UserApi.create_users_with_list_input"
# 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 = {}
query_params = opts[:query_params] || {}
# header parameters
header_params = {}
header_params = opts[:header_params] || {}
# form parameters
form_params = {}
form_params = opts[:form_params] || {}
# http body (model)
post_body = @api_client.object_to_http_body(user)
auth_names = []
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
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)
: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
@ -167,7 +197,7 @@ module Petstore
# Delete user
# This can only be done by the logged in user.
# @param username The name that needs to be deleted
# @param username [String] The name that needs to be deleted
# @param [Hash] opts the optional parameters
# @return [nil]
def delete_user(username, opts = {})
@ -177,9 +207,9 @@ module Petstore
# Delete user
# This can only be done by the logged in user.
# @param username The name that needs to be deleted
# @param username [String] The name that needs to be deleted
# @param [Hash] opts the optional parameters
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
# @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 ...'
@ -189,26 +219,36 @@ module Petstore
fail ArgumentError, "Missing the required parameter 'username' when calling UserApi.delete_user"
end
# resource path
local_var_path = '/user/{username}'.sub('{' + 'username' + '}', username.to_s)
local_var_path = '/user/{username}'.sub('{' + 'username' + '}', CGI.escape(username.to_s).gsub('%2F', '/'))
# query parameters
query_params = {}
query_params = opts[:query_params] || {}
# header parameters
header_params = {}
header_params = opts[:header_params] || {}
# form parameters
form_params = {}
form_params = opts[:form_params] || {}
# http body (model)
post_body = nil
auth_names = []
data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,
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)
: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
@ -216,7 +256,7 @@ module Petstore
end
# Get user by user name
# @param username The name that needs to be fetched. Use user1 for testing.
# @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 = {})
@ -225,9 +265,9 @@ module Petstore
end
# Get user by user name
# @param username The name that needs to be fetched. Use user1 for testing.
# @param username [String] The name that needs to be fetched. Use user1 for testing.
# @param [Hash] opts the optional parameters
# @return [Array<(User, Fixnum, Hash)>] User data, response status code and response headers
# @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 ...'
@ -237,29 +277,38 @@ module Petstore
fail ArgumentError, "Missing the required parameter 'username' when calling UserApi.get_user_by_name"
end
# resource path
local_var_path = '/user/{username}'.sub('{' + 'username' + '}', username.to_s)
local_var_path = '/user/{username}'.sub('{' + 'username' + '}', CGI.escape(username.to_s).gsub('%2F', '/'))
# query parameters
query_params = {}
query_params = opts[:query_params] || {}
# header parameters
header_params = {}
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 = {}
form_params = opts[:form_params] || {}
# http body (model)
post_body = nil
auth_names = []
data, status_code, headers = @api_client.call_api(:GET, local_var_path,
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 => 'User')
: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
@ -267,8 +316,8 @@ module Petstore
end
# Logs user into the system
# @param username The user name for login
# @param password The password for login in clear text
# @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 = {})
@ -277,10 +326,10 @@ module Petstore
end
# Logs user into the system
# @param username The user name for login
# @param password The password for login in clear text
# @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, Fixnum, Hash)>] String data, response status code and response headers
# @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 ...'
@ -297,28 +346,37 @@ module Petstore
local_var_path = '/user/login'
# query parameters
query_params = {}
query_params = opts[:query_params] || {}
query_params[:'username'] = username
query_params[:'password'] = password
# header parameters
header_params = {}
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 = {}
form_params = opts[:form_params] || {}
# http body (model)
post_body = nil
auth_names = []
data, status_code, headers = @api_client.call_api(:GET, local_var_path,
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 => 'String')
: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
@ -335,7 +393,7 @@ module Petstore
# Logs out current logged in user session
# @param [Hash] opts the optional parameters
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
# @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 ...'
@ -344,23 +402,33 @@ module Petstore
local_var_path = '/user/logout'
# query parameters
query_params = {}
query_params = opts[:query_params] || {}
# header parameters
header_params = {}
header_params = opts[:header_params] || {}
# form parameters
form_params = {}
form_params = opts[:form_params] || {}
# http body (model)
post_body = nil
auth_names = []
data, status_code, headers = @api_client.call_api(:GET, local_var_path,
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)
: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
@ -369,22 +437,22 @@ module Petstore
# Updated user
# This can only be done by the logged in user.
# @param username name that need to be deleted
# @param user Updated user object
# @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, user, opts = {})
update_user_with_http_info(username, user, opts)
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 name that need to be deleted
# @param user Updated user object
# @param username [String] name that need to be deleted
# @param body [User] Updated user object
# @param [Hash] opts the optional parameters
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def update_user_with_http_info(username, user, opts = {})
# @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
@ -392,36 +460,45 @@ module Petstore
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 'user' is set
if @api_client.config.client_side_validation && user.nil?
fail ArgumentError, "Missing the required parameter 'user' when calling UserApi.update_user"
# 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' + '}', username.to_s)
local_var_path = '/user/{username}'.sub('{' + 'username' + '}', CGI.escape(username.to_s).gsub('%2F', '/'))
# query parameters
query_params = {}
query_params = opts[:query_params] || {}
# header parameters
header_params = {}
header_params = opts[:header_params] || {}
# form parameters
form_params = {}
form_params = opts[:form_params] || {}
# http body (model)
post_body = @api_client.object_to_http_body(user)
auth_names = []
data, status_code, headers = @api_client.call_api(:PUT, local_var_path,
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)
: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

View File

@ -3,132 +3,155 @@
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 3.3.3-SNAPSHOT
OpenAPI Generator version: 4.1.0-SNAPSHOT
=end
require 'date'
require 'faraday'
require 'json'
require 'logger'
require 'faraday'
require 'tempfile'
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
def initialize(config = Configuration.default)
@config = config
end
attr_reader :config
# 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 = {})
normalized_path = ::File.join(config.base_path, path)
@last_response = connection.public_send(http_method.to_sym.downcase) do |req|
req.url(normalized_path)
req.headers = default_headers.merge(opts[:header_params] || {})
req.body = opts[:body]
query_params = opts[:query_params] || {}
form_params = opts[:form_params] || {}
req.params = query_params.merge(form_params)
connection = Faraday.new(:url => config.base_url) do |conn|
conn.basic_auth(config.username, config.password)
if opts[:header_params]["Content-Type"] == "multipart/form-data"
conn.request :multipart
conn.request :url_encoded
end
conn.adapter(Faraday.default_adapter)
end
begin
response = connection.public_send(http_method.to_sym.downcase) do |req|
build_request(http_method, path, req, opts)
end
if @config.debugging
@config.logger.debug "HTTP response body ~BEGIN~\n#{@last_response.body}\n~END~\n"
if @config.debugging
@config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
end
unless response.success?
if response.status == 0
# Errors from libcurl will be made visible here
fail ApiError.new(:code => 0,
:message => response.return_message)
else
fail ApiError.new(:code => response.status,
:response_headers => response.headers,
:response_body => response.body),
response.reason_phrase
end
end
rescue Faraday::TimeoutError
fail ApiError.new('Connection timed out')
end
if opts[:return_type]
data = deserialize(@last_response, opts[:return_type])
data = deserialize(response, opts[:return_type])
else
data = nil
end
return data, @last_response.status, @last_response.headers
return data, response.status, response.headers
end
attr_reader :last_response
# 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, request, opts = {})
url = build_request_url(path)
http_method = http_method.to_sym.downcase
# 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)
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
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
# 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
request.headers = header_params
request.body = req_body
request.url path
request.params = query_params
download_file(request) if opts[:return_type] == 'File'
request
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
private
def connection
@connection ||= bulid_connection
end
def bulid_connection
Faraday.new(:url => config.base_url) do |builder|
builder.adapter(Faraday.default_adapter)
end
end
def user_agent
@user_agent ||= "OpenAPI-Generator/#{VERSION}/ruby"
end
def default_headers
{
'Content-Type' => 'application/json',
'User-Agent' => user_agent
}
end
# Deserialize the response to the given return type.
#
# @param [Response] response HTTP response
@ -136,6 +159,10 @@ module Petstore
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
@ -172,7 +199,7 @@ module Petstore
data.to_i
when 'Float'
data.to_f
when 'BOOLEAN'
when 'Boolean'
data == true
when 'DateTime'
# parse date time (expecting ISO 8601 format)
@ -195,9 +222,179 @@ module Petstore
end
else
# models, e.g. Pet
Petstore.const_get(return_type).new.tap do |model|
model.build_from_hash data
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
# 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, ::Tempfile
data[key] = Faraday::UploadIO.new(value.path, '')
when ::Array, nil
# let Faraday handle 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
# 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

View File

@ -3,10 +3,10 @@
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 3.3.3-SNAPSHOT
OpenAPI Generator version: 4.1.0-SNAPSHOT
=end
@ -34,5 +34,24 @@ module Petstore
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

View File

@ -3,15 +3,13 @@
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 3.3.3-SNAPSHOT
OpenAPI Generator version: 4.1.0-SNAPSHOT
=end
require 'uri'
module Petstore
class Configuration
# Defines url scheme
@ -128,7 +126,7 @@ module Petstore
attr_accessor :force_ending_format
def initialize
@scheme = 'https'
@scheme = 'http'
@host = 'petstore.swagger.io'
@base_path = '/v2'
@api_key = {}
@ -174,8 +172,7 @@ module Petstore
end
def base_url
url = "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
URI.encode(url)
"#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
end
# Gets API key (with prefix if set).
@ -245,8 +242,8 @@ module Petstore
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}"
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]

View 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.1.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

View 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.1.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

View 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.1.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

View File

@ -3,10 +3,10 @@
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 3.3.3-SNAPSHOT
OpenAPI Generator version: 4.1.0-SNAPSHOT
=end
@ -14,45 +14,136 @@ require 'date'
module Petstore
class AdditionalPropertiesClass
attr_accessor :map_property
attr_accessor :map_string
attr_accessor :map_of_map_property
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_property' => :'map_property',
:'map_of_map_property' => :'map_of_map_property'
:'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_property' => :'Hash<String, String>',
:'map_of_map_property' => :'Hash<String, Hash<String, String>>'
:'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 = {})
return unless attributes.is_a?(Hash)
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::AdditionalPropertiesClass` initialize method"
end
# convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
# 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.has_key?(:'map_property')
if (value = attributes[:'map_property']).is_a?(Hash)
self.map_property = value
if attributes.key?(:'map_string')
if (value = attributes[:'map_string']).is_a?(Hash)
self.map_string = value
end
end
if attributes.has_key?(:'map_of_map_property')
if (value = attributes[:'map_of_map_property']).is_a?(Hash)
self.map_of_map_property = value
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?
@ -73,8 +164,17 @@ module Petstore
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
map_property == o.map_property &&
map_of_map_property == o.map_of_map_property
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
@ -84,9 +184,16 @@ module Petstore
end
# Calculates hash code according to all attributes.
# @return [Fixnum] Hash code
# @return [Integer] Hash code
def hash
[map_property, map_of_map_property].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
@ -96,7 +203,7 @@ module Petstore
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 the attribute
# 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) })
@ -125,7 +232,7 @@ module Petstore
value.to_i
when :Float
value.to_f
when :BOOLEAN
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
@ -146,8 +253,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View 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.1.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

View 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.1.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

View 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.1.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

View 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.1.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

View File

@ -3,10 +3,10 @@
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 3.3.3-SNAPSHOT
OpenAPI Generator version: 4.1.0-SNAPSHOT
=end
@ -34,19 +34,31 @@ module Petstore
}
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 = {})
return unless attributes.is_a?(Hash)
# convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
if attributes.has_key?(:'className')
self.class_name = attributes[:'className']
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::Animal` initialize method"
end
if attributes.has_key?(:'color')
# 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'
@ -87,11 +99,18 @@ module Petstore
end
# Calculates hash code according to all attributes.
# @return [Fixnum] Hash code
# @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
@ -99,7 +118,7 @@ module Petstore
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 the attribute
# 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) })
@ -128,7 +147,7 @@ module Petstore
value.to_i
when :Float
value.to_f
when :BOOLEAN
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
@ -149,8 +168,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -3,10 +3,10 @@
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 3.3.3-SNAPSHOT
OpenAPI Generator version: 4.1.0-SNAPSHOT
=end
@ -41,20 +41,27 @@ module Petstore
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
return unless attributes.is_a?(Hash)
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::ApiResponse` initialize method"
end
# convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
# 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.has_key?(:'code')
if attributes.key?(:'code')
self.code = attributes[:'code']
end
if attributes.has_key?(:'type')
if attributes.key?(:'type')
self.type = attributes[:'type']
end
if attributes.has_key?(:'message')
if attributes.key?(:'message')
self.message = attributes[:'message']
end
end
@ -89,11 +96,18 @@ module Petstore
end
# Calculates hash code according to all attributes.
# @return [Fixnum] Hash code
# @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
@ -101,7 +115,7 @@ module Petstore
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 the attribute
# 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) })
@ -130,7 +144,7 @@ module Petstore
value.to_i
when :Float
value.to_f
when :BOOLEAN
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
@ -151,8 +165,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -3,10 +3,10 @@
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 3.3.3-SNAPSHOT
OpenAPI Generator version: 4.1.0-SNAPSHOT
=end
@ -33,13 +33,20 @@ module Petstore
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
return unless attributes.is_a?(Hash)
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::ArrayOfArrayOfNumberOnly` initialize method"
end
# convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
# 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.has_key?(:'ArrayArrayNumber')
if (value = attributes[:'ArrayArrayNumber']).is_a?(Array)
if attributes.key?(:'array_array_number')
if (value = attributes[:'array_array_number']).is_a?(Array)
self.array_array_number = value
end
end
@ -73,11 +80,18 @@ module Petstore
end
# Calculates hash code according to all attributes.
# @return [Fixnum] Hash code
# @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
@ -85,7 +99,7 @@ module Petstore
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 the attribute
# 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) })
@ -114,7 +128,7 @@ module Petstore
value.to_i
when :Float
value.to_f
when :BOOLEAN
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
@ -135,8 +149,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -3,10 +3,10 @@
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 3.3.3-SNAPSHOT
OpenAPI Generator version: 4.1.0-SNAPSHOT
=end
@ -33,13 +33,20 @@ module Petstore
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
return unless attributes.is_a?(Hash)
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::ArrayOfNumberOnly` initialize method"
end
# convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
# 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.has_key?(:'ArrayNumber')
if (value = attributes[:'ArrayNumber']).is_a?(Array)
if attributes.key?(:'array_number')
if (value = attributes[:'array_number']).is_a?(Array)
self.array_number = value
end
end
@ -73,11 +80,18 @@ module Petstore
end
# Calculates hash code according to all attributes.
# @return [Fixnum] Hash code
# @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
@ -85,7 +99,7 @@ module Petstore
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 the attribute
# 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) })
@ -114,7 +128,7 @@ module Petstore
value.to_i
when :Float
value.to_f
when :BOOLEAN
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
@ -135,8 +149,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -3,10 +3,10 @@
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 3.3.3-SNAPSHOT
OpenAPI Generator version: 4.1.0-SNAPSHOT
=end
@ -41,24 +41,31 @@ module Petstore
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
return unless attributes.is_a?(Hash)
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::ArrayTest` initialize method"
end
# convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
# 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.has_key?(:'array_of_string')
if attributes.key?(:'array_of_string')
if (value = attributes[:'array_of_string']).is_a?(Array)
self.array_of_string = value
end
end
if attributes.has_key?(:'array_array_of_integer')
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.has_key?(:'array_array_of_model')
if attributes.key?(:'array_array_of_model')
if (value = attributes[:'array_array_of_model']).is_a?(Array)
self.array_array_of_model = value
end
@ -95,11 +102,18 @@ module Petstore
end
# Calculates hash code according to all attributes.
# @return [Fixnum] Hash code
# @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
@ -107,7 +121,7 @@ module Petstore
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 the attribute
# 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) })
@ -136,7 +150,7 @@ module Petstore
value.to_i
when :Float
value.to_f
when :BOOLEAN
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
@ -157,8 +171,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -3,10 +3,10 @@
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 3.3.3-SNAPSHOT
OpenAPI Generator version: 4.1.0-SNAPSHOT
=end
@ -54,33 +54,40 @@ module Petstore
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
return unless attributes.is_a?(Hash)
# convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
if attributes.has_key?(:'smallCamel')
self.small_camel = attributes[:'smallCamel']
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::Capitalization` initialize method"
end
if attributes.has_key?(:'CapitalCamel')
self.capital_camel = attributes[:'CapitalCamel']
# 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.has_key?(:'small_Snake')
self.small_snake = attributes[:'small_Snake']
if attributes.key?(:'capital_camel')
self.capital_camel = attributes[:'capital_camel']
end
if attributes.has_key?(:'Capital_Snake')
self.capital_snake = attributes[:'Capital_Snake']
if attributes.key?(:'small_snake')
self.small_snake = attributes[:'small_snake']
end
if attributes.has_key?(:'SCA_ETH_Flow_Points')
self.sca_eth_flow_points = attributes[:'SCA_ETH_Flow_Points']
if attributes.key?(:'capital_snake')
self.capital_snake = attributes[:'capital_snake']
end
if attributes.has_key?(:'ATT_NAME')
self.att_name = attributes[:'ATT_NAME']
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
@ -117,11 +124,18 @@ module Petstore
end
# Calculates hash code according to all attributes.
# @return [Fixnum] Hash code
# @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
@ -129,7 +143,7 @@ module Petstore
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 the attribute
# 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) })
@ -158,7 +172,7 @@ module Petstore
value.to_i
when :Float
value.to_f
when :BOOLEAN
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
@ -179,8 +193,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -3,28 +3,22 @@
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 3.3.3-SNAPSHOT
OpenAPI Generator version: 4.1.0-SNAPSHOT
=end
require 'date'
module Petstore
class Cat
attr_accessor :class_name
attr_accessor :color
class Cat < Animal
attr_accessor :declawed
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'class_name' => :'className',
:'color' => :'color',
:'declawed' => :'declawed'
}
end
@ -32,31 +26,37 @@ module Petstore
# Attribute type mapping.
def self.openapi_types
{
:'class_name' => :'String',
:'color' => :'String',
:'declawed' => :'BOOLEAN'
:'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 = {})
return unless attributes.is_a?(Hash)
# convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
if attributes.has_key?(:'className')
self.class_name = attributes[:'className']
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::Cat` initialize method"
end
if attributes.has_key?(:'color')
self.color = attributes[:'color']
else
self.color = 'red'
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
}
if attributes.has_key?(:'declawed')
# call parent's initialize
super(attributes)
if attributes.key?(:'declawed')
self.declawed = attributes[:'declawed']
end
end
@ -64,19 +64,14 @@ module Petstore
# 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 = 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?
return false if @class_name.nil?
true
true && super
end
# Checks equality by comparing each attribute.
@ -84,9 +79,7 @@ module Petstore
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
class_name == o.class_name &&
color == o.color &&
declawed == o.declawed
declawed == o.declawed && super(o)
end
# @see the `==` method
@ -96,9 +89,16 @@ module Petstore
end
# Calculates hash code according to all attributes.
# @return [Fixnum] Hash code
# @return [Integer] Hash code
def hash
[class_name, color, declawed].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
@ -106,9 +106,10 @@ module Petstore
# @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 the attribute
# 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) })
@ -137,7 +138,7 @@ module Petstore
value.to_i
when :Float
value.to_f
when :BOOLEAN
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
@ -158,8 +159,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end
@ -178,7 +178,7 @@ module Petstore
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
hash = super
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
next if value.nil?

View 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.1.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

View File

@ -3,10 +3,10 @@
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 3.3.3-SNAPSHOT
OpenAPI Generator version: 4.1.0-SNAPSHOT
=end
@ -37,16 +37,23 @@ module Petstore
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
return unless attributes.is_a?(Hash)
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::Category` initialize method"
end
# convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
# 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.has_key?(:'id')
if attributes.key?(:'id')
self.id = attributes[:'id']
end
if attributes.has_key?(:'name')
if attributes.key?(:'name')
self.name = attributes[:'name']
else
self.name = 'default-name'
@ -87,11 +94,18 @@ module Petstore
end
# Calculates hash code according to all attributes.
# @return [Fixnum] Hash code
# @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
@ -99,7 +113,7 @@ module Petstore
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 the attribute
# 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) })
@ -128,7 +142,7 @@ module Petstore
value.to_i
when :Float
value.to_f
when :BOOLEAN
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
@ -149,8 +163,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -3,10 +3,10 @@
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 3.3.3-SNAPSHOT
OpenAPI Generator version: 4.1.0-SNAPSHOT
=end
@ -34,12 +34,19 @@ module Petstore
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
return unless attributes.is_a?(Hash)
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::ClassModel` initialize method"
end
# convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
# 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.has_key?(:'_class')
if attributes.key?(:'_class')
self._class = attributes[:'_class']
end
end
@ -72,11 +79,18 @@ module Petstore
end
# Calculates hash code according to all attributes.
# @return [Fixnum] Hash code
# @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
@ -84,7 +98,7 @@ module Petstore
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 the attribute
# 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) })
@ -113,7 +127,7 @@ module Petstore
value.to_i
when :Float
value.to_f
when :BOOLEAN
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
@ -134,8 +148,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -3,10 +3,10 @@
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 3.3.3-SNAPSHOT
OpenAPI Generator version: 4.1.0-SNAPSHOT
=end
@ -33,12 +33,19 @@ module Petstore
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
return unless attributes.is_a?(Hash)
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::Client` initialize method"
end
# convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
# 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.has_key?(:'client')
if attributes.key?(:'client')
self.client = attributes[:'client']
end
end
@ -71,11 +78,18 @@ module Petstore
end
# Calculates hash code according to all attributes.
# @return [Fixnum] Hash code
# @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
@ -83,7 +97,7 @@ module Petstore
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 the attribute
# 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) })
@ -112,7 +126,7 @@ module Petstore
value.to_i
when :Float
value.to_f
when :BOOLEAN
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
@ -133,8 +147,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -3,28 +3,22 @@
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 3.3.3-SNAPSHOT
OpenAPI Generator version: 4.1.0-SNAPSHOT
=end
require 'date'
module Petstore
class Dog
attr_accessor :class_name
attr_accessor :color
class Dog < Animal
attr_accessor :breed
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'class_name' => :'className',
:'color' => :'color',
:'breed' => :'breed'
}
end
@ -32,31 +26,37 @@ module Petstore
# Attribute type mapping.
def self.openapi_types
{
:'class_name' => :'String',
:'color' => :'String',
:'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 = {})
return unless attributes.is_a?(Hash)
# convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
if attributes.has_key?(:'className')
self.class_name = attributes[:'className']
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::Dog` initialize method"
end
if attributes.has_key?(:'color')
self.color = attributes[:'color']
else
self.color = 'red'
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
}
if attributes.has_key?(:'breed')
# call parent's initialize
super(attributes)
if attributes.key?(:'breed')
self.breed = attributes[:'breed']
end
end
@ -64,19 +64,14 @@ module Petstore
# 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 = 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?
return false if @class_name.nil?
true
true && super
end
# Checks equality by comparing each attribute.
@ -84,9 +79,7 @@ module Petstore
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
class_name == o.class_name &&
color == o.color &&
breed == o.breed
breed == o.breed && super(o)
end
# @see the `==` method
@ -96,9 +89,16 @@ module Petstore
end
# Calculates hash code according to all attributes.
# @return [Fixnum] Hash code
# @return [Integer] Hash code
def hash
[class_name, color, breed].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
@ -106,9 +106,10 @@ module Petstore
# @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 the attribute
# 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) })
@ -137,7 +138,7 @@ module Petstore
value.to_i
when :Float
value.to_f
when :BOOLEAN
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
@ -158,8 +159,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end
@ -178,7 +178,7 @@ module Petstore
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
hash = super
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
next if value.nil?

View 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.1.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

View File

@ -3,10 +3,10 @@
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 3.3.3-SNAPSHOT
OpenAPI Generator version: 4.1.0-SNAPSHOT
=end
@ -59,16 +59,23 @@ module Petstore
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
return unless attributes.is_a?(Hash)
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::EnumArrays` initialize method"
end
# convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
# 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.has_key?(:'just_symbol')
if attributes.key?(:'just_symbol')
self.just_symbol = attributes[:'just_symbol']
end
if attributes.has_key?(:'array_enum')
if attributes.key?(:'array_enum')
if (value = attributes[:'array_enum']).is_a?(Array)
self.array_enum = value
end
@ -85,7 +92,7 @@ module Petstore
# 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', ['>=', '$'])
just_symbol_validator = EnumAttributeValidator.new('String', [">=", "$"])
return false unless just_symbol_validator.valid?(@just_symbol)
true
end
@ -93,9 +100,9 @@ module Petstore
# 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', ['>=', '$'])
validator = EnumAttributeValidator.new('String', [">=", "$"])
unless validator.valid?(just_symbol)
fail ArgumentError, 'invalid value for "just_symbol", must be one of #{validator.allowable_values}.'
fail ArgumentError, "invalid value for \"just_symbol\", must be one of #{validator.allowable_values}."
end
@just_symbol = just_symbol
end
@ -116,11 +123,18 @@ module Petstore
end
# Calculates hash code according to all attributes.
# @return [Fixnum] Hash code
# @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
@ -128,7 +142,7 @@ module Petstore
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 the attribute
# 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) })
@ -157,7 +171,7 @@ module Petstore
value.to_i
when :Float
value.to_f
when :BOOLEAN
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
@ -178,8 +192,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -3,10 +3,10 @@
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 3.3.3-SNAPSHOT
OpenAPI Generator version: 4.1.0-SNAPSHOT
=end
@ -14,10 +14,16 @@ require 'date'
module Petstore
class EnumClass
ABC = "_abc".freeze
EFG = "-efg".freeze
XYZ = "(xyz)".freeze
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

View File

@ -3,10 +3,10 @@
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 3.3.3-SNAPSHOT
OpenAPI Generator version: 4.1.0-SNAPSHOT
=end
@ -71,29 +71,36 @@ module Petstore
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
return unless attributes.is_a?(Hash)
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::EnumTest` initialize method"
end
# convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
# 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.has_key?(:'enum_string')
if attributes.key?(:'enum_string')
self.enum_string = attributes[:'enum_string']
end
if attributes.has_key?(:'enum_string_required')
if attributes.key?(:'enum_string_required')
self.enum_string_required = attributes[:'enum_string_required']
end
if attributes.has_key?(:'enum_integer')
if attributes.key?(:'enum_integer')
self.enum_integer = attributes[:'enum_integer']
end
if attributes.has_key?(:'enum_number')
if attributes.key?(:'enum_number')
self.enum_number = attributes[:'enum_number']
end
if attributes.has_key?(:'outerEnum')
self.outer_enum = attributes[:'outerEnum']
if attributes.key?(:'outer_enum')
self.outer_enum = attributes[:'outer_enum']
end
end
@ -111,14 +118,14 @@ module Petstore
# 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', ''])
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', ''])
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'])
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'])
enum_number_validator = EnumAttributeValidator.new('Float', [1.1, -1.2])
return false unless enum_number_validator.valid?(@enum_number)
true
end
@ -126,9 +133,9 @@ module Petstore
# 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', ''])
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}.'
fail ArgumentError, "invalid value for \"enum_string\", must be one of #{validator.allowable_values}."
end
@enum_string = enum_string
end
@ -136,9 +143,9 @@ module Petstore
# 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', ''])
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}.'
fail ArgumentError, "invalid value for \"enum_string_required\", must be one of #{validator.allowable_values}."
end
@enum_string_required = enum_string_required
end
@ -146,9 +153,9 @@ module Petstore
# 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'])
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}.'
fail ArgumentError, "invalid value for \"enum_integer\", must be one of #{validator.allowable_values}."
end
@enum_integer = enum_integer
end
@ -156,9 +163,9 @@ module Petstore
# 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'])
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}.'
fail ArgumentError, "invalid value for \"enum_number\", must be one of #{validator.allowable_values}."
end
@enum_number = enum_number
end
@ -182,11 +189,18 @@ module Petstore
end
# Calculates hash code according to all attributes.
# @return [Fixnum] Hash code
# @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
@ -194,7 +208,7 @@ module Petstore
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 the attribute
# 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) })
@ -223,7 +237,7 @@ module Petstore
value.to_i
when :Float
value.to_f
when :BOOLEAN
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
@ -244,8 +258,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

View File

@ -3,10 +3,10 @@
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
OpenAPI spec version: 1.0.0
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 3.3.3-SNAPSHOT
OpenAPI Generator version: 4.1.0-SNAPSHOT
=end
@ -35,13 +35,20 @@ module Petstore
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
return unless attributes.is_a?(Hash)
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::File` initialize method"
end
# convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
# 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.has_key?(:'sourceURI')
self.source_uri = attributes[:'sourceURI']
if attributes.key?(:'source_uri')
self.source_uri = attributes[:'source_uri']
end
end
@ -73,11 +80,18 @@ module Petstore
end
# Calculates hash code according to all attributes.
# @return [Fixnum] Hash code
# @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
@ -85,7 +99,7 @@ module Petstore
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 the attribute
# 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) })
@ -114,7 +128,7 @@ module Petstore
value.to_i
when :Float
value.to_f
when :BOOLEAN
when :Boolean
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
@ -135,8 +149,7 @@ module Petstore
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
Petstore.const_get(type).build_from_hash(value)
end
end

Some files were not shown because too many files have changed in this diff Show More