package-test-ruby 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +28 -0
- data/README.md +174 -0
- data/bin/console +15 -0
- data/lib/swagger_petstore_open_api30/api_helper.rb +10 -0
- data/lib/swagger_petstore_open_api30/client.rb +90 -0
- data/lib/swagger_petstore_open_api30/configuration.rb +173 -0
- data/lib/swagger_petstore_open_api30/controllers/base_controller.rb +60 -0
- data/lib/swagger_petstore_open_api30/controllers/pet_controller.rb +271 -0
- data/lib/swagger_petstore_open_api30/controllers/store_controller.rb +125 -0
- data/lib/swagger_petstore_open_api30/controllers/user_controller.rb +223 -0
- data/lib/swagger_petstore_open_api30/exceptions/api_exception.rb +21 -0
- data/lib/swagger_petstore_open_api30/exceptions/o_auth_provider_exception.rb +64 -0
- data/lib/swagger_petstore_open_api30/http/auth/api_key.rb +52 -0
- data/lib/swagger_petstore_open_api30/http/auth/petstore_auth.rb +113 -0
- data/lib/swagger_petstore_open_api30/http/http_call_back.rb +10 -0
- data/lib/swagger_petstore_open_api30/http/http_method_enum.rb +10 -0
- data/lib/swagger_petstore_open_api30/http/http_request.rb +10 -0
- data/lib/swagger_petstore_open_api30/http/http_response.rb +10 -0
- data/lib/swagger_petstore_open_api30/http/proxy_settings.rb +22 -0
- data/lib/swagger_petstore_open_api30/models/api_response.rb +101 -0
- data/lib/swagger_petstore_open_api30/models/base_model.rb +110 -0
- data/lib/swagger_petstore_open_api30/models/category.rb +88 -0
- data/lib/swagger_petstore_open_api30/models/o_auth_provider_error_enum.rb +62 -0
- data/lib/swagger_petstore_open_api30/models/o_auth_scope_petstore_auth_enum.rb +36 -0
- data/lib/swagger_petstore_open_api30/models/o_auth_token.rb +125 -0
- data/lib/swagger_petstore_open_api30/models/order.rb +151 -0
- data/lib/swagger_petstore_open_api30/models/pet.rb +151 -0
- data/lib/swagger_petstore_open_api30/models/status1_enum.rb +40 -0
- data/lib/swagger_petstore_open_api30/models/status2_enum.rb +40 -0
- data/lib/swagger_petstore_open_api30/models/status_enum.rb +40 -0
- data/lib/swagger_petstore_open_api30/models/tag.rb +88 -0
- data/lib/swagger_petstore_open_api30/models/user.rb +167 -0
- data/lib/swagger_petstore_open_api30/utilities/date_time_helper.rb +11 -0
- data/lib/swagger_petstore_open_api30/utilities/file_wrapper.rb +28 -0
- data/lib/swagger_petstore_open_api30/utilities/xml_utilities.rb +12 -0
- data/lib/swagger_petstore_open_api30.rb +59 -0
- data/test/controllers/controller_test_base.rb +28 -0
- data/test/controllers/test_pet_controller.rb +50 -0
- data/test/controllers/test_store_controller.rb +55 -0
- data/test/controllers/test_user_controller.rb +156 -0
- data/test/http_response_catcher.rb +19 -0
- metadata +153 -0
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# swagger_petstore_open_api30
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by
|
|
4
|
+
# APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module SwaggerPetstoreOpenApi30
|
|
7
|
+
# User Model.
|
|
8
|
+
class User < BaseModel
|
|
9
|
+
SKIP = Object.new
|
|
10
|
+
private_constant :SKIP
|
|
11
|
+
|
|
12
|
+
# TODO: Write general description for this method
|
|
13
|
+
# @return [Integer]
|
|
14
|
+
attr_accessor :id
|
|
15
|
+
|
|
16
|
+
# TODO: Write general description for this method
|
|
17
|
+
# @return [String]
|
|
18
|
+
attr_accessor :username
|
|
19
|
+
|
|
20
|
+
# TODO: Write general description for this method
|
|
21
|
+
# @return [String]
|
|
22
|
+
attr_accessor :first_name
|
|
23
|
+
|
|
24
|
+
# TODO: Write general description for this method
|
|
25
|
+
# @return [String]
|
|
26
|
+
attr_accessor :last_name
|
|
27
|
+
|
|
28
|
+
# TODO: Write general description for this method
|
|
29
|
+
# @return [String]
|
|
30
|
+
attr_accessor :email
|
|
31
|
+
|
|
32
|
+
# TODO: Write general description for this method
|
|
33
|
+
# @return [String]
|
|
34
|
+
attr_accessor :password
|
|
35
|
+
|
|
36
|
+
# TODO: Write general description for this method
|
|
37
|
+
# @return [String]
|
|
38
|
+
attr_accessor :phone
|
|
39
|
+
|
|
40
|
+
# User Status
|
|
41
|
+
# @return [Integer]
|
|
42
|
+
attr_accessor :user_status
|
|
43
|
+
|
|
44
|
+
# A mapping from model property names to API property names.
|
|
45
|
+
def self.names
|
|
46
|
+
@_hash = {} if @_hash.nil?
|
|
47
|
+
@_hash['id'] = 'id'
|
|
48
|
+
@_hash['username'] = 'username'
|
|
49
|
+
@_hash['first_name'] = 'firstName'
|
|
50
|
+
@_hash['last_name'] = 'lastName'
|
|
51
|
+
@_hash['email'] = 'email'
|
|
52
|
+
@_hash['password'] = 'password'
|
|
53
|
+
@_hash['phone'] = 'phone'
|
|
54
|
+
@_hash['user_status'] = 'userStatus'
|
|
55
|
+
@_hash
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# An array for optional fields
|
|
59
|
+
def self.optionals
|
|
60
|
+
%w[
|
|
61
|
+
id
|
|
62
|
+
username
|
|
63
|
+
first_name
|
|
64
|
+
last_name
|
|
65
|
+
email
|
|
66
|
+
password
|
|
67
|
+
phone
|
|
68
|
+
user_status
|
|
69
|
+
]
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# An array for nullable fields
|
|
73
|
+
def self.nullables
|
|
74
|
+
[]
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def initialize(id = SKIP, username = SKIP, first_name = SKIP,
|
|
78
|
+
last_name = SKIP, email = SKIP, password = SKIP,
|
|
79
|
+
phone = SKIP, user_status = SKIP)
|
|
80
|
+
@id = id unless id == SKIP
|
|
81
|
+
@username = username unless username == SKIP
|
|
82
|
+
@first_name = first_name unless first_name == SKIP
|
|
83
|
+
@last_name = last_name unless last_name == SKIP
|
|
84
|
+
@email = email unless email == SKIP
|
|
85
|
+
@password = password unless password == SKIP
|
|
86
|
+
@phone = phone unless phone == SKIP
|
|
87
|
+
@user_status = user_status unless user_status == SKIP
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
# Creates an instance of the object from a hash.
|
|
91
|
+
def self.from_hash(hash)
|
|
92
|
+
return nil unless hash
|
|
93
|
+
|
|
94
|
+
# Extract variables from the hash.
|
|
95
|
+
id = hash.key?('id') ? hash['id'] : SKIP
|
|
96
|
+
username = hash.key?('username') ? hash['username'] : SKIP
|
|
97
|
+
first_name = hash.key?('firstName') ? hash['firstName'] : SKIP
|
|
98
|
+
last_name = hash.key?('lastName') ? hash['lastName'] : SKIP
|
|
99
|
+
email = hash.key?('email') ? hash['email'] : SKIP
|
|
100
|
+
password = hash.key?('password') ? hash['password'] : SKIP
|
|
101
|
+
phone = hash.key?('phone') ? hash['phone'] : SKIP
|
|
102
|
+
user_status = hash.key?('userStatus') ? hash['userStatus'] : SKIP
|
|
103
|
+
|
|
104
|
+
# Create object from extracted values.
|
|
105
|
+
User.new(id,
|
|
106
|
+
username,
|
|
107
|
+
first_name,
|
|
108
|
+
last_name,
|
|
109
|
+
email,
|
|
110
|
+
password,
|
|
111
|
+
phone,
|
|
112
|
+
user_status)
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def self.from_element(root)
|
|
116
|
+
id = XmlUtilities.from_element(root, 'id', Integer)
|
|
117
|
+
username = XmlUtilities.from_element(root, 'username', String)
|
|
118
|
+
first_name = XmlUtilities.from_element(root, 'firstName', String)
|
|
119
|
+
last_name = XmlUtilities.from_element(root, 'lastName', String)
|
|
120
|
+
email = XmlUtilities.from_element(root, 'email', String)
|
|
121
|
+
password = XmlUtilities.from_element(root, 'password', String)
|
|
122
|
+
phone = XmlUtilities.from_element(root, 'phone', String)
|
|
123
|
+
user_status = XmlUtilities.from_element(root, 'userStatus', Integer)
|
|
124
|
+
|
|
125
|
+
new(id,
|
|
126
|
+
username,
|
|
127
|
+
first_name,
|
|
128
|
+
last_name,
|
|
129
|
+
email,
|
|
130
|
+
password,
|
|
131
|
+
phone,
|
|
132
|
+
user_status)
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
def to_xml_element(doc, root_name)
|
|
136
|
+
root = doc.create_element(root_name)
|
|
137
|
+
|
|
138
|
+
XmlUtilities.add_as_subelement(doc, root, 'id', id)
|
|
139
|
+
XmlUtilities.add_as_subelement(doc, root, 'username', username)
|
|
140
|
+
XmlUtilities.add_as_subelement(doc, root, 'firstName', first_name)
|
|
141
|
+
XmlUtilities.add_as_subelement(doc, root, 'lastName', last_name)
|
|
142
|
+
XmlUtilities.add_as_subelement(doc, root, 'email', email)
|
|
143
|
+
XmlUtilities.add_as_subelement(doc, root, 'password', password)
|
|
144
|
+
XmlUtilities.add_as_subelement(doc, root, 'phone', phone)
|
|
145
|
+
XmlUtilities.add_as_subelement(doc, root, 'userStatus', user_status)
|
|
146
|
+
|
|
147
|
+
root
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
# Provides a human-readable string representation of the object.
|
|
151
|
+
def to_s
|
|
152
|
+
class_name = self.class.name.split('::').last
|
|
153
|
+
"<#{class_name} id: #{@id}, username: #{@username}, first_name: #{@first_name}, last_name:"\
|
|
154
|
+
" #{@last_name}, email: #{@email}, password: #{@password}, phone: #{@phone}, user_status:"\
|
|
155
|
+
" #{@user_status}>"
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
# Provides a debugging-friendly string with detailed object information.
|
|
159
|
+
def inspect
|
|
160
|
+
class_name = self.class.name.split('::').last
|
|
161
|
+
"<#{class_name} id: #{@id.inspect}, username: #{@username.inspect}, first_name:"\
|
|
162
|
+
" #{@first_name.inspect}, last_name: #{@last_name.inspect}, email: #{@email.inspect},"\
|
|
163
|
+
" password: #{@password.inspect}, phone: #{@phone.inspect}, user_status:"\
|
|
164
|
+
" #{@user_status.inspect}>"
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# swagger_petstore_open_api30
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by
|
|
4
|
+
# APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
require 'date'
|
|
7
|
+
module SwaggerPetstoreOpenApi30
|
|
8
|
+
# A utility that supports dateTime conversion to different formats
|
|
9
|
+
class DateTimeHelper < CoreLibrary::DateTimeHelper
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# swagger_petstore_open_api30
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by
|
|
4
|
+
# APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module SwaggerPetstoreOpenApi30
|
|
7
|
+
# A utility to allow users to set the content-type for files
|
|
8
|
+
class FileWrapper < CoreLibrary::FileWrapper
|
|
9
|
+
# The constructor.
|
|
10
|
+
# @param [File] file The file to be sent in the request.
|
|
11
|
+
# @param [string] content_type The content type of the provided file.
|
|
12
|
+
def initialize(file, content_type: 'application/octet-stream')
|
|
13
|
+
super
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Provides a human-readable string representation of the object.
|
|
17
|
+
def to_s
|
|
18
|
+
class_name = self.class.name.split('::').last
|
|
19
|
+
"<#{class_name} file: #{@file}, content_type: #{@content_type}>"
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Provides a debugging-friendly string with detailed object information.
|
|
23
|
+
def to_inspect
|
|
24
|
+
class_name = self.class.name.split('::').last
|
|
25
|
+
"<#{class_name} file: #{@file.inspect}, content_type: #{@content_type.inspect}>"
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# swagger_petstore_open_api30
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by
|
|
4
|
+
# APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
require 'nokogiri'
|
|
7
|
+
|
|
8
|
+
module SwaggerPetstoreOpenApi30
|
|
9
|
+
# A utility class for handling xml parsing.
|
|
10
|
+
class XmlUtilities < CoreLibrary::XmlHelper
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# swagger_petstore_open_api30
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by
|
|
4
|
+
# APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
require 'date'
|
|
7
|
+
require 'json'
|
|
8
|
+
|
|
9
|
+
require 'apimatic_core_interfaces'
|
|
10
|
+
require 'apimatic_core'
|
|
11
|
+
require 'apimatic_faraday_client_adapter'
|
|
12
|
+
|
|
13
|
+
require_relative 'swagger_petstore_open_api30/api_helper'
|
|
14
|
+
require_relative 'swagger_petstore_open_api30/client'
|
|
15
|
+
|
|
16
|
+
# Utilities
|
|
17
|
+
require_relative 'swagger_petstore_open_api30/utilities/file_wrapper'
|
|
18
|
+
require_relative 'swagger_petstore_open_api30/utilities/date_time_helper'
|
|
19
|
+
require_relative 'swagger_petstore_open_api30/utilities/xml_utilities'
|
|
20
|
+
|
|
21
|
+
# Http
|
|
22
|
+
require_relative 'swagger_petstore_open_api30/http/http_call_back'
|
|
23
|
+
require_relative 'swagger_petstore_open_api30/http/http_method_enum'
|
|
24
|
+
require_relative 'swagger_petstore_open_api30/http/http_request'
|
|
25
|
+
require_relative 'swagger_petstore_open_api30/http/http_response'
|
|
26
|
+
require_relative 'swagger_petstore_open_api30/http/proxy_settings'
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
require_relative 'swagger_petstore_open_api30/http/auth/petstore_auth'
|
|
30
|
+
require_relative 'swagger_petstore_open_api30/http/auth/api_key'
|
|
31
|
+
|
|
32
|
+
# Models
|
|
33
|
+
require_relative 'swagger_petstore_open_api30/models/base_model'
|
|
34
|
+
require_relative 'swagger_petstore_open_api30/models/order'
|
|
35
|
+
require_relative 'swagger_petstore_open_api30/models/category'
|
|
36
|
+
require_relative 'swagger_petstore_open_api30/models/user'
|
|
37
|
+
require_relative 'swagger_petstore_open_api30/models/tag'
|
|
38
|
+
require_relative 'swagger_petstore_open_api30/models/pet'
|
|
39
|
+
require_relative 'swagger_petstore_open_api30/models/api_response'
|
|
40
|
+
require_relative 'swagger_petstore_open_api30/models/o_auth_token'
|
|
41
|
+
require_relative 'swagger_petstore_open_api30/models/status_enum'
|
|
42
|
+
require_relative 'swagger_petstore_open_api30/models/status1_enum'
|
|
43
|
+
require_relative 'swagger_petstore_open_api30/models/status2_enum'
|
|
44
|
+
require_relative 'swagger_petstore_open_api30/models/o_auth_provider_error_enum'
|
|
45
|
+
require_relative 'swagger_petstore_open_api30/models/' \
|
|
46
|
+
'o_auth_scope_petstore_auth_enum'
|
|
47
|
+
|
|
48
|
+
# Exceptions
|
|
49
|
+
require_relative 'swagger_petstore_open_api30/exceptions/api_exception'
|
|
50
|
+
require_relative 'swagger_petstore_open_api30/exceptions/' \
|
|
51
|
+
'o_auth_provider_exception'
|
|
52
|
+
|
|
53
|
+
require_relative 'swagger_petstore_open_api30/configuration'
|
|
54
|
+
|
|
55
|
+
# Controllers
|
|
56
|
+
require_relative 'swagger_petstore_open_api30/controllers/base_controller'
|
|
57
|
+
require_relative 'swagger_petstore_open_api30/controllers/pet_controller'
|
|
58
|
+
require_relative 'swagger_petstore_open_api30/controllers/store_controller'
|
|
59
|
+
require_relative 'swagger_petstore_open_api30/controllers/user_controller'
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# swagger_petstore_open_api30
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by
|
|
4
|
+
# APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
require 'json'
|
|
7
|
+
require 'minitest/autorun'
|
|
8
|
+
require 'minitest/hell'
|
|
9
|
+
require 'minitest/pride'
|
|
10
|
+
require 'minitest/proveit'
|
|
11
|
+
require 'swagger_petstore_open_api30'
|
|
12
|
+
require_relative '../http_response_catcher'
|
|
13
|
+
|
|
14
|
+
class ControllerTestBase < Minitest::Test
|
|
15
|
+
parallelize_me!
|
|
16
|
+
include SwaggerPetstoreOpenApi30
|
|
17
|
+
include CoreLibrary
|
|
18
|
+
|
|
19
|
+
# Initializes the base test controller
|
|
20
|
+
def setup_class
|
|
21
|
+
@client = Client.from_env(http_callback: HttpResponseCatcher.new)
|
|
22
|
+
|
|
23
|
+
_config = @client.config
|
|
24
|
+
petstore_auth_token = @client.petstore_auth.fetch_token()
|
|
25
|
+
petstore_auth_credentials = _config.petstore_auth_credentials.clone_with(o_auth_token: petstore_auth_token)
|
|
26
|
+
_config = _config.clone_with(petstore_auth_credentials: petstore_auth_credentials)
|
|
27
|
+
@client = Client.new(config: _config)
|
|
28
|
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# swagger_petstore_open_api30
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by
|
|
4
|
+
# APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
require_relative 'controller_test_base'
|
|
7
|
+
|
|
8
|
+
class PetControllerTest < ControllerTestBase
|
|
9
|
+
# Called only once for the class before any test has executed
|
|
10
|
+
def setup
|
|
11
|
+
setup_class
|
|
12
|
+
@controller = @client.pet
|
|
13
|
+
@response_catcher = @controller.http_call_back
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Multiple status values can be provided with comma separated strings.
|
|
17
|
+
def test_find_pets_by_status
|
|
18
|
+
# Parameters for the API call
|
|
19
|
+
status = 'available'
|
|
20
|
+
|
|
21
|
+
# Perform the API call through the SDK function
|
|
22
|
+
result = @controller.find_pets_by_status(status)
|
|
23
|
+
|
|
24
|
+
# Test response code
|
|
25
|
+
assert_equal(200, @response_catcher.response.status_code)
|
|
26
|
+
# Test headers
|
|
27
|
+
expected_headers = {}
|
|
28
|
+
expected_headers['content-type'] = 'application/json; charset=utf-8'
|
|
29
|
+
|
|
30
|
+
assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Multiple status values can be provided with comma separated strings.
|
|
34
|
+
def test_find_pets_by_status1
|
|
35
|
+
# Parameters for the API call
|
|
36
|
+
status = 'available'
|
|
37
|
+
|
|
38
|
+
# Perform the API call through the SDK function
|
|
39
|
+
result = @controller.find_pets_by_status(status)
|
|
40
|
+
|
|
41
|
+
# Test response code
|
|
42
|
+
assert_equal(200, @response_catcher.response.status_code)
|
|
43
|
+
# Test headers
|
|
44
|
+
expected_headers = {}
|
|
45
|
+
expected_headers['content-type'] = 'application/xml'
|
|
46
|
+
|
|
47
|
+
assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# swagger_petstore_open_api30
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by
|
|
4
|
+
# APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
require_relative 'controller_test_base'
|
|
7
|
+
|
|
8
|
+
class StoreControllerTest < ControllerTestBase
|
|
9
|
+
# Called only once for the class before any test has executed
|
|
10
|
+
def setup
|
|
11
|
+
setup_class
|
|
12
|
+
@controller = @client.store
|
|
13
|
+
@response_catcher = @controller.http_call_back
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Returns a map of status codes to quantities.
|
|
17
|
+
def test_get_inventory
|
|
18
|
+
|
|
19
|
+
# Perform the API call through the SDK function
|
|
20
|
+
result = @controller.get_inventory()
|
|
21
|
+
|
|
22
|
+
# Test response code
|
|
23
|
+
assert_equal(200, @response_catcher.response.status_code)
|
|
24
|
+
# Test headers
|
|
25
|
+
expected_headers = {}
|
|
26
|
+
expected_headers['content-type'] = 'application/json; charset=utf-8'
|
|
27
|
+
|
|
28
|
+
assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Place a new order in the store.
|
|
32
|
+
def test_place_order
|
|
33
|
+
# Parameters for the API call
|
|
34
|
+
id = 10
|
|
35
|
+
pet_id = 198772
|
|
36
|
+
quantity = 7
|
|
37
|
+
ship_date = nil
|
|
38
|
+
status = nil
|
|
39
|
+
complete = nil
|
|
40
|
+
|
|
41
|
+
# Perform the API call through the SDK function
|
|
42
|
+
result = @controller.place_order(id: id, pet_id: pet_id, quantity: quantity,
|
|
43
|
+
ship_date: ship_date, status: status,
|
|
44
|
+
complete: complete)
|
|
45
|
+
|
|
46
|
+
# Test response code
|
|
47
|
+
assert_equal(200, @response_catcher.response.status_code)
|
|
48
|
+
# Test headers
|
|
49
|
+
expected_headers = {}
|
|
50
|
+
expected_headers['content-type'] = 'application/json; charset=utf-8'
|
|
51
|
+
|
|
52
|
+
assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
end
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# swagger_petstore_open_api30
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by
|
|
4
|
+
# APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
require_relative 'controller_test_base'
|
|
7
|
+
|
|
8
|
+
class UserControllerTest < ControllerTestBase
|
|
9
|
+
# Called only once for the class before any test has executed
|
|
10
|
+
def setup
|
|
11
|
+
setup_class
|
|
12
|
+
@controller = @client.user
|
|
13
|
+
@response_catcher = @controller.http_call_back
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# This can only be done by the logged in user.
|
|
17
|
+
def test_create_user
|
|
18
|
+
# Parameters for the API call
|
|
19
|
+
id = 10
|
|
20
|
+
username = 'theUser'
|
|
21
|
+
first_name = 'John'
|
|
22
|
+
last_name = 'James'
|
|
23
|
+
email = 'john@email.com'
|
|
24
|
+
password = '12345'
|
|
25
|
+
phone = '12345'
|
|
26
|
+
user_status = 1
|
|
27
|
+
|
|
28
|
+
# Perform the API call through the SDK function
|
|
29
|
+
result = @controller.create_user(id: id, username: username,
|
|
30
|
+
first_name: first_name,
|
|
31
|
+
last_name: last_name, email: email,
|
|
32
|
+
password: password, phone: phone,
|
|
33
|
+
user_status: user_status)
|
|
34
|
+
|
|
35
|
+
# Test response code
|
|
36
|
+
assert_equal(200, @response_catcher.response.status_code)
|
|
37
|
+
# Test headers
|
|
38
|
+
expected_headers = {}
|
|
39
|
+
expected_headers['content-type'] = 'application/json; charset=utf-8'
|
|
40
|
+
|
|
41
|
+
assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# This can only be done by the logged in user.
|
|
45
|
+
def test_create_user1
|
|
46
|
+
# Parameters for the API call
|
|
47
|
+
id = 10
|
|
48
|
+
username = 'theUser'
|
|
49
|
+
first_name = 'John'
|
|
50
|
+
last_name = 'James'
|
|
51
|
+
email = 'john@email.com'
|
|
52
|
+
password = '12345'
|
|
53
|
+
phone = '12345'
|
|
54
|
+
user_status = 1
|
|
55
|
+
|
|
56
|
+
# Perform the API call through the SDK function
|
|
57
|
+
result = @controller.create_user(id: id, username: username,
|
|
58
|
+
first_name: first_name,
|
|
59
|
+
last_name: last_name, email: email,
|
|
60
|
+
password: password, phone: phone,
|
|
61
|
+
user_status: user_status)
|
|
62
|
+
|
|
63
|
+
# Test response code
|
|
64
|
+
assert_equal(200, @response_catcher.response.status_code)
|
|
65
|
+
# Test headers
|
|
66
|
+
expected_headers = {}
|
|
67
|
+
expected_headers['content-type'] = 'application/xml'
|
|
68
|
+
|
|
69
|
+
assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# Creates list of users with given input array.
|
|
73
|
+
def test_create_users_with_list_input
|
|
74
|
+
# Parameters for the API call
|
|
75
|
+
body = nil
|
|
76
|
+
|
|
77
|
+
# Perform the API call through the SDK function
|
|
78
|
+
result = @controller.create_users_with_list_input(body: body)
|
|
79
|
+
|
|
80
|
+
# Test response code
|
|
81
|
+
assert_equal(200, @response_catcher.response.status_code)
|
|
82
|
+
# Test headers
|
|
83
|
+
expected_headers = {}
|
|
84
|
+
expected_headers['content-type'] = 'application/json; charset=utf-8'
|
|
85
|
+
|
|
86
|
+
assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# Creates list of users with given input array.
|
|
90
|
+
def test_create_users_with_list_input1
|
|
91
|
+
# Parameters for the API call
|
|
92
|
+
body = nil
|
|
93
|
+
|
|
94
|
+
# Perform the API call through the SDK function
|
|
95
|
+
result = @controller.create_users_with_list_input(body: body)
|
|
96
|
+
|
|
97
|
+
# Test response code
|
|
98
|
+
assert_equal(200, @response_catcher.response.status_code)
|
|
99
|
+
# Test headers
|
|
100
|
+
expected_headers = {}
|
|
101
|
+
expected_headers['content-type'] = 'application/xml'
|
|
102
|
+
|
|
103
|
+
assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
# Log into the system.
|
|
107
|
+
def test_login_user
|
|
108
|
+
# Parameters for the API call
|
|
109
|
+
username = nil
|
|
110
|
+
password = nil
|
|
111
|
+
|
|
112
|
+
# Perform the API call through the SDK function
|
|
113
|
+
result = @controller.login_user(username: username, password: password)
|
|
114
|
+
|
|
115
|
+
# Test response code
|
|
116
|
+
assert_equal(200, @response_catcher.response.status_code)
|
|
117
|
+
# Test headers
|
|
118
|
+
expected_headers = {}
|
|
119
|
+
expected_headers['x-rate-limit'] = nil
|
|
120
|
+
expected_headers['x-expires-after'] = nil
|
|
121
|
+
expected_headers['content-type'] = 'application/xml'
|
|
122
|
+
|
|
123
|
+
assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
# Log into the system.
|
|
127
|
+
def test_login_user1
|
|
128
|
+
# Parameters for the API call
|
|
129
|
+
username = nil
|
|
130
|
+
password = nil
|
|
131
|
+
|
|
132
|
+
# Perform the API call through the SDK function
|
|
133
|
+
result = @controller.login_user(username: username, password: password)
|
|
134
|
+
|
|
135
|
+
# Test response code
|
|
136
|
+
assert_equal(200, @response_catcher.response.status_code)
|
|
137
|
+
# Test headers
|
|
138
|
+
expected_headers = {}
|
|
139
|
+
expected_headers['x-rate-limit'] = nil
|
|
140
|
+
expected_headers['x-expires-after'] = nil
|
|
141
|
+
expected_headers['content-type'] = 'application/json; charset=utf-8'
|
|
142
|
+
|
|
143
|
+
assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
# Log user out of the system.
|
|
147
|
+
def test_logout_user
|
|
148
|
+
|
|
149
|
+
# Perform the API call through the SDK function
|
|
150
|
+
@controller.logout_user()
|
|
151
|
+
|
|
152
|
+
# Test response code
|
|
153
|
+
assert_equal(200, @response_catcher.response.status_code)
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# swagger_petstore_open_api30
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by
|
|
4
|
+
# APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
class HttpResponseCatcher < SwaggerPetstoreOpenApi30::HttpCallBack
|
|
7
|
+
attr_reader :response
|
|
8
|
+
|
|
9
|
+
def on_before_request(request)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# Catching the response
|
|
13
|
+
def on_after_response(response)
|
|
14
|
+
@response = response
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|