swagger_aem 3.8.0 → 4.0.0
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 +4 -4
- data/Gemfile.lock +107 -34
- data/README.md +8 -12
- data/bin/byebug +16 -0
- data/bin/coderay +16 -0
- data/bin/htmldiff +16 -0
- data/bin/ldiff +16 -0
- data/bin/pry +16 -0
- data/bin/racc +16 -0
- data/bin/rake +16 -0
- data/bin/rspec +16 -0
- data/bin/rubocop +16 -0
- data/bin/ruby-parse +16 -0
- data/bin/ruby-rewrite +16 -0
- data/docs/BundleData.md +24 -23
- data/docs/BundleDataProp.md +10 -9
- data/docs/BundleInfo.md +12 -11
- data/docs/ConsoleApi.md +188 -79
- data/docs/CqApi.md +52 -16
- data/docs/CrxApi.md +192 -64
- data/docs/CustomApi.md +85 -32
- data/docs/GraniteApi.md +37 -20
- data/docs/InstallStatus.md +8 -7
- data/docs/InstallStatusStatus.md +10 -9
- data/docs/KeystoreChainItems.md +16 -15
- data/docs/KeystoreInfo.md +10 -9
- data/docs/KeystoreItems.md +16 -15
- data/docs/SamlConfigurationInfo.md +18 -17
- data/docs/SamlConfigurationProperties.md +54 -53
- data/docs/SamlConfigurationPropertyItemsArray.md +18 -17
- data/docs/SamlConfigurationPropertyItemsBoolean.md +18 -17
- data/docs/SamlConfigurationPropertyItemsLong.md +18 -17
- data/docs/SamlConfigurationPropertyItemsString.md +18 -17
- data/docs/SlingApi.md +1021 -496
- data/docs/TruststoreInfo.md +10 -9
- data/docs/TruststoreItems.md +20 -19
- data/git_push.sh +3 -4
- data/lib/swagger_aem/api/console_api.rb +33 -27
- data/lib/swagger_aem/api/cq_api.rb +11 -9
- data/lib/swagger_aem/api/crx_api.rb +42 -32
- data/lib/swagger_aem/api/custom_api.rb +15 -12
- data/lib/swagger_aem/api/granite_api.rb +11 -7
- data/lib/swagger_aem/api/sling_api.rb +342 -298
- data/lib/swagger_aem/api_client.rb +73 -64
- data/lib/swagger_aem/api_error.rb +3 -2
- data/lib/swagger_aem/api_model_base.rb +88 -0
- data/lib/swagger_aem/configuration.rb +75 -15
- data/lib/swagger_aem/models/bundle_data.rb +32 -91
- data/lib/swagger_aem/models/bundle_data_prop.rb +32 -91
- data/lib/swagger_aem/models/bundle_info.rb +32 -91
- data/lib/swagger_aem/models/install_status.rb +32 -91
- data/lib/swagger_aem/models/install_status_status.rb +32 -91
- data/lib/swagger_aem/models/keystore_chain_items.rb +32 -91
- data/lib/swagger_aem/models/keystore_info.rb +32 -91
- data/lib/swagger_aem/models/keystore_items.rb +32 -91
- data/lib/swagger_aem/models/saml_configuration_info.rb +32 -91
- data/lib/swagger_aem/models/saml_configuration_properties.rb +32 -91
- data/lib/swagger_aem/models/saml_configuration_property_items_array.rb +32 -91
- data/lib/swagger_aem/models/saml_configuration_property_items_boolean.rb +32 -91
- data/lib/swagger_aem/models/saml_configuration_property_items_long.rb +32 -91
- data/lib/swagger_aem/models/saml_configuration_property_items_string.rb +32 -91
- data/lib/swagger_aem/models/truststore_info.rb +32 -91
- data/lib/swagger_aem/models/truststore_items.rb +32 -91
- data/lib/swagger_aem/version.rb +3 -3
- data/lib/swagger_aem.rb +3 -8
- data/spec/api/console_api_spec.rb +8 -8
- data/spec/api/cq_api_spec.rb +4 -4
- data/spec/api/crx_api_spec.rb +9 -9
- data/spec/api/custom_api_spec.rb +5 -5
- data/spec/api/granite_api_spec.rb +3 -3
- data/spec/api/sling_api_spec.rb +89 -87
- data/spec/models/bundle_data_prop_spec.rb +8 -6
- data/spec/models/bundle_data_spec.rb +15 -13
- data/spec/models/bundle_info_spec.rb +9 -7
- data/spec/models/install_status_spec.rb +7 -5
- data/spec/models/install_status_status_spec.rb +8 -6
- data/spec/models/keystore_chain_items_spec.rb +11 -9
- data/spec/models/keystore_info_spec.rb +8 -6
- data/spec/models/keystore_items_spec.rb +11 -9
- data/spec/models/saml_configuration_info_spec.rb +12 -10
- data/spec/models/saml_configuration_properties_spec.rb +30 -28
- data/spec/models/saml_configuration_property_items_array_spec.rb +12 -10
- data/spec/models/saml_configuration_property_items_boolean_spec.rb +12 -10
- data/spec/models/saml_configuration_property_items_long_spec.rb +12 -10
- data/spec/models/saml_configuration_property_items_string_spec.rb +12 -10
- data/spec/models/truststore_info_spec.rb +8 -6
- data/spec/models/truststore_items_spec.rb +13 -11
- data/spec/spec_helper.rb +2 -2
- data/swagger_aem.gemspec +4 -4
- metadata +15 -54
- data/docs/InlineObject.md +0 -17
- data/docs/InlineObject1.md +0 -17
- data/docs/InlineObject2.md +0 -17
- data/docs/InlineObject3.md +0 -17
- data/docs/InlineObject4.md +0 -21
- data/docs/InlineObject5.md +0 -19
- data/lib/swagger_aem/models/inline_object.rb +0 -206
- data/lib/swagger_aem/models/inline_object1.rb +0 -206
- data/lib/swagger_aem/models/inline_object2.rb +0 -206
- data/lib/swagger_aem/models/inline_object3.rb +0 -206
- data/lib/swagger_aem/models/inline_object4.rb +0 -224
- data/lib/swagger_aem/models/inline_object5.rb +0 -215
- data/spec/api_client_spec.rb +0 -226
- data/spec/configuration_spec.rb +0 -42
- data/spec/models/inline_object1_spec.rb +0 -41
- data/spec/models/inline_object2_spec.rb +0 -41
- data/spec/models/inline_object3_spec.rb +0 -41
- data/spec/models/inline_object4_spec.rb +0 -53
- data/spec/models/inline_object5_spec.rb +0 -47
- data/spec/models/inline_object_spec.rb +0 -41
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
|
|
4
4
|
#Swagger AEM is an OpenAPI specification for Adobe Experience Manager (AEM) API
|
|
5
5
|
|
|
6
|
-
The version of the OpenAPI document:
|
|
6
|
+
The version of the OpenAPI document: 4.0.0
|
|
7
7
|
Contact: opensource@shinesolutions.com
|
|
8
8
|
Generated by: https://openapi-generator.tech
|
|
9
|
-
|
|
9
|
+
Generator version: 7.24.0
|
|
10
10
|
|
|
11
11
|
=end
|
|
12
12
|
|
|
@@ -14,8 +14,10 @@ require 'date'
|
|
|
14
14
|
require 'json'
|
|
15
15
|
require 'logger'
|
|
16
16
|
require 'tempfile'
|
|
17
|
+
require 'time'
|
|
17
18
|
require 'typhoeus'
|
|
18
19
|
|
|
20
|
+
|
|
19
21
|
module SwaggerAemClient
|
|
20
22
|
class ApiClient
|
|
21
23
|
# The Configuration object holding settings to be used in the API client.
|
|
@@ -44,9 +46,11 @@ module SwaggerAemClient
|
|
|
44
46
|
# Call an API with given options.
|
|
45
47
|
#
|
|
46
48
|
# @return [Array<(Object, Integer, Hash)>] an array of 3 elements:
|
|
47
|
-
# the data deserialized from response body (
|
|
49
|
+
# the data deserialized from response body (may be a Tempfile or nil), response status code and response headers.
|
|
48
50
|
def call_api(http_method, path, opts = {})
|
|
49
51
|
request = build_request(http_method, path, opts)
|
|
52
|
+
tempfile = nil
|
|
53
|
+
(download_file(request) { tempfile = _1 }) if opts[:return_type] == 'File'
|
|
50
54
|
response = request.run
|
|
51
55
|
|
|
52
56
|
if @config.debugging
|
|
@@ -68,7 +72,9 @@ module SwaggerAemClient
|
|
|
68
72
|
end
|
|
69
73
|
end
|
|
70
74
|
|
|
71
|
-
if opts[:return_type]
|
|
75
|
+
if opts[:return_type] == 'File'
|
|
76
|
+
data = tempfile
|
|
77
|
+
elsif opts[:return_type]
|
|
72
78
|
data = deserialize(response, opts[:return_type])
|
|
73
79
|
else
|
|
74
80
|
data = nil
|
|
@@ -86,12 +92,13 @@ module SwaggerAemClient
|
|
|
86
92
|
# @option opts [Object] :body HTTP body (JSON/XML)
|
|
87
93
|
# @return [Typhoeus::Request] A Typhoeus Request
|
|
88
94
|
def build_request(http_method, path, opts = {})
|
|
89
|
-
url = build_request_url(path)
|
|
95
|
+
url = build_request_url(path, opts)
|
|
90
96
|
http_method = http_method.to_sym.downcase
|
|
91
97
|
|
|
92
98
|
header_params = @default_headers.merge(opts[:header_params] || {})
|
|
93
99
|
query_params = opts[:query_params] || {}
|
|
94
100
|
form_params = opts[:form_params] || {}
|
|
101
|
+
follow_location = opts[:follow_location] || true
|
|
95
102
|
|
|
96
103
|
update_params_for_auth! header_params, query_params, opts[:auth_names]
|
|
97
104
|
|
|
@@ -108,7 +115,8 @@ module SwaggerAemClient
|
|
|
108
115
|
:ssl_verifyhost => _verify_ssl_host,
|
|
109
116
|
:sslcert => @config.cert_file,
|
|
110
117
|
:sslkey => @config.key_file,
|
|
111
|
-
:verbose => @config.debugging
|
|
118
|
+
:verbose => @config.debugging,
|
|
119
|
+
:followlocation => follow_location
|
|
112
120
|
}
|
|
113
121
|
|
|
114
122
|
# set custom cert, if provided
|
|
@@ -122,9 +130,7 @@ module SwaggerAemClient
|
|
|
122
130
|
end
|
|
123
131
|
end
|
|
124
132
|
|
|
125
|
-
|
|
126
|
-
download_file(request) if opts[:return_type] == 'File'
|
|
127
|
-
request
|
|
133
|
+
Typhoeus::Request.new(url, req_opts)
|
|
128
134
|
end
|
|
129
135
|
|
|
130
136
|
# Builds the HTTP request body
|
|
@@ -155,6 +161,47 @@ module SwaggerAemClient
|
|
|
155
161
|
data
|
|
156
162
|
end
|
|
157
163
|
|
|
164
|
+
# Save response body into a file in (the defined) temporary folder, using the filename
|
|
165
|
+
# from the "Content-Disposition" header if provided, otherwise a random filename.
|
|
166
|
+
# The response body is written to the file in chunks in order to handle files which
|
|
167
|
+
# size is larger than maximum Ruby String or even larger than the maximum memory a Ruby
|
|
168
|
+
# process can use.
|
|
169
|
+
#
|
|
170
|
+
# @see Configuration#temp_folder_path
|
|
171
|
+
#
|
|
172
|
+
# @return [Tempfile] the tempfile generated
|
|
173
|
+
def download_file(request)
|
|
174
|
+
tempfile = nil
|
|
175
|
+
encoding = nil
|
|
176
|
+
request.on_headers do |response|
|
|
177
|
+
content_disposition = response.headers['Content-Disposition']
|
|
178
|
+
if content_disposition && content_disposition =~ /filename=/i
|
|
179
|
+
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
|
|
180
|
+
prefix = sanitize_filename(filename)
|
|
181
|
+
else
|
|
182
|
+
prefix = 'download-'
|
|
183
|
+
end
|
|
184
|
+
prefix = prefix + '-' unless prefix.end_with?('-')
|
|
185
|
+
encoding = response.body.encoding
|
|
186
|
+
tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
|
|
187
|
+
end
|
|
188
|
+
request.on_body do |chunk|
|
|
189
|
+
chunk.force_encoding(encoding)
|
|
190
|
+
tempfile.write(chunk)
|
|
191
|
+
end
|
|
192
|
+
request.on_complete do
|
|
193
|
+
if !tempfile
|
|
194
|
+
fail ApiError.new("Failed to create the tempfile based on the HTTP response from the server: #{request.inspect}")
|
|
195
|
+
end
|
|
196
|
+
tempfile.close
|
|
197
|
+
@config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
|
|
198
|
+
"with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
|
|
199
|
+
"will be deleted automatically with GC. It's also recommended to delete the temp file "\
|
|
200
|
+
"explicitly with `tempfile.delete`"
|
|
201
|
+
yield tempfile if block_given?
|
|
202
|
+
end
|
|
203
|
+
end
|
|
204
|
+
|
|
158
205
|
# Check if the given MIME is a JSON MIME.
|
|
159
206
|
# JSON MIME examples:
|
|
160
207
|
# application/json
|
|
@@ -164,7 +211,7 @@ module SwaggerAemClient
|
|
|
164
211
|
# @param [String] mime MIME
|
|
165
212
|
# @return [Boolean] True if the MIME is application/json
|
|
166
213
|
def json_mime?(mime)
|
|
167
|
-
(mime == '*/*') || !(mime =~
|
|
214
|
+
(mime == '*/*') || !(mime =~ /^Application\/.*json(?!p)(;.*)?/i).nil?
|
|
168
215
|
end
|
|
169
216
|
|
|
170
217
|
# Deserialize the response to the given return type.
|
|
@@ -173,15 +220,10 @@ module SwaggerAemClient
|
|
|
173
220
|
# @param [String] return_type some examples: "User", "Array<User>", "Hash<String, Integer>"
|
|
174
221
|
def deserialize(response, return_type)
|
|
175
222
|
body = response.body
|
|
176
|
-
|
|
177
|
-
# handle file downloading - return the File instance processed in request callbacks
|
|
178
|
-
# note that response body is empty when the file is written in chunks in request on_body callback
|
|
179
|
-
return @tempfile if return_type == 'File'
|
|
180
|
-
|
|
181
223
|
return nil if body.nil? || body.empty?
|
|
182
224
|
|
|
183
225
|
# return response body directly for String return type
|
|
184
|
-
return body if return_type == 'String'
|
|
226
|
+
return body.to_s if return_type == 'String'
|
|
185
227
|
|
|
186
228
|
# ensuring a default content type
|
|
187
229
|
content_type = response.headers['Content-Type'] || 'application/json'
|
|
@@ -191,7 +233,7 @@ module SwaggerAemClient
|
|
|
191
233
|
begin
|
|
192
234
|
data = JSON.parse("[#{body}]", :symbolize_names => true)[0]
|
|
193
235
|
rescue JSON::ParserError => e
|
|
194
|
-
if %w(String Date
|
|
236
|
+
if %w(String Date Time).include?(return_type)
|
|
195
237
|
data = body
|
|
196
238
|
else
|
|
197
239
|
raise e
|
|
@@ -216,9 +258,9 @@ module SwaggerAemClient
|
|
|
216
258
|
data.to_f
|
|
217
259
|
when 'Boolean'
|
|
218
260
|
data == true
|
|
219
|
-
when '
|
|
261
|
+
when 'Time'
|
|
220
262
|
# parse date time (expecting ISO 8601 format)
|
|
221
|
-
|
|
263
|
+
Time.parse data
|
|
222
264
|
when 'Date'
|
|
223
265
|
# parse date time (expecting ISO 8601 format)
|
|
224
266
|
Date.parse data
|
|
@@ -236,45 +278,12 @@ module SwaggerAemClient
|
|
|
236
278
|
data.each { |k, v| hash[k] = convert_to_type(v, sub_type) }
|
|
237
279
|
end
|
|
238
280
|
else
|
|
239
|
-
# models
|
|
240
|
-
SwaggerAemClient.const_get(return_type)
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
# Save response body into a file in (the defined) temporary folder, using the filename
|
|
245
|
-
# from the "Content-Disposition" header if provided, otherwise a random filename.
|
|
246
|
-
# The response body is written to the file in chunks in order to handle files which
|
|
247
|
-
# size is larger than maximum Ruby String or even larger than the maximum memory a Ruby
|
|
248
|
-
# process can use.
|
|
249
|
-
#
|
|
250
|
-
# @see Configuration#temp_folder_path
|
|
251
|
-
def download_file(request)
|
|
252
|
-
tempfile = nil
|
|
253
|
-
encoding = nil
|
|
254
|
-
request.on_headers do |response|
|
|
255
|
-
content_disposition = response.headers['Content-Disposition']
|
|
256
|
-
if content_disposition && content_disposition =~ /filename=/i
|
|
257
|
-
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
|
|
258
|
-
prefix = sanitize_filename(filename)
|
|
281
|
+
# models (e.g. Pet) or oneOf/anyOf
|
|
282
|
+
klass = SwaggerAemClient.const_get(return_type)
|
|
283
|
+
if klass.respond_to?(:openapi_one_of) || klass.respond_to?(:openapi_any_of)
|
|
284
|
+
klass.build(data)
|
|
259
285
|
else
|
|
260
|
-
|
|
261
|
-
end
|
|
262
|
-
prefix = prefix + '-' unless prefix.end_with?('-')
|
|
263
|
-
encoding = response.body.encoding
|
|
264
|
-
tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
|
|
265
|
-
@tempfile = tempfile
|
|
266
|
-
end
|
|
267
|
-
request.on_body do |chunk|
|
|
268
|
-
chunk.force_encoding(encoding)
|
|
269
|
-
tempfile.write(chunk)
|
|
270
|
-
end
|
|
271
|
-
request.on_complete do |response|
|
|
272
|
-
if tempfile
|
|
273
|
-
tempfile.close
|
|
274
|
-
@config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
|
|
275
|
-
"with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
|
|
276
|
-
"will be deleted automatically with GC. It's also recommended to delete the temp file "\
|
|
277
|
-
"explicitly with `tempfile.delete`"
|
|
286
|
+
klass.build_from_hash(data)
|
|
278
287
|
end
|
|
279
288
|
end
|
|
280
289
|
end
|
|
@@ -285,16 +294,16 @@ module SwaggerAemClient
|
|
|
285
294
|
# @param [String] filename the filename to be sanitized
|
|
286
295
|
# @return [String] the sanitized filename
|
|
287
296
|
def sanitize_filename(filename)
|
|
288
|
-
filename.
|
|
297
|
+
filename.split(/[\/\\]/).last
|
|
289
298
|
end
|
|
290
299
|
|
|
291
|
-
def build_request_url(path)
|
|
300
|
+
def build_request_url(path, opts = {})
|
|
292
301
|
# Add leading and trailing slashes to path
|
|
293
302
|
path = "/#{path}".gsub(/\/+/, '/')
|
|
294
|
-
@config.base_url + path
|
|
303
|
+
@config.base_url(opts[:operation]) + path
|
|
295
304
|
end
|
|
296
305
|
|
|
297
|
-
# Update
|
|
306
|
+
# Update header and query params based on authentication settings.
|
|
298
307
|
#
|
|
299
308
|
# @param [Hash] header_params Header parameters
|
|
300
309
|
# @param [Hash] query_params Query parameters
|
|
@@ -306,7 +315,7 @@ module SwaggerAemClient
|
|
|
306
315
|
case auth_setting[:in]
|
|
307
316
|
when 'header' then header_params[auth_setting[:key]] = auth_setting[:value]
|
|
308
317
|
when 'query' then query_params[auth_setting[:key]] = auth_setting[:value]
|
|
309
|
-
else fail ArgumentError, 'Authentication token must be in `query`
|
|
318
|
+
else fail ArgumentError, 'Authentication token must be in `query` or `header`'
|
|
310
319
|
end
|
|
311
320
|
end
|
|
312
321
|
end
|
|
@@ -333,8 +342,8 @@ module SwaggerAemClient
|
|
|
333
342
|
# @param [Array] content_types array for Content-Type
|
|
334
343
|
# @return [String] the Content-Type header (e.g. application/json)
|
|
335
344
|
def select_header_content_type(content_types)
|
|
336
|
-
#
|
|
337
|
-
return
|
|
345
|
+
# return nil by default
|
|
346
|
+
return if content_types.nil? || content_types.empty?
|
|
338
347
|
# use JSON when present, otherwise use the first one
|
|
339
348
|
json_content_type = content_types.find { |s| json_mime?(s) }
|
|
340
349
|
json_content_type || content_types.first
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
|
|
4
4
|
#Swagger AEM is an OpenAPI specification for Adobe Experience Manager (AEM) API
|
|
5
5
|
|
|
6
|
-
The version of the OpenAPI document:
|
|
6
|
+
The version of the OpenAPI document: 4.0.0
|
|
7
7
|
Contact: opensource@shinesolutions.com
|
|
8
8
|
Generated by: https://openapi-generator.tech
|
|
9
|
-
|
|
9
|
+
Generator version: 7.24.0
|
|
10
10
|
|
|
11
11
|
=end
|
|
12
12
|
|
|
@@ -32,6 +32,7 @@ module SwaggerAemClient
|
|
|
32
32
|
end
|
|
33
33
|
else
|
|
34
34
|
super arg
|
|
35
|
+
@message = arg
|
|
35
36
|
end
|
|
36
37
|
end
|
|
37
38
|
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#Adobe Experience Manager (AEM) API
|
|
3
|
+
|
|
4
|
+
#Swagger AEM is an OpenAPI specification for Adobe Experience Manager (AEM) API
|
|
5
|
+
|
|
6
|
+
The version of the OpenAPI document: 4.0.0
|
|
7
|
+
Contact: opensource@shinesolutions.com
|
|
8
|
+
Generated by: https://openapi-generator.tech
|
|
9
|
+
Generator version: 7.24.0
|
|
10
|
+
|
|
11
|
+
=end
|
|
12
|
+
|
|
13
|
+
module SwaggerAemClient
|
|
14
|
+
class ApiModelBase
|
|
15
|
+
# Deserializes the data based on type
|
|
16
|
+
# @param string type Data type
|
|
17
|
+
# @param string value Value to be deserialized
|
|
18
|
+
# @return [Object] Deserialized data
|
|
19
|
+
def self._deserialize(type, value)
|
|
20
|
+
case type.to_sym
|
|
21
|
+
when :Time
|
|
22
|
+
Time.parse(value)
|
|
23
|
+
when :Date
|
|
24
|
+
Date.parse(value)
|
|
25
|
+
when :String
|
|
26
|
+
value.to_s
|
|
27
|
+
when :Integer
|
|
28
|
+
value.to_i
|
|
29
|
+
when :Float
|
|
30
|
+
value.to_f
|
|
31
|
+
when :Boolean
|
|
32
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
33
|
+
true
|
|
34
|
+
else
|
|
35
|
+
false
|
|
36
|
+
end
|
|
37
|
+
when :Object
|
|
38
|
+
# generic object (usually a Hash), return directly
|
|
39
|
+
value
|
|
40
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
41
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
42
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
43
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
44
|
+
k_type = Regexp.last_match[:k_type]
|
|
45
|
+
v_type = Regexp.last_match[:v_type]
|
|
46
|
+
{}.tap do |hash|
|
|
47
|
+
value.each do |k, v|
|
|
48
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
else # model
|
|
52
|
+
# models (e.g. Pet) or oneOf
|
|
53
|
+
klass = SwaggerAemClient.const_get(type)
|
|
54
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Returns the string representation of the object
|
|
59
|
+
# @return [String] String presentation of the object
|
|
60
|
+
def to_s
|
|
61
|
+
to_hash.to_s
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
65
|
+
# @return [Hash] Returns the object in the form of hash
|
|
66
|
+
def to_body
|
|
67
|
+
to_hash
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# Outputs non-array value in the form of hash
|
|
71
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
72
|
+
# @param [Object] value Any valid value
|
|
73
|
+
# @return [Hash] Returns the value in the form of hash
|
|
74
|
+
def _to_hash(value)
|
|
75
|
+
if value.is_a?(Array)
|
|
76
|
+
value.compact.map { |v| _to_hash(v) }
|
|
77
|
+
elsif value.is_a?(Hash)
|
|
78
|
+
{}.tap do |hash|
|
|
79
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
80
|
+
end
|
|
81
|
+
elsif value.respond_to? :to_hash
|
|
82
|
+
value.to_hash
|
|
83
|
+
else
|
|
84
|
+
value
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
|
|
4
4
|
#Swagger AEM is an OpenAPI specification for Adobe Experience Manager (AEM) API
|
|
5
5
|
|
|
6
|
-
The version of the OpenAPI document:
|
|
6
|
+
The version of the OpenAPI document: 4.0.0
|
|
7
7
|
Contact: opensource@shinesolutions.com
|
|
8
8
|
Generated by: https://openapi-generator.tech
|
|
9
|
-
|
|
9
|
+
Generator version: 7.24.0
|
|
10
10
|
|
|
11
11
|
=end
|
|
12
12
|
|
|
@@ -21,6 +21,18 @@ module SwaggerAemClient
|
|
|
21
21
|
# Defines url base path
|
|
22
22
|
attr_accessor :base_path
|
|
23
23
|
|
|
24
|
+
# Define server configuration index
|
|
25
|
+
attr_accessor :server_index
|
|
26
|
+
|
|
27
|
+
# Define server operation configuration index
|
|
28
|
+
attr_accessor :server_operation_index
|
|
29
|
+
|
|
30
|
+
# Default server variables
|
|
31
|
+
attr_accessor :server_variables
|
|
32
|
+
|
|
33
|
+
# Default server operation variables
|
|
34
|
+
attr_accessor :server_operation_variables
|
|
35
|
+
|
|
24
36
|
# Defines API keys used with API Key authentications.
|
|
25
37
|
#
|
|
26
38
|
# @return [Hash] key: parameter name, value: parameter value (API key)
|
|
@@ -50,6 +62,16 @@ module SwaggerAemClient
|
|
|
50
62
|
# Defines the access token (Bearer) used with OAuth2.
|
|
51
63
|
attr_accessor :access_token
|
|
52
64
|
|
|
65
|
+
# Defines a Proc used to fetch or refresh access tokens (Bearer) used with OAuth2.
|
|
66
|
+
# Overrides the access_token if set
|
|
67
|
+
# @return [Proc]
|
|
68
|
+
attr_accessor :access_token_getter
|
|
69
|
+
|
|
70
|
+
# Set this to return data as binary instead of downloading a temp file. When enabled (set to true)
|
|
71
|
+
# HTTP responses with return type `File` will be returned as a stream of binary data.
|
|
72
|
+
# Default to false.
|
|
73
|
+
attr_accessor :return_binary_data
|
|
74
|
+
|
|
53
75
|
# Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
|
|
54
76
|
# details will be logged with `logger.debug` (see the `logger` attribute).
|
|
55
77
|
# Default to false.
|
|
@@ -57,6 +79,14 @@ module SwaggerAemClient
|
|
|
57
79
|
# @return [true, false]
|
|
58
80
|
attr_accessor :debugging
|
|
59
81
|
|
|
82
|
+
# Set this to ignore operation servers for the API client. This is useful when you need to
|
|
83
|
+
# send requests to a different server than the one specified in the OpenAPI document.
|
|
84
|
+
# Will default to the base url defined in the spec but can be overridden by setting
|
|
85
|
+
# `scheme`, `host`, `base_path` directly.
|
|
86
|
+
# Default to false.
|
|
87
|
+
# @return [true, false]
|
|
88
|
+
attr_accessor :ignore_operation_servers
|
|
89
|
+
|
|
60
90
|
# Defines the logger used for debugging.
|
|
61
91
|
# Default to `Rails.logger` (when in Rails) or logging to STDOUT.
|
|
62
92
|
#
|
|
@@ -121,6 +151,7 @@ module SwaggerAemClient
|
|
|
121
151
|
# https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
|
|
122
152
|
attr_accessor :params_encoding
|
|
123
153
|
|
|
154
|
+
|
|
124
155
|
attr_accessor :inject_format
|
|
125
156
|
|
|
126
157
|
attr_accessor :force_ending_format
|
|
@@ -129,16 +160,21 @@ module SwaggerAemClient
|
|
|
129
160
|
@scheme = 'http'
|
|
130
161
|
@host = 'localhost'
|
|
131
162
|
@base_path = ''
|
|
163
|
+
@server_index = nil
|
|
164
|
+
@server_operation_index = {}
|
|
165
|
+
@server_variables = {}
|
|
166
|
+
@server_operation_variables = {}
|
|
132
167
|
@api_key = {}
|
|
133
168
|
@api_key_prefix = {}
|
|
134
|
-
@timeout = 0
|
|
135
169
|
@client_side_validation = true
|
|
136
170
|
@verify_ssl = true
|
|
137
171
|
@verify_ssl_host = true
|
|
138
|
-
@params_encoding = nil
|
|
139
172
|
@cert_file = nil
|
|
140
173
|
@key_file = nil
|
|
174
|
+
@timeout = 0
|
|
175
|
+
@params_encoding = nil
|
|
141
176
|
@debugging = false
|
|
177
|
+
@ignore_operation_servers = false
|
|
142
178
|
@inject_format = false
|
|
143
179
|
@force_ending_format = false
|
|
144
180
|
@logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
|
|
@@ -171,20 +207,35 @@ module SwaggerAemClient
|
|
|
171
207
|
@base_path = '' if @base_path == '/'
|
|
172
208
|
end
|
|
173
209
|
|
|
174
|
-
|
|
175
|
-
|
|
210
|
+
# Returns base URL for specified operation based on server settings
|
|
211
|
+
def base_url(operation = nil)
|
|
212
|
+
return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if ignore_operation_servers
|
|
213
|
+
if operation_server_settings.key?(operation) then
|
|
214
|
+
index = server_operation_index.fetch(operation, server_index)
|
|
215
|
+
server_url(index.nil? ? 0 : index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
|
|
216
|
+
else
|
|
217
|
+
server_index.nil? ? "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') : server_url(server_index, server_variables, nil)
|
|
218
|
+
end
|
|
176
219
|
end
|
|
177
220
|
|
|
178
221
|
# Gets API key (with prefix if set).
|
|
179
222
|
# @param [String] param_name the parameter name of API key auth
|
|
180
|
-
def api_key_with_prefix(param_name)
|
|
223
|
+
def api_key_with_prefix(param_name, param_alias = nil)
|
|
224
|
+
key = @api_key[param_name]
|
|
225
|
+
key = @api_key.fetch(param_alias, key) unless param_alias.nil?
|
|
181
226
|
if @api_key_prefix[param_name]
|
|
182
|
-
"#{@api_key_prefix[param_name]} #{
|
|
227
|
+
"#{@api_key_prefix[param_name]} #{key}"
|
|
183
228
|
else
|
|
184
|
-
|
|
229
|
+
key
|
|
185
230
|
end
|
|
186
231
|
end
|
|
187
232
|
|
|
233
|
+
# Gets access_token using access_token_getter or uses the static access_token
|
|
234
|
+
def access_token_with_refresh
|
|
235
|
+
return access_token if access_token_getter.nil?
|
|
236
|
+
access_token_getter.call
|
|
237
|
+
end
|
|
238
|
+
|
|
188
239
|
# Gets Basic Auth token string
|
|
189
240
|
def basic_auth_token
|
|
190
241
|
'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
|
|
@@ -207,31 +258,38 @@ module SwaggerAemClient
|
|
|
207
258
|
def server_settings
|
|
208
259
|
[
|
|
209
260
|
{
|
|
210
|
-
url: "
|
|
261
|
+
url: "",
|
|
211
262
|
description: "No description provided",
|
|
212
263
|
}
|
|
213
264
|
]
|
|
214
265
|
end
|
|
215
266
|
|
|
267
|
+
def operation_server_settings
|
|
268
|
+
{
|
|
269
|
+
}
|
|
270
|
+
end
|
|
271
|
+
|
|
216
272
|
# Returns URL based on server settings
|
|
217
273
|
#
|
|
218
274
|
# @param index array index of the server settings
|
|
219
275
|
# @param variables hash of variable and the corresponding value
|
|
220
|
-
def server_url(index, variables = {})
|
|
221
|
-
servers = server_settings
|
|
276
|
+
def server_url(index, variables = {}, servers = nil)
|
|
277
|
+
servers = server_settings if servers == nil
|
|
222
278
|
|
|
223
279
|
# check array index out of bound
|
|
224
|
-
if (index < 0 || index >= servers.size)
|
|
225
|
-
fail ArgumentError, "Invalid index #{index} when selecting the server. Must be less than #{servers.size}"
|
|
280
|
+
if (index.nil? || index < 0 || index >= servers.size)
|
|
281
|
+
fail ArgumentError, "Invalid index #{index} when selecting the server. Must not be nil and must be less than #{servers.size}"
|
|
226
282
|
end
|
|
227
283
|
|
|
228
284
|
server = servers[index]
|
|
229
285
|
url = server[:url]
|
|
230
286
|
|
|
287
|
+
return url unless server.key? :variables
|
|
288
|
+
|
|
231
289
|
# go through variable and assign a value
|
|
232
290
|
server[:variables].each do |name, variable|
|
|
233
291
|
if variables.key?(name)
|
|
234
|
-
if (server[:variables][name][:enum_values].include?
|
|
292
|
+
if (!server[:variables][name].key?(:enum_values) || server[:variables][name][:enum_values].include?(variables[name]))
|
|
235
293
|
url.gsub! "{" + name.to_s + "}", variables[name]
|
|
236
294
|
else
|
|
237
295
|
fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."
|
|
@@ -244,5 +302,7 @@ module SwaggerAemClient
|
|
|
244
302
|
|
|
245
303
|
url
|
|
246
304
|
end
|
|
305
|
+
|
|
306
|
+
|
|
247
307
|
end
|
|
248
308
|
end
|