kuapir 0.1.2

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.
Files changed (190) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +13 -0
  3. data/Gemfile.lock +77 -0
  4. data/LICENSE +21 -0
  5. data/README.md +170 -0
  6. data/Rakefile +12 -0
  7. data/docs/BoxOffice.md +26 -0
  8. data/docs/BoxOfficeResponse.md +20 -0
  9. data/docs/Company.md +18 -0
  10. data/docs/Country.md +18 -0
  11. data/docs/DigitalReleaseItem.md +44 -0
  12. data/docs/DigitalReleaseResponse.md +22 -0
  13. data/docs/Distribution.md +28 -0
  14. data/docs/DistributionResponse.md +20 -0
  15. data/docs/Episode.md +28 -0
  16. data/docs/Fact.md +22 -0
  17. data/docs/FactResponse.md +20 -0
  18. data/docs/Film.md +100 -0
  19. data/docs/FilmSearchByFiltersResponse.md +22 -0
  20. data/docs/FilmSearchByFiltersResponseItems.md +42 -0
  21. data/docs/FilmSearchResponse.md +24 -0
  22. data/docs/FilmSearchResponseFilms.md +42 -0
  23. data/docs/FilmSequelsAndPrequelsResponse.md +30 -0
  24. data/docs/FilmTopResponse.md +20 -0
  25. data/docs/FilmTopResponseFilms.md +38 -0
  26. data/docs/FilmsApi.md +1126 -0
  27. data/docs/FiltersResponse.md +20 -0
  28. data/docs/FiltersResponseCountries.md +20 -0
  29. data/docs/FiltersResponseGenres.md +20 -0
  30. data/docs/Genre.md +18 -0
  31. data/docs/ImageResponse.md +22 -0
  32. data/docs/ImageResponseItems.md +20 -0
  33. data/docs/PersonByNameResponse.md +20 -0
  34. data/docs/PersonByNameResponseItems.md +28 -0
  35. data/docs/PersonResponse.md +50 -0
  36. data/docs/PersonResponseFilms.md +30 -0
  37. data/docs/PersonResponseSpouses.md +32 -0
  38. data/docs/PersonsApi.md +83 -0
  39. data/docs/PremiereResponse.md +20 -0
  40. data/docs/PremiereResponseItem.md +36 -0
  41. data/docs/RelatedFilmResponse.md +20 -0
  42. data/docs/RelatedFilmResponseItems.md +30 -0
  43. data/docs/ReviewDetailsResponse.md +32 -0
  44. data/docs/ReviewsApi.md +155 -0
  45. data/docs/ReviewsResponse.md +34 -0
  46. data/docs/ReviewsResponseReviews.md +32 -0
  47. data/docs/Season.md +20 -0
  48. data/docs/SeasonResponse.md +20 -0
  49. data/docs/StaffApi.md +147 -0
  50. data/docs/StaffResponse.md +30 -0
  51. data/docs/VideoResponse.md +20 -0
  52. data/docs/VideoResponseItems.md +22 -0
  53. data/kinopoiskapiunofficial-openapi.json +2918 -0
  54. data/kuapir.gemspec +42 -0
  55. data/lib/kuapir/api/films_api.rb +1193 -0
  56. data/lib/kuapir/api/persons_api.rb +89 -0
  57. data/lib/kuapir/api/reviews_api.rb +165 -0
  58. data/lib/kuapir/api/staff_api.rb +145 -0
  59. data/lib/kuapir/api_client.rb +390 -0
  60. data/lib/kuapir/api_error.rb +57 -0
  61. data/lib/kuapir/configuration.rb +287 -0
  62. data/lib/kuapir/models/box_office.rb +246 -0
  63. data/lib/kuapir/models/box_office_response.rb +224 -0
  64. data/lib/kuapir/models/company.rb +214 -0
  65. data/lib/kuapir/models/country.rb +214 -0
  66. data/lib/kuapir/models/digital_release_item.rb +334 -0
  67. data/lib/kuapir/models/digital_release_response.rb +232 -0
  68. data/lib/kuapir/models/distribution.rb +300 -0
  69. data/lib/kuapir/models/distribution_response.rb +224 -0
  70. data/lib/kuapir/models/episode.rb +249 -0
  71. data/lib/kuapir/models/fact.rb +266 -0
  72. data/lib/kuapir/models/fact_response.rb +224 -0
  73. data/lib/kuapir/models/film.rb +551 -0
  74. data/lib/kuapir/models/film_search_by_filters_response.rb +232 -0
  75. data/lib/kuapir/models/film_search_by_filters_response_items.rb +319 -0
  76. data/lib/kuapir/models/film_search_response.rb +244 -0
  77. data/lib/kuapir/models/film_search_response_films.rb +311 -0
  78. data/lib/kuapir/models/film_sequels_and_prequels_response.rb +300 -0
  79. data/lib/kuapir/models/film_top_response.rb +224 -0
  80. data/lib/kuapir/models/film_top_response_films.rb +272 -0
  81. data/lib/kuapir/models/filters_response.rb +226 -0
  82. data/lib/kuapir/models/filters_response_countries.rb +214 -0
  83. data/lib/kuapir/models/filters_response_genres.rb +214 -0
  84. data/lib/kuapir/models/genre.rb +214 -0
  85. data/lib/kuapir/models/image_response.rb +238 -0
  86. data/lib/kuapir/models/image_response_items.rb +214 -0
  87. data/lib/kuapir/models/person_by_name_response.rb +224 -0
  88. data/lib/kuapir/models/person_by_name_response_items.rb +274 -0
  89. data/lib/kuapir/models/person_response.rb +363 -0
  90. data/lib/kuapir/models/person_response_films.rb +284 -0
  91. data/lib/kuapir/models/person_response_spouses.rb +283 -0
  92. data/lib/kuapir/models/premiere_response.rb +224 -0
  93. data/lib/kuapir/models/premiere_response_item.rb +289 -0
  94. data/lib/kuapir/models/related_film_response.rb +224 -0
  95. data/lib/kuapir/models/related_film_response_items.rb +279 -0
  96. data/lib/kuapir/models/review_details_response.rb +314 -0
  97. data/lib/kuapir/models/reviews_response.rb +294 -0
  98. data/lib/kuapir/models/reviews_response_reviews.rb +282 -0
  99. data/lib/kuapir/models/season.rb +224 -0
  100. data/lib/kuapir/models/season_response.rb +224 -0
  101. data/lib/kuapir/models/staff_response.rb +301 -0
  102. data/lib/kuapir/models/video_response.rb +224 -0
  103. data/lib/kuapir/models/video_response_items.rb +255 -0
  104. data/lib/kuapir/version.rb +5 -0
  105. data/lib/kuapir.rb +83 -0
  106. data/openapi-generator-templates/Gemfile.mustache +9 -0
  107. data/openapi-generator-templates/README.mustache +148 -0
  108. data/openapi-generator-templates/Rakefile.mustache +10 -0
  109. data/openapi-generator-templates/api.mustache +205 -0
  110. data/openapi-generator-templates/api_client.mustache +260 -0
  111. data/openapi-generator-templates/api_client_faraday_partial.mustache +136 -0
  112. data/openapi-generator-templates/api_client_spec.mustache +216 -0
  113. data/openapi-generator-templates/api_client_typhoeus_partial.mustache +153 -0
  114. data/openapi-generator-templates/api_doc.mustache +118 -0
  115. data/openapi-generator-templates/api_error.mustache +45 -0
  116. data/openapi-generator-templates/api_info.mustache +12 -0
  117. data/openapi-generator-templates/api_test.mustache +43 -0
  118. data/openapi-generator-templates/base_object.mustache +120 -0
  119. data/openapi-generator-templates/configuration.mustache +381 -0
  120. data/openapi-generator-templates/configuration_spec.mustache +30 -0
  121. data/openapi-generator-templates/configuration_tls_faraday_partial.mustache +29 -0
  122. data/openapi-generator-templates/configuration_tls_typhoeus_partial.mustache +34 -0
  123. data/openapi-generator-templates/gem.mustache +50 -0
  124. data/openapi-generator-templates/gemspec.mustache +31 -0
  125. data/openapi-generator-templates/git_push.sh.mustache +57 -0
  126. data/openapi-generator-templates/gitignore.mustache +39 -0
  127. data/openapi-generator-templates/model.mustache +22 -0
  128. data/openapi-generator-templates/model_doc.mustache +12 -0
  129. data/openapi-generator-templates/model_test.mustache +73 -0
  130. data/openapi-generator-templates/partial_model_enum_class.mustache +20 -0
  131. data/openapi-generator-templates/partial_model_generic.mustache +371 -0
  132. data/openapi-generator-templates/partial_model_generic_doc.mustache +28 -0
  133. data/openapi-generator-templates/partial_oneof_module.mustache +137 -0
  134. data/openapi-generator-templates/partial_oneof_module_doc.mustache +92 -0
  135. data/openapi-generator-templates/rspec.mustache +2 -0
  136. data/openapi-generator-templates/rubocop.mustache +148 -0
  137. data/openapi-generator-templates/spec_helper.mustache +99 -0
  138. data/openapi-generator-templates/travis.mustache +14 -0
  139. data/openapi-generator-templates/version.mustache +3 -0
  140. data/openapitools.json +21 -0
  141. data/spec/api/films_api_spec.rb +227 -0
  142. data/spec/api/persons_api_spec.rb +45 -0
  143. data/spec/api/reviews_api_spec.rb +57 -0
  144. data/spec/api/staff_api_spec.rb +54 -0
  145. data/spec/api_client_spec.rb +229 -0
  146. data/spec/configuration_spec.rb +28 -0
  147. data/spec/models/box_office_response_spec.rb +37 -0
  148. data/spec/models/box_office_spec.rb +55 -0
  149. data/spec/models/company_spec.rb +31 -0
  150. data/spec/models/country_spec.rb +31 -0
  151. data/spec/models/digital_release_item_spec.rb +109 -0
  152. data/spec/models/digital_release_response_spec.rb +43 -0
  153. data/spec/models/distribution_response_spec.rb +37 -0
  154. data/spec/models/distribution_spec.rb +69 -0
  155. data/spec/models/episode_spec.rb +61 -0
  156. data/spec/models/fact_response_spec.rb +37 -0
  157. data/spec/models/fact_spec.rb +47 -0
  158. data/spec/models/film_search_by_filters_response_items_spec.rb +107 -0
  159. data/spec/models/film_search_by_filters_response_spec.rb +43 -0
  160. data/spec/models/film_search_response_films_spec.rb +107 -0
  161. data/spec/models/film_search_response_spec.rb +49 -0
  162. data/spec/models/film_sequels_and_prequels_response_spec.rb +71 -0
  163. data/spec/models/film_spec.rb +285 -0
  164. data/spec/models/film_top_response_films_spec.rb +91 -0
  165. data/spec/models/film_top_response_spec.rb +37 -0
  166. data/spec/models/filters_response_countries_spec.rb +37 -0
  167. data/spec/models/filters_response_genres_spec.rb +37 -0
  168. data/spec/models/filters_response_spec.rb +37 -0
  169. data/spec/models/genre_spec.rb +31 -0
  170. data/spec/models/image_response_items_spec.rb +37 -0
  171. data/spec/models/image_response_spec.rb +43 -0
  172. data/spec/models/person_by_name_response_items_spec.rb +65 -0
  173. data/spec/models/person_by_name_response_spec.rb +37 -0
  174. data/spec/models/person_response_films_spec.rb +71 -0
  175. data/spec/models/person_response_spec.rb +131 -0
  176. data/spec/models/person_response_spouses_spec.rb +77 -0
  177. data/spec/models/premiere_response_item_spec.rb +85 -0
  178. data/spec/models/premiere_response_spec.rb +37 -0
  179. data/spec/models/related_film_response_items_spec.rb +71 -0
  180. data/spec/models/related_film_response_spec.rb +37 -0
  181. data/spec/models/review_details_response_spec.rb +77 -0
  182. data/spec/models/reviews_response_reviews_spec.rb +77 -0
  183. data/spec/models/reviews_response_spec.rb +79 -0
  184. data/spec/models/season_response_spec.rb +37 -0
  185. data/spec/models/season_spec.rb +37 -0
  186. data/spec/models/staff_response_spec.rb +71 -0
  187. data/spec/models/video_response_items_spec.rb +47 -0
  188. data/spec/models/video_response_spec.rb +37 -0
  189. data/spec/spec_helper.rb +107 -0
  190. metadata +326 -0
@@ -0,0 +1,120 @@
1
+ # Builds the object from hash
2
+ # @param [Hash] attributes Model attributes in the form of hash
3
+ # @return [Object] Returns the model itself
4
+ def self.build_from_hash(attributes)
5
+ new.build_from_hash(attributes)
6
+ end
7
+
8
+ # Builds the object from hash
9
+ # @param [Hash] attributes Model attributes in the form of hash
10
+ # @return [Object] Returns the model itself
11
+ def build_from_hash(attributes)
12
+ return nil unless attributes.is_a?(Hash)
13
+ {{#parent}}
14
+ super(attributes)
15
+ {{/parent}}
16
+ self.class.openapi_types.each_pair do |key, type|
17
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
18
+ self.send("#{key}=", nil)
19
+ elsif type =~ /\AArray<(.*)>/i
20
+ # check to ensure the input is an array given that the attribute
21
+ # is documented as an array but the input is not
22
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
23
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
24
+ end
25
+ elsif !attributes[self.class.attribute_map[key]].nil?
26
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
27
+ end
28
+ end
29
+
30
+ self
31
+ end
32
+
33
+ # Deserializes the data based on type
34
+ # @param string type Data type
35
+ # @param string value Value to be deserialized
36
+ # @return [Object] Deserialized data
37
+ def _deserialize(type, value)
38
+ case type.to_sym
39
+ when :Time
40
+ Time.parse(value)
41
+ when :Date
42
+ Date.parse(value)
43
+ when :String
44
+ value.to_s
45
+ when :Integer
46
+ value.to_i
47
+ when :Float
48
+ value.to_f
49
+ when :Boolean
50
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
51
+ true
52
+ else
53
+ false
54
+ end
55
+ when :Object
56
+ # generic object (usually a Hash), return directly
57
+ value
58
+ when /\AArray<(?<inner_type>.+)>\z/
59
+ inner_type = Regexp.last_match[:inner_type]
60
+ value.map { |v| _deserialize(inner_type, v) }
61
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
62
+ k_type = Regexp.last_match[:k_type]
63
+ v_type = Regexp.last_match[:v_type]
64
+ {}.tap do |hash|
65
+ value.each do |k, v|
66
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
67
+ end
68
+ end
69
+ else # model
70
+ # models (e.g. Pet) or oneOf
71
+ klass = {{moduleName}}.const_get(type)
72
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
73
+ end
74
+ end
75
+
76
+ # Returns the string representation of the object
77
+ # @return [String] String presentation of the object
78
+ def to_s
79
+ to_hash.to_s
80
+ end
81
+
82
+ # to_body is an alias to to_hash (backward compatibility)
83
+ # @return [Hash] Returns the object in the form of hash
84
+ def to_body
85
+ to_hash
86
+ end
87
+
88
+ # Returns the object in the form of hash
89
+ # @return [Hash] Returns the object in the form of hash
90
+ def to_hash
91
+ hash = {{^parent}}{}{{/parent}}{{#parent}}super{{/parent}}
92
+ self.class.attribute_map.each_pair do |attr, param|
93
+ value = self.send(attr)
94
+ if value.nil?
95
+ is_nullable = self.class.openapi_nullable.include?(attr)
96
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
97
+ end
98
+
99
+ hash[param] = _to_hash(value)
100
+ end
101
+ hash
102
+ end
103
+
104
+ # Outputs non-array value in the form of hash
105
+ # For object, use to_hash. Otherwise, just return the value
106
+ # @param [Object] value Any valid value
107
+ # @return [Hash] Returns the value in the form of hash
108
+ def _to_hash(value)
109
+ if value.is_a?(Array)
110
+ value.compact.map { |v| _to_hash(v) }
111
+ elsif value.is_a?(Hash)
112
+ {}.tap do |hash|
113
+ value.each { |k, v| hash[k] = _to_hash(v) }
114
+ end
115
+ elsif value.respond_to? :to_hash
116
+ value.to_hash
117
+ else
118
+ value
119
+ end
120
+ end
@@ -0,0 +1,381 @@
1
+ module {{moduleName}}
2
+ class Configuration
3
+ # Defines url scheme
4
+ attr_accessor :scheme
5
+
6
+ # Defines url host
7
+ attr_accessor :host
8
+
9
+ # Defines url base path
10
+ attr_accessor :base_path
11
+
12
+ # Define server configuration index
13
+ attr_accessor :server_index
14
+
15
+ # Define server operation configuration index
16
+ attr_accessor :server_operation_index
17
+
18
+ # Default server variables
19
+ attr_accessor :server_variables
20
+
21
+ # Default server operation variables
22
+ attr_accessor :server_operation_variables
23
+
24
+ # Defines API keys used with API Key authentications.
25
+ #
26
+ # @return [Hash] key: parameter name, value: parameter value (API key)
27
+ #
28
+ # @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
29
+ # config.api_key['api_key'] = 'xxx'
30
+ attr_accessor :api_key
31
+
32
+ # Defines API key prefixes used with API Key authentications.
33
+ #
34
+ # @return [Hash] key: parameter name, value: API key prefix
35
+ #
36
+ # @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
37
+ # config.api_key_prefix['api_key'] = 'Token'
38
+ attr_accessor :api_key_prefix
39
+
40
+ # Defines the username used with HTTP basic authentication.
41
+ #
42
+ # @return [String]
43
+ attr_accessor :username
44
+
45
+ # Defines the password used with HTTP basic authentication.
46
+ #
47
+ # @return [String]
48
+ attr_accessor :password
49
+
50
+ # Defines the access token (Bearer) used with OAuth2.
51
+ attr_accessor :access_token
52
+
53
+ # Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
54
+ # details will be logged with `logger.debug` (see the `logger` attribute).
55
+ # Default to false.
56
+ #
57
+ # @return [true, false]
58
+ attr_accessor :debugging
59
+
60
+ # Defines the logger used for debugging.
61
+ # Default to `Rails.logger` (when in Rails) or logging to STDOUT.
62
+ #
63
+ # @return [#debug]
64
+ attr_accessor :logger
65
+
66
+ # Defines the temporary folder to store downloaded files
67
+ # (for API endpoints that have file response).
68
+ # Default to use `Tempfile`.
69
+ #
70
+ # @return [String]
71
+ attr_accessor :temp_folder_path
72
+
73
+ # The time limit for HTTP request in seconds.
74
+ # Default to 0 (never times out).
75
+ attr_accessor :timeout
76
+
77
+ # Set this to false to skip client side validation in the operation.
78
+ # Default to true.
79
+ # @return [true, false]
80
+ attr_accessor :client_side_validation
81
+
82
+ {{^isFaraday}}
83
+ {{> configuration_tls_typhoeus_partial}}
84
+ {{/isFaraday}}
85
+ {{#isFaraday}}
86
+ {{> configuration_tls_faraday_partial}}
87
+ {{/isFaraday}}
88
+ # Set this to customize parameters encoding of array parameter with multi collectionFormat.
89
+ # Default to nil.
90
+ #
91
+ # @see The params_encoding option of Ethon. Related source code:
92
+ # https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
93
+ attr_accessor :params_encoding
94
+
95
+ attr_accessor :inject_format
96
+
97
+ attr_accessor :force_ending_format
98
+
99
+ def initialize
100
+ @scheme = '{{scheme}}'
101
+ @host = '{{host}}{{#port}}:{{{.}}}{{/port}}'
102
+ @base_path = '{{contextPath}}'
103
+ @server_index = 0
104
+ @server_operation_index = {}
105
+ @server_variables = {}
106
+ @server_operation_variables = {}
107
+ @api_key = {}
108
+ @api_key_prefix = {}
109
+ @client_side_validation = true
110
+ {{#isFaraday}}
111
+ @ssl_verify = true
112
+ @ssl_verify_mode = nil
113
+ @ssl_ca_file = nil
114
+ @ssl_client_cert = nil
115
+ @ssl_client_key = nil
116
+ @middlewares = []
117
+ @request_middlewares = []
118
+ @response_middlewares = []
119
+ @timeout = 60
120
+ {{/isFaraday}}
121
+ {{^isFaraday}}
122
+ @verify_ssl = true
123
+ @verify_ssl_host = true
124
+ @params_encoding = nil
125
+ @cert_file = nil
126
+ @key_file = nil
127
+ @timeout = 0
128
+ {{/isFaraday}}
129
+ @debugging = false
130
+ @inject_format = false
131
+ @force_ending_format = false
132
+ @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
133
+
134
+ yield(self) if block_given?
135
+ end
136
+
137
+ # The default Configuration object.
138
+ def self.default
139
+ @@default ||= Configuration.new
140
+ end
141
+
142
+ def configure
143
+ yield(self) if block_given?
144
+ end
145
+
146
+ def scheme=(scheme)
147
+ # remove :// from scheme
148
+ @scheme = scheme.sub(/:\/\//, '')
149
+ end
150
+
151
+ def host=(host)
152
+ # remove http(s):// and anything after a slash
153
+ @host = host.sub(/https?:\/\//, '').split('/').first
154
+ end
155
+
156
+ def base_path=(base_path)
157
+ # Add leading and trailing slashes to base_path
158
+ @base_path = "/#{base_path}".gsub(/\/+/, '/')
159
+ @base_path = '' if @base_path == '/'
160
+ end
161
+
162
+ # Returns base URL for specified operation based on server settings
163
+ def base_url(operation = nil)
164
+ index = server_operation_index.fetch(operation, server_index)
165
+ return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if index == nil
166
+
167
+ server_url(index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
168
+ end
169
+
170
+ # Gets API key (with prefix if set).
171
+ # @param [String] param_name the parameter name of API key auth
172
+ def api_key_with_prefix(param_name, param_alias = nil)
173
+ key = @api_key[param_name]
174
+ key = @api_key.fetch(param_alias, key) unless param_alias.nil?
175
+ if @api_key_prefix[param_name]
176
+ "#{@api_key_prefix[param_name]} #{key}"
177
+ else
178
+ key
179
+ end
180
+ end
181
+
182
+ # Gets Basic Auth token string
183
+ def basic_auth_token
184
+ 'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
185
+ end
186
+
187
+ # Returns Auth Settings hash for api client.
188
+ def auth_settings
189
+ {
190
+ {{#authMethods}}
191
+ {{#isApiKey}}
192
+ '{{name}}' =>
193
+ {
194
+ type: 'api_key',
195
+ in: {{#isKeyInHeader}}'header'{{/isKeyInHeader}}{{#isKeyInQuery}}'query'{{/isKeyInQuery}},
196
+ key: '{{keyParamName}}',
197
+ value: api_key_with_prefix('{{name}}'{{#vendorExtensions.x-auth-id-alias}}, '{{.}}'{{/vendorExtensions.x-auth-id-alias}})
198
+ },
199
+ {{/isApiKey}}
200
+ {{#isBasic}}
201
+ {{#isBasicBasic}}
202
+ '{{name}}' =>
203
+ {
204
+ type: 'basic',
205
+ in: 'header',
206
+ key: 'Authorization',
207
+ value: basic_auth_token
208
+ },
209
+ {{/isBasicBasic}}
210
+ {{#isBasicBearer}}
211
+ '{{name}}' =>
212
+ {
213
+ type: 'bearer',
214
+ in: 'header',
215
+ {{#bearerFormat}}
216
+ format: '{{{.}}}',
217
+ {{/bearerFormat}}
218
+ key: 'Authorization',
219
+ value: "Bearer #{access_token}"
220
+ },
221
+ {{/isBasicBearer}}
222
+ {{/isBasic}}
223
+ {{#isOAuth}}
224
+ '{{name}}' =>
225
+ {
226
+ type: 'oauth2',
227
+ in: 'header',
228
+ key: 'Authorization',
229
+ value: "Bearer #{access_token}"
230
+ },
231
+ {{/isOAuth}}
232
+ {{/authMethods}}
233
+ }
234
+ end
235
+
236
+ # Returns an array of Server setting
237
+ def server_settings
238
+ [
239
+ {{#servers}}
240
+ {
241
+ url: "{{{url}}}",
242
+ description: "{{{description}}}{{^description}}No description provided{{/description}}",
243
+ {{#variables}}
244
+ {{#-first}}
245
+ variables: {
246
+ {{/-first}}
247
+ {{{name}}}: {
248
+ description: "{{{description}}}{{^description}}No description provided{{/description}}",
249
+ default_value: "{{{defaultValue}}}",
250
+ {{#enumValues}}
251
+ {{#-first}}
252
+ enum_values: [
253
+ {{/-first}}
254
+ "{{{.}}}"{{^-last}},{{/-last}}
255
+ {{#-last}}
256
+ ]
257
+ {{/-last}}
258
+ {{/enumValues}}
259
+ }{{^-last}},{{/-last}}
260
+ {{#-last}}
261
+ }
262
+ {{/-last}}
263
+ {{/variables}}
264
+ }{{^-last}},{{/-last}}
265
+ {{/servers}}
266
+ ]
267
+ end
268
+
269
+ def operation_server_settings
270
+ {
271
+ {{#apiInfo}}
272
+ {{#apis}}
273
+ {{#operations}}
274
+ {{#operation}}
275
+ {{#servers}}
276
+ {{#-first}}
277
+ "{{{classname}}}.{{{nickname}}}": [
278
+ {{/-first}}
279
+ {
280
+ url: "{{{url}}}",
281
+ description: "{{{description}}}{{^description}}No description provided{{/description}}",
282
+ {{#variables}}
283
+ {{#-first}}
284
+ variables: {
285
+ {{/-first}}
286
+ {{{name}}}: {
287
+ description: "{{{description}}}{{^description}}No description provided{{/description}}",
288
+ default_value: "{{{defaultValue}}}",
289
+ {{#enumValues}}
290
+ {{#-first}}
291
+ enum_values: [
292
+ {{/-first}}
293
+ "{{{.}}}"{{^-last}},{{/-last}}
294
+ {{#-last}}
295
+ ]
296
+ {{/-last}}
297
+ {{/enumValues}}
298
+ }{{^-last}},{{/-last}}
299
+ {{#-last}}
300
+ }
301
+ {{/-last}}
302
+ {{/variables}}
303
+ }{{^-last}},{{/-last}}
304
+ {{#-last}}
305
+ ],
306
+ {{/-last}}
307
+ {{/servers}}
308
+ {{/operation}}
309
+ {{/operations}}
310
+ {{/apis}}
311
+ {{/apiInfo}}
312
+ }
313
+ end
314
+
315
+ # Returns URL based on server settings
316
+ #
317
+ # @param index array index of the server settings
318
+ # @param variables hash of variable and the corresponding value
319
+ def server_url(index, variables = {}, servers = nil)
320
+ servers = server_settings if servers == nil
321
+
322
+ # check array index out of bound
323
+ if (index < 0 || index >= servers.size)
324
+ fail ArgumentError, "Invalid index #{index} when selecting the server. Must be less than #{servers.size}"
325
+ end
326
+
327
+ server = servers[index]
328
+ url = server[:url]
329
+
330
+ return url unless server.key? :variables
331
+
332
+ # go through variable and assign a value
333
+ server[:variables].each do |name, variable|
334
+ if variables.key?(name)
335
+ if (!server[:variables][name].key?(:enum_values) || server[:variables][name][:enum_values].include?(variables[name]))
336
+ url.gsub! "{" + name.to_s + "}", variables[name]
337
+ else
338
+ fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."
339
+ end
340
+ else
341
+ # use default value
342
+ url.gsub! "{" + name.to_s + "}", server[:variables][name][:default_value]
343
+ end
344
+ end
345
+
346
+ url
347
+ end
348
+
349
+ {{#isFaraday}}
350
+ # Adds middleware to the stack
351
+ def use(*middleware)
352
+ @middlewares << middleware
353
+ end
354
+
355
+ # Adds request middleware to the stack
356
+ def request(*middleware)
357
+ @request_middlewares << middleware
358
+ end
359
+
360
+ # Adds response middleware to the stack
361
+ def response(*middleware)
362
+ @response_middlewares << middleware
363
+ end
364
+
365
+ # Set up middleware on the connection
366
+ def configure_middleware(connection)
367
+ @middlewares.each do |middleware|
368
+ connection.use(*middleware)
369
+ end
370
+
371
+ @request_middlewares.each do |middleware|
372
+ connection.request(*middleware)
373
+ end
374
+
375
+ @response_middlewares.each do |middleware|
376
+ connection.response(*middleware)
377
+ end
378
+ end
379
+ {{/isFaraday}}
380
+ end
381
+ end
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+
3
+ describe {{moduleName}}::Configuration do
4
+ let(:config) { {{moduleName}}::Configuration.default }
5
+
6
+ before(:each) do
7
+ # uncomment below to setup host and base_path
8
+ # require 'URI'
9
+ # uri = URI.parse("{{{basePath}}}")
10
+ # {{moduleName}}.configure do |c|
11
+ # c.host = uri.host
12
+ # c.base_path = uri.path
13
+ # end
14
+ end
15
+
16
+ describe '#base_url' do
17
+ it 'should have the default value' do
18
+ # uncomment below to test default value of the base path
19
+ # expect(config.base_url).to eq("{{{basePath}}}")
20
+ end
21
+
22
+ it 'should remove trailing slashes' do
23
+ [nil, '', '/', '//'].each do |base_path|
24
+ config.base_path = base_path
25
+ # uncomment below to test trailing slashes
26
+ # expect(config.base_url).to eq("{{{basePath}}}")
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,29 @@
1
+ ### TLS/SSL setting
2
+ # Set this to false to skip verifying SSL certificate when calling API from https server.
3
+ # Default to true.
4
+ #
5
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
6
+ #
7
+ # @return [true, false]
8
+ attr_accessor :ssl_verify
9
+
10
+ ### TLS/SSL setting
11
+ # Any `OpenSSL::SSL::` constant (see https://ruby-doc.org/stdlib-2.5.1/libdoc/openssl/rdoc/OpenSSL/SSL.html)
12
+ #
13
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
14
+ #
15
+ attr_accessor :ssl_verify_mode
16
+
17
+ ### TLS/SSL setting
18
+ # Set this to customize the certificate file to verify the peer.
19
+ #
20
+ # @return [String] the path to the certificate file
21
+ attr_accessor :ssl_ca_file
22
+
23
+ ### TLS/SSL setting
24
+ # Client certificate file (for client certificate)
25
+ attr_accessor :ssl_client_cert
26
+
27
+ ### TLS/SSL setting
28
+ # Client private key file (for client certificate)
29
+ attr_accessor :ssl_client_key
@@ -0,0 +1,34 @@
1
+ ### TLS/SSL setting
2
+ # Set this to false to skip verifying SSL certificate when calling API from https server.
3
+ # Default to true.
4
+ #
5
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
6
+ #
7
+ # @return [true, false]
8
+ attr_accessor :verify_ssl
9
+
10
+ ### TLS/SSL setting
11
+ # Set this to false to skip verifying SSL host name
12
+ # Default to true.
13
+ #
14
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
15
+ #
16
+ # @return [true, false]
17
+ attr_accessor :verify_ssl_host
18
+
19
+ ### TLS/SSL setting
20
+ # Set this to customize the certificate file to verify the peer.
21
+ #
22
+ # @return [String] the path to the certificate file
23
+ #
24
+ # @see The `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code:
25
+ # https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
26
+ attr_accessor :ssl_ca_cert
27
+
28
+ ### TLS/SSL setting
29
+ # Client certificate file (for client certificate)
30
+ attr_accessor :cert_file
31
+
32
+ ### TLS/SSL setting
33
+ # Client private key file (for client certificate)
34
+ attr_accessor :key_file
@@ -0,0 +1,50 @@
1
+ =begin
2
+ {{> api_info}}
3
+ =end
4
+
5
+ # Common files
6
+ require '{{gemName}}/api_client'
7
+ require '{{gemName}}/api_error'
8
+ require '{{gemName}}/version'
9
+ require '{{gemName}}/configuration'
10
+
11
+ # Models
12
+ {{#models}}
13
+ {{#model}}
14
+ {{^parent}}
15
+ require '{{gemName}}/{{modelPackage}}/{{classFilename}}'
16
+ {{/parent}}
17
+ {{/model}}
18
+ {{/models}}
19
+ {{#models}}
20
+ {{#model}}
21
+ {{#parent}}
22
+ require '{{gemName}}/{{modelPackage}}/{{classFilename}}'
23
+ {{/parent}}
24
+ {{/model}}
25
+ {{/models}}
26
+
27
+ # APIs
28
+ {{#apiInfo}}
29
+ {{#apis}}
30
+ require '{{importPath}}'
31
+ {{/apis}}
32
+ {{/apiInfo}}
33
+
34
+ module {{moduleName}}
35
+ class << self
36
+ # Customize default settings for the SDK using block.
37
+ # {{moduleName}}.configure do |config|
38
+ # config.username = "xxx"
39
+ # config.password = "xxx"
40
+ # end
41
+ # If no block given, return the default Configuration object.
42
+ def configure
43
+ if block_given?
44
+ yield(Configuration.default)
45
+ else
46
+ Configuration.default
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,31 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ $:.push File.expand_path("../lib", __FILE__)
4
+ require "{{gemName}}/version"
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "{{gemName}}{{^gemName}}{{{appName}}}{{/gemName}}"
8
+ s.version = {{moduleName}}::VERSION
9
+ s.platform = Gem::Platform::RUBY
10
+ s.authors = ["{{gemAuthor}}{{^gemAuthor}}OpenAPI-Generator{{/gemAuthor}}"]
11
+ s.email = ["{{gemAuthorEmail}}{{^gemAuthorEmail}}{{infoEmail}}{{/gemAuthorEmail}}"]
12
+ s.homepage = "{{gemHomepage}}{{^gemHomepage}}https://openapi-generator.tech{{/gemHomepage}}"
13
+ s.summary = "{{gemSummary}}{{^gemSummary}}{{{appName}}} Ruby Gem{{/gemSummary}}"
14
+ s.description = "{{gemDescription}}{{^gemDescription}}{{{appDescription}}}{{^appDescription}}{{{appName}}} Ruby Gem{{/appDescription}}{{/gemDescription}}"
15
+ s.license = "{{{gemLicense}}}{{^gemLicense}}Unlicense{{/gemLicense}}"
16
+ s.required_ruby_version = "{{{gemRequiredRubyVersion}}}{{^gemRequiredRubyVersion}}>= 2.4{{/gemRequiredRubyVersion}}"
17
+
18
+ {{#isFaraday}}
19
+ s.add_runtime_dependency 'faraday', '~> 1.0', '>= 1.0.1'
20
+ {{/isFaraday}}
21
+ {{^isFaraday}}
22
+ s.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1'
23
+ {{/isFaraday}}
24
+
25
+ s.add_development_dependency 'rspec', '~> 3.6', '>= 3.6.0'
26
+
27
+ s.files = `find *`.split("\n").uniq.sort.select { |f| !f.empty? }
28
+ s.test_files = `find spec/*`.split("\n")
29
+ s.executables = []
30
+ s.require_paths = ["lib"]
31
+ end