docraptor 1.3.0 → 1.4.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 +5 -5
- data/.gitignore +5 -1
- data/.swagger-codegen/VERSION +1 -1
- data/.swagger-revision +1 -1
- data/CHANGELOG.md +4 -0
- data/Gemfile +1 -1
- data/docraptor.gemspec +6 -6
- data/docraptor.yaml +112 -18
- data/examples/hosted_async.rb +75 -0
- data/examples/hosted_sync.rb +62 -0
- data/lib/docraptor.rb +4 -4
- data/lib/docraptor/api/doc_api.rb +173 -36
- data/lib/docraptor/api_client.rb +14 -12
- data/lib/docraptor/api_error.rb +3 -3
- data/lib/docraptor/configuration.rb +4 -4
- data/lib/docraptor/models/async_doc.rb +11 -15
- data/lib/docraptor/models/doc.rb +51 -36
- data/lib/docraptor/models/{async_doc_status.rb → doc_status.rb} +12 -16
- data/lib/docraptor/models/prince_options.rb +15 -18
- data/lib/docraptor/version.rb +4 -4
- data/script/fix_gemspec.rb +3 -2
- data/script/swagger +6 -1
- data/spec/api_client_spec.rb +55 -38
- data/spec/configuration_spec.rb +12 -12
- data/spec/spec_helper.rb +4 -4
- data/swagger-config.json +1 -1
- data/test/async.rb +11 -2
- data/test/expire_hosted.rb +50 -0
- data/test/hosted_async.rb +34 -0
- data/test/hosted_sync.rb +33 -0
- data/test/sync.rb +10 -2
- data/test/xlsx.rb +10 -2
- metadata +27 -30
- data/spec/api/doc_api_spec.rb +0 -83
- data/spec/models/async_doc_spec.rb +0 -42
- data/spec/models/async_doc_status_spec.rb +0 -72
- data/spec/models/doc_spec.rb +0 -128
- data/spec/models/prince_options_spec.rb +0 -214
data/lib/docraptor.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
=begin
|
2
|
-
#DocRaptor
|
2
|
+
#DocRaptor
|
3
3
|
|
4
4
|
#A native client library for the DocRaptor HTML to PDF/XLS service.
|
5
5
|
|
6
|
-
OpenAPI spec version: 1.
|
6
|
+
OpenAPI spec version: 1.4.0
|
7
7
|
|
8
8
|
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
-
Swagger Codegen version: 2.
|
9
|
+
Swagger Codegen version: 2.4.14
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
@@ -18,8 +18,8 @@ require 'docraptor/configuration'
|
|
18
18
|
|
19
19
|
# Models
|
20
20
|
require 'docraptor/models/async_doc'
|
21
|
-
require 'docraptor/models/async_doc_status'
|
22
21
|
require 'docraptor/models/doc'
|
22
|
+
require 'docraptor/models/doc_status'
|
23
23
|
require 'docraptor/models/prince_options'
|
24
24
|
|
25
25
|
# APIs
|
@@ -1,16 +1,16 @@
|
|
1
1
|
=begin
|
2
|
-
#DocRaptor
|
2
|
+
#DocRaptor
|
3
3
|
|
4
4
|
#A native client library for the DocRaptor HTML to PDF/XLS service.
|
5
5
|
|
6
|
-
OpenAPI spec version: 1.
|
6
|
+
OpenAPI spec version: 1.4.0
|
7
7
|
|
8
8
|
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
-
Swagger Codegen version: 2.
|
9
|
+
Swagger Codegen version: 2.4.14
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
13
|
-
require
|
13
|
+
require 'uri'
|
14
14
|
|
15
15
|
module DocRaptor
|
16
16
|
class DocApi
|
@@ -19,32 +19,29 @@ module DocRaptor
|
|
19
19
|
def initialize(api_client = ApiClient.default)
|
20
20
|
@api_client = api_client
|
21
21
|
end
|
22
|
-
|
23
|
-
#
|
24
|
-
# Creates a document asynchronously. You must use a callback url or the the returned status id and the status api to find out when it completes. Then use the download api to get the document.
|
22
|
+
# Creates a document asynchronously. You must use a callback url or the returned status id and the status API to find out when it completes. Then use the download API to get the document.
|
25
23
|
# @param doc The document to be created.
|
26
24
|
# @param [Hash] opts the optional parameters
|
27
25
|
# @return [AsyncDoc]
|
28
26
|
def create_async_doc(doc, opts = {})
|
29
27
|
data, _status_code, _headers = create_async_doc_with_http_info(doc, opts)
|
30
|
-
|
28
|
+
data
|
31
29
|
end
|
32
30
|
|
33
|
-
#
|
34
|
-
# Creates a document asynchronously. You must use a callback url or the the returned status id and the status api to find out when it completes. Then use the download api to get the document.
|
31
|
+
# Creates a document asynchronously. You must use a callback url or the returned status id and the status API to find out when it completes. Then use the download API to get the document.
|
35
32
|
# @param doc The document to be created.
|
36
33
|
# @param [Hash] opts the optional parameters
|
37
34
|
# @return [Array<(AsyncDoc, Fixnum, Hash)>] AsyncDoc data, response status code and response headers
|
38
35
|
def create_async_doc_with_http_info(doc, opts = {})
|
39
36
|
if @api_client.config.debugging
|
40
|
-
@api_client.config.logger.debug
|
37
|
+
@api_client.config.logger.debug 'Calling API: DocApi.create_async_doc ...'
|
41
38
|
end
|
42
39
|
# verify the required parameter 'doc' is set
|
43
40
|
if @api_client.config.client_side_validation && doc.nil?
|
44
41
|
fail ArgumentError, "Missing the required parameter 'doc' when calling DocApi.create_async_doc"
|
45
42
|
end
|
46
43
|
# resource path
|
47
|
-
local_var_path =
|
44
|
+
local_var_path = '/async_docs'
|
48
45
|
|
49
46
|
# query parameters
|
50
47
|
query_params = {}
|
@@ -72,32 +69,29 @@ module DocRaptor
|
|
72
69
|
end
|
73
70
|
return data, status_code, headers
|
74
71
|
end
|
75
|
-
|
76
|
-
#
|
77
72
|
# Creates a document synchronously.
|
78
73
|
# @param doc The document to be created.
|
79
74
|
# @param [Hash] opts the optional parameters
|
80
75
|
# @return [String]
|
81
76
|
def create_doc(doc, opts = {})
|
82
77
|
data, _status_code, _headers = create_doc_with_http_info(doc, opts)
|
83
|
-
|
78
|
+
data
|
84
79
|
end
|
85
80
|
|
86
|
-
#
|
87
81
|
# Creates a document synchronously.
|
88
82
|
# @param doc The document to be created.
|
89
83
|
# @param [Hash] opts the optional parameters
|
90
84
|
# @return [Array<(String, Fixnum, Hash)>] String data, response status code and response headers
|
91
85
|
def create_doc_with_http_info(doc, opts = {})
|
92
86
|
if @api_client.config.debugging
|
93
|
-
@api_client.config.logger.debug
|
87
|
+
@api_client.config.logger.debug 'Calling API: DocApi.create_doc ...'
|
94
88
|
end
|
95
89
|
# verify the required parameter 'doc' is set
|
96
90
|
if @api_client.config.client_side_validation && doc.nil?
|
97
91
|
fail ArgumentError, "Missing the required parameter 'doc' when calling DocApi.create_doc"
|
98
92
|
end
|
99
93
|
# resource path
|
100
|
-
local_var_path =
|
94
|
+
local_var_path = '/docs'
|
101
95
|
|
102
96
|
# query parameters
|
103
97
|
query_params = {}
|
@@ -125,32 +119,178 @@ module DocRaptor
|
|
125
119
|
end
|
126
120
|
return data, status_code, headers
|
127
121
|
end
|
122
|
+
# Creates a hosted document asynchronously. You must use a callback url or the returned status id and the status API to find out when it completes. Then use the download API to get the document.
|
123
|
+
# @param doc The document to be created.
|
124
|
+
# @param [Hash] opts the optional parameters
|
125
|
+
# @return [AsyncDoc]
|
126
|
+
def create_hosted_async_doc(doc, opts = {})
|
127
|
+
data, _status_code, _headers = create_hosted_async_doc_with_http_info(doc, opts)
|
128
|
+
data
|
129
|
+
end
|
130
|
+
|
131
|
+
# Creates a hosted document asynchronously. You must use a callback url or the returned status id and the status API to find out when it completes. Then use the download API to get the document.
|
132
|
+
# @param doc The document to be created.
|
133
|
+
# @param [Hash] opts the optional parameters
|
134
|
+
# @return [Array<(AsyncDoc, Fixnum, Hash)>] AsyncDoc data, response status code and response headers
|
135
|
+
def create_hosted_async_doc_with_http_info(doc, opts = {})
|
136
|
+
if @api_client.config.debugging
|
137
|
+
@api_client.config.logger.debug 'Calling API: DocApi.create_hosted_async_doc ...'
|
138
|
+
end
|
139
|
+
# verify the required parameter 'doc' is set
|
140
|
+
if @api_client.config.client_side_validation && doc.nil?
|
141
|
+
fail ArgumentError, "Missing the required parameter 'doc' when calling DocApi.create_hosted_async_doc"
|
142
|
+
end
|
143
|
+
# resource path
|
144
|
+
local_var_path = '/hosted_async_docs'
|
145
|
+
|
146
|
+
# query parameters
|
147
|
+
query_params = {}
|
148
|
+
|
149
|
+
# header parameters
|
150
|
+
header_params = {}
|
151
|
+
# HTTP header 'Accept' (if needed)
|
152
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/xml', 'application/pdf', 'application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'])
|
153
|
+
|
154
|
+
# form parameters
|
155
|
+
form_params = {}
|
156
|
+
|
157
|
+
# http body (model)
|
158
|
+
post_body = @api_client.object_to_http_body(doc)
|
159
|
+
auth_names = ['basicAuth']
|
160
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
|
161
|
+
:header_params => header_params,
|
162
|
+
:query_params => query_params,
|
163
|
+
:form_params => form_params,
|
164
|
+
:body => post_body,
|
165
|
+
:auth_names => auth_names,
|
166
|
+
:return_type => 'AsyncDoc')
|
167
|
+
if @api_client.config.debugging
|
168
|
+
@api_client.config.logger.debug "API called: DocApi#create_hosted_async_doc\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
169
|
+
end
|
170
|
+
return data, status_code, headers
|
171
|
+
end
|
172
|
+
# Creates a hosted document synchronously.
|
173
|
+
# @param doc The document to be created.
|
174
|
+
# @param [Hash] opts the optional parameters
|
175
|
+
# @return [DocStatus]
|
176
|
+
def create_hosted_doc(doc, opts = {})
|
177
|
+
data, _status_code, _headers = create_hosted_doc_with_http_info(doc, opts)
|
178
|
+
data
|
179
|
+
end
|
180
|
+
|
181
|
+
# Creates a hosted document synchronously.
|
182
|
+
# @param doc The document to be created.
|
183
|
+
# @param [Hash] opts the optional parameters
|
184
|
+
# @return [Array<(DocStatus, Fixnum, Hash)>] DocStatus data, response status code and response headers
|
185
|
+
def create_hosted_doc_with_http_info(doc, opts = {})
|
186
|
+
if @api_client.config.debugging
|
187
|
+
@api_client.config.logger.debug 'Calling API: DocApi.create_hosted_doc ...'
|
188
|
+
end
|
189
|
+
# verify the required parameter 'doc' is set
|
190
|
+
if @api_client.config.client_side_validation && doc.nil?
|
191
|
+
fail ArgumentError, "Missing the required parameter 'doc' when calling DocApi.create_hosted_doc"
|
192
|
+
end
|
193
|
+
# resource path
|
194
|
+
local_var_path = '/hosted_docs'
|
195
|
+
|
196
|
+
# query parameters
|
197
|
+
query_params = {}
|
198
|
+
|
199
|
+
# header parameters
|
200
|
+
header_params = {}
|
201
|
+
# HTTP header 'Accept' (if needed)
|
202
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/xml', 'application/pdf', 'application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'])
|
203
|
+
|
204
|
+
# form parameters
|
205
|
+
form_params = {}
|
206
|
+
|
207
|
+
# http body (model)
|
208
|
+
post_body = @api_client.object_to_http_body(doc)
|
209
|
+
auth_names = ['basicAuth']
|
210
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
|
211
|
+
:header_params => header_params,
|
212
|
+
:query_params => query_params,
|
213
|
+
:form_params => form_params,
|
214
|
+
:body => post_body,
|
215
|
+
:auth_names => auth_names,
|
216
|
+
:return_type => 'DocStatus')
|
217
|
+
if @api_client.config.debugging
|
218
|
+
@api_client.config.logger.debug "API called: DocApi#create_hosted_doc\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
219
|
+
end
|
220
|
+
return data, status_code, headers
|
221
|
+
end
|
222
|
+
# Expires a previously created hosted doc.
|
223
|
+
# @param id The download_id returned from status request or hosted document response.
|
224
|
+
# @param [Hash] opts the optional parameters
|
225
|
+
# @return [nil]
|
226
|
+
def expire(id, opts = {})
|
227
|
+
expire_with_http_info(id, opts)
|
228
|
+
nil
|
229
|
+
end
|
230
|
+
|
231
|
+
# Expires a previously created hosted doc.
|
232
|
+
# @param id The download_id returned from status request or hosted document response.
|
233
|
+
# @param [Hash] opts the optional parameters
|
234
|
+
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
|
235
|
+
def expire_with_http_info(id, opts = {})
|
236
|
+
if @api_client.config.debugging
|
237
|
+
@api_client.config.logger.debug 'Calling API: DocApi.expire ...'
|
238
|
+
end
|
239
|
+
# verify the required parameter 'id' is set
|
240
|
+
if @api_client.config.client_side_validation && id.nil?
|
241
|
+
fail ArgumentError, "Missing the required parameter 'id' when calling DocApi.expire"
|
242
|
+
end
|
243
|
+
# resource path
|
244
|
+
local_var_path = '/expire/{id}'.sub('{' + 'id' + '}', id.to_s)
|
245
|
+
|
246
|
+
# query parameters
|
247
|
+
query_params = {}
|
248
|
+
|
249
|
+
# header parameters
|
250
|
+
header_params = {}
|
251
|
+
# HTTP header 'Accept' (if needed)
|
252
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/xml', 'application/pdf', 'application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'])
|
253
|
+
|
254
|
+
# form parameters
|
255
|
+
form_params = {}
|
128
256
|
|
129
|
-
|
130
|
-
|
131
|
-
|
257
|
+
# http body (model)
|
258
|
+
post_body = nil
|
259
|
+
auth_names = ['basicAuth']
|
260
|
+
data, status_code, headers = @api_client.call_api(:PATCH, local_var_path,
|
261
|
+
:header_params => header_params,
|
262
|
+
:query_params => query_params,
|
263
|
+
:form_params => form_params,
|
264
|
+
:body => post_body,
|
265
|
+
:auth_names => auth_names)
|
266
|
+
if @api_client.config.debugging
|
267
|
+
@api_client.config.logger.debug "API called: DocApi#expire\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
268
|
+
end
|
269
|
+
return data, status_code, headers
|
270
|
+
end
|
271
|
+
# Downloads a finished document.
|
272
|
+
# @param id The download_id returned from an async status request or callback.
|
132
273
|
# @param [Hash] opts the optional parameters
|
133
274
|
# @return [String]
|
134
275
|
def get_async_doc(id, opts = {})
|
135
276
|
data, _status_code, _headers = get_async_doc_with_http_info(id, opts)
|
136
|
-
|
277
|
+
data
|
137
278
|
end
|
138
279
|
|
139
|
-
#
|
140
|
-
#
|
141
|
-
# @param id The download_id returned from status request or a callback.
|
280
|
+
# Downloads a finished document.
|
281
|
+
# @param id The download_id returned from an async status request or callback.
|
142
282
|
# @param [Hash] opts the optional parameters
|
143
283
|
# @return [Array<(String, Fixnum, Hash)>] String data, response status code and response headers
|
144
284
|
def get_async_doc_with_http_info(id, opts = {})
|
145
285
|
if @api_client.config.debugging
|
146
|
-
@api_client.config.logger.debug
|
286
|
+
@api_client.config.logger.debug 'Calling API: DocApi.get_async_doc ...'
|
147
287
|
end
|
148
288
|
# verify the required parameter 'id' is set
|
149
289
|
if @api_client.config.client_side_validation && id.nil?
|
150
290
|
fail ArgumentError, "Missing the required parameter 'id' when calling DocApi.get_async_doc"
|
151
291
|
end
|
152
292
|
# resource path
|
153
|
-
local_var_path =
|
293
|
+
local_var_path = '/download/{id}'.sub('{' + 'id' + '}', id.to_s)
|
154
294
|
|
155
295
|
# query parameters
|
156
296
|
query_params = {}
|
@@ -178,32 +318,29 @@ module DocRaptor
|
|
178
318
|
end
|
179
319
|
return data, status_code, headers
|
180
320
|
end
|
181
|
-
|
182
|
-
#
|
183
321
|
# Check on the status of an asynchronously created document.
|
184
322
|
# @param id The status_id returned when creating an asynchronous document.
|
185
323
|
# @param [Hash] opts the optional parameters
|
186
|
-
# @return [
|
324
|
+
# @return [DocStatus]
|
187
325
|
def get_async_doc_status(id, opts = {})
|
188
326
|
data, _status_code, _headers = get_async_doc_status_with_http_info(id, opts)
|
189
|
-
|
327
|
+
data
|
190
328
|
end
|
191
329
|
|
192
|
-
#
|
193
330
|
# Check on the status of an asynchronously created document.
|
194
331
|
# @param id The status_id returned when creating an asynchronous document.
|
195
332
|
# @param [Hash] opts the optional parameters
|
196
|
-
# @return [Array<(
|
333
|
+
# @return [Array<(DocStatus, Fixnum, Hash)>] DocStatus data, response status code and response headers
|
197
334
|
def get_async_doc_status_with_http_info(id, opts = {})
|
198
335
|
if @api_client.config.debugging
|
199
|
-
@api_client.config.logger.debug
|
336
|
+
@api_client.config.logger.debug 'Calling API: DocApi.get_async_doc_status ...'
|
200
337
|
end
|
201
338
|
# verify the required parameter 'id' is set
|
202
339
|
if @api_client.config.client_side_validation && id.nil?
|
203
340
|
fail ArgumentError, "Missing the required parameter 'id' when calling DocApi.get_async_doc_status"
|
204
341
|
end
|
205
342
|
# resource path
|
206
|
-
local_var_path =
|
343
|
+
local_var_path = '/status/{id}'.sub('{' + 'id' + '}', id.to_s)
|
207
344
|
|
208
345
|
# query parameters
|
209
346
|
query_params = {}
|
@@ -225,7 +362,7 @@ module DocRaptor
|
|
225
362
|
:form_params => form_params,
|
226
363
|
:body => post_body,
|
227
364
|
:auth_names => auth_names,
|
228
|
-
:return_type => '
|
365
|
+
:return_type => 'DocStatus')
|
229
366
|
if @api_client.config.debugging
|
230
367
|
@api_client.config.logger.debug "API called: DocApi#get_async_doc_status\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
231
368
|
end
|
data/lib/docraptor/api_client.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
=begin
|
2
|
-
#DocRaptor
|
2
|
+
#DocRaptor
|
3
3
|
|
4
4
|
#A native client library for the DocRaptor HTML to PDF/XLS service.
|
5
5
|
|
6
|
-
OpenAPI spec version: 1.
|
6
|
+
OpenAPI spec version: 1.4.0
|
7
7
|
|
8
8
|
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
-
Swagger Codegen version: 2.
|
9
|
+
Swagger Codegen version: 2.4.14
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
@@ -33,7 +33,7 @@ module DocRaptor
|
|
33
33
|
@config = config
|
34
34
|
@user_agent = "ruby-swagger-#{VERSION}"
|
35
35
|
@default_headers = {
|
36
|
-
'Content-Type' =>
|
36
|
+
'Content-Type' => 'application/json',
|
37
37
|
'User-Agent' => @user_agent
|
38
38
|
}
|
39
39
|
end
|
@@ -112,6 +112,8 @@ module DocRaptor
|
|
112
112
|
:verbose => @config.debugging
|
113
113
|
}
|
114
114
|
|
115
|
+
req_opts.merge!(multipart: true) if header_params['Content-Type'].start_with? "multipart/"
|
116
|
+
|
115
117
|
# set custom cert, if provided
|
116
118
|
req_opts[:cainfo] = @config.ssl_ca_cert if @config.ssl_ca_cert
|
117
119
|
|
@@ -137,7 +139,7 @@ module DocRaptor
|
|
137
139
|
# @param [String] mime MIME
|
138
140
|
# @return [Boolean] True if the MIME is application/json
|
139
141
|
def json_mime?(mime)
|
140
|
-
|
142
|
+
(mime == '*/*') || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
|
141
143
|
end
|
142
144
|
|
143
145
|
# Deserialize the response to the given return type.
|
@@ -201,12 +203,12 @@ module DocRaptor
|
|
201
203
|
when /\AArray<(.+)>\z/
|
202
204
|
# e.g. Array<Pet>
|
203
205
|
sub_type = $1
|
204
|
-
data.map {|item| convert_to_type(item, sub_type) }
|
206
|
+
data.map { |item| convert_to_type(item, sub_type) }
|
205
207
|
when /\AHash\<String, (.+)\>\z/
|
206
208
|
# e.g. Hash<String, Integer>
|
207
209
|
sub_type = $1
|
208
210
|
{}.tap do |hash|
|
209
|
-
data.each {|k, v| hash[k] = convert_to_type(v, sub_type) }
|
211
|
+
data.each { |k, v| hash[k] = convert_to_type(v, sub_type) }
|
210
212
|
end
|
211
213
|
else
|
212
214
|
# models, e.g. Pet
|
@@ -228,7 +230,7 @@ module DocRaptor
|
|
228
230
|
encoding = nil
|
229
231
|
request.on_headers do |response|
|
230
232
|
content_disposition = response.headers['Content-Disposition']
|
231
|
-
if content_disposition
|
233
|
+
if content_disposition && content_disposition =~ /filename=/i
|
232
234
|
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
|
233
235
|
prefix = sanitize_filename(filename)
|
234
236
|
else
|
@@ -280,7 +282,7 @@ module DocRaptor
|
|
280
282
|
data = {}
|
281
283
|
form_params.each do |key, value|
|
282
284
|
case value
|
283
|
-
when File, Array, nil
|
285
|
+
when ::File, ::Array, nil
|
284
286
|
# let typhoeus handle File, Array and nil parameters
|
285
287
|
data[key] = value
|
286
288
|
else
|
@@ -327,7 +329,7 @@ module DocRaptor
|
|
327
329
|
return nil if accepts.nil? || accepts.empty?
|
328
330
|
# use JSON when present, otherwise use all of the provided
|
329
331
|
json_accept = accepts.find { |s| json_mime?(s) }
|
330
|
-
|
332
|
+
json_accept || accepts.join(',')
|
331
333
|
end
|
332
334
|
|
333
335
|
# Return Content-Type header based on an array of content types provided.
|
@@ -338,7 +340,7 @@ module DocRaptor
|
|
338
340
|
return 'application/json' if content_types.nil? || content_types.empty?
|
339
341
|
# use JSON when present, otherwise use the first one
|
340
342
|
json_content_type = content_types.find { |s| json_mime?(s) }
|
341
|
-
|
343
|
+
json_content_type || content_types.first
|
342
344
|
end
|
343
345
|
|
344
346
|
# Convert object (array, hash, object, etc) to JSON string.
|
@@ -348,7 +350,7 @@ module DocRaptor
|
|
348
350
|
return model if model.nil? || model.is_a?(String)
|
349
351
|
local_body = nil
|
350
352
|
if model.is_a?(Array)
|
351
|
-
local_body = model.map{|m| object_to_hash(m) }
|
353
|
+
local_body = model.map { |m| object_to_hash(m) }
|
352
354
|
else
|
353
355
|
local_body = object_to_hash(model)
|
354
356
|
end
|