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
@@ -1,19 +1,18 @@
|
|
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
13
|
require 'date'
|
14
14
|
|
15
15
|
module DocRaptor
|
16
|
-
|
17
16
|
class PrinceOptions
|
18
17
|
# Set the baseurl for assets.
|
19
18
|
attr_accessor :baseurl
|
@@ -205,7 +204,7 @@ module DocRaptor
|
|
205
204
|
return unless attributes.is_a?(Hash)
|
206
205
|
|
207
206
|
# convert string to symbol for hash key
|
208
|
-
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
207
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
209
208
|
|
210
209
|
if attributes.has_key?(:'baseurl')
|
211
210
|
self.baseurl = attributes[:'baseurl']
|
@@ -246,7 +245,7 @@ module DocRaptor
|
|
246
245
|
if attributes.has_key?(:'media')
|
247
246
|
self.media = attributes[:'media']
|
248
247
|
else
|
249
|
-
self.media =
|
248
|
+
self.media = 'print'
|
250
249
|
end
|
251
250
|
|
252
251
|
if attributes.has_key?(:'no_author_style')
|
@@ -308,7 +307,7 @@ module DocRaptor
|
|
308
307
|
if attributes.has_key?(:'input')
|
309
308
|
self.input = attributes[:'input']
|
310
309
|
else
|
311
|
-
self.input =
|
310
|
+
self.input = 'html'
|
312
311
|
end
|
313
312
|
|
314
313
|
if attributes.has_key?(:'version')
|
@@ -330,30 +329,29 @@ module DocRaptor
|
|
330
329
|
if attributes.has_key?(:'pdf_title')
|
331
330
|
self.pdf_title = attributes[:'pdf_title']
|
332
331
|
end
|
333
|
-
|
334
332
|
end
|
335
333
|
|
336
334
|
# Show invalid properties with the reasons. Usually used together with valid?
|
337
|
-
# @return Array for valid
|
335
|
+
# @return Array for valid properties with the reasons
|
338
336
|
def list_invalid_properties
|
339
337
|
invalid_properties = Array.new
|
340
|
-
|
338
|
+
invalid_properties
|
341
339
|
end
|
342
340
|
|
343
341
|
# Check to see if the all the properties in the model are valid
|
344
342
|
# @return true if the model is valid
|
345
343
|
def valid?
|
346
|
-
input_validator = EnumAttributeValidator.new('String', [
|
344
|
+
input_validator = EnumAttributeValidator.new('String', ['html', 'xml', 'auto'])
|
347
345
|
return false unless input_validator.valid?(@input)
|
348
|
-
|
346
|
+
true
|
349
347
|
end
|
350
348
|
|
351
349
|
# Custom attribute writer method checking allowed values (enum).
|
352
350
|
# @param [Object] input Object to be assigned
|
353
351
|
def input=(input)
|
354
|
-
validator = EnumAttributeValidator.new('String', [
|
352
|
+
validator = EnumAttributeValidator.new('String', ['html', 'xml', 'auto'])
|
355
353
|
unless validator.valid?(input)
|
356
|
-
fail ArgumentError,
|
354
|
+
fail ArgumentError, 'invalid value for "input", must be one of #{validator.allowable_values}.'
|
357
355
|
end
|
358
356
|
@input = input
|
359
357
|
end
|
@@ -414,10 +412,10 @@ module DocRaptor
|
|
414
412
|
return nil unless attributes.is_a?(Hash)
|
415
413
|
self.class.swagger_types.each_pair do |key, type|
|
416
414
|
if type =~ /\AArray<(.*)>/i
|
417
|
-
# check to ensure the input is an array given that the
|
415
|
+
# check to ensure the input is an array given that the attribute
|
418
416
|
# is documented as an array but the input is not
|
419
417
|
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
420
|
-
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) }
|
418
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
421
419
|
end
|
422
420
|
elsif !attributes[self.class.attribute_map[key]].nil?
|
423
421
|
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
@@ -499,7 +497,7 @@ module DocRaptor
|
|
499
497
|
# @return [Hash] Returns the value in the form of hash
|
500
498
|
def _to_hash(value)
|
501
499
|
if value.is_a?(Array)
|
502
|
-
value.compact.map{ |v| _to_hash(v) }
|
500
|
+
value.compact.map { |v| _to_hash(v) }
|
503
501
|
elsif value.is_a?(Hash)
|
504
502
|
{}.tap do |hash|
|
505
503
|
value.each { |k, v| hash[k] = _to_hash(v) }
|
@@ -512,5 +510,4 @@ module DocRaptor
|
|
512
510
|
end
|
513
511
|
|
514
512
|
end
|
515
|
-
|
516
513
|
end
|
data/lib/docraptor/version.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
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
13
|
module DocRaptor
|
14
|
-
VERSION =
|
14
|
+
VERSION = '1.4.0'
|
15
15
|
end
|
data/script/fix_gemspec.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
|
1
|
+
# coding: utf-8
|
2
|
+
bad_files = %q{s.files = `find *`.split("\n").uniq.sort.select { |f| !f.empty? }}
|
2
3
|
bad_test_files = %q{s.test_files = `find spec/*`.split("\n")}
|
3
|
-
good_files = %q{s.files = `git ls-files`.split("\n").uniq.sort.select{|f| !f.empty? }}
|
4
|
+
good_files = %q{s.files = `git ls-files`.split("\n").uniq.sort.select { |f| !f.empty? }}
|
4
5
|
good_test_files = %q{s.test_files = `git ls-files spec test`.split("\n")}
|
5
6
|
|
6
7
|
development_dependency_marker = %q{ s.add_development_dependency 'autotest-fsevent', '~> 0.2', '>= 0.2.12'}
|
data/script/swagger
CHANGED
@@ -8,6 +8,11 @@ if [ "$SWAGGER_CODGEN_REVISION" = "" ]; then
|
|
8
8
|
exit 1
|
9
9
|
fi
|
10
10
|
|
11
|
+
if ! [ -x "$(command -v mvn)" ]; then
|
12
|
+
echo 'Error: mvn not installed, using homebrew to install' >&2
|
13
|
+
brew install maven
|
14
|
+
fi
|
15
|
+
|
11
16
|
if [ ! -d "swagger-codegen" ]; then
|
12
17
|
git clone https://github.com/swagger-api/swagger-codegen
|
13
18
|
fi
|
@@ -31,5 +36,5 @@ if [ ! -f "$executable" ]; then
|
|
31
36
|
mvn clean package
|
32
37
|
fi
|
33
38
|
|
34
|
-
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
39
|
+
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties -DapiTests=false -DapiDocs=false -DmodelTests=false -DmodelDocs=false"
|
35
40
|
java $JAVA_OPTS -jar $executable $*
|
data/spec/api_client_spec.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
|
|
@@ -51,11 +51,11 @@ describe DocRaptor::ApiClient do
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
-
describe
|
54
|
+
describe 'params_encoding in #build_request' do
|
55
55
|
let(:config) { DocRaptor::Configuration.new }
|
56
56
|
let(:api_client) { DocRaptor::ApiClient.new(config) }
|
57
57
|
|
58
|
-
it
|
58
|
+
it 'defaults to nil' do
|
59
59
|
expect(DocRaptor::Configuration.default.params_encoding).to eq(nil)
|
60
60
|
expect(config.params_encoding).to eq(nil)
|
61
61
|
|
@@ -63,18 +63,18 @@ describe DocRaptor::ApiClient do
|
|
63
63
|
expect(request.options[:params_encoding]).to eq(nil)
|
64
64
|
end
|
65
65
|
|
66
|
-
it
|
66
|
+
it 'can be customized' do
|
67
67
|
config.params_encoding = :multi
|
68
68
|
request = api_client.build_request(:get, '/test')
|
69
69
|
expect(request.options[:params_encoding]).to eq(:multi)
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
|
-
describe
|
73
|
+
describe 'timeout in #build_request' do
|
74
74
|
let(:config) { DocRaptor::Configuration.new }
|
75
75
|
let(:api_client) { DocRaptor::ApiClient.new(config) }
|
76
76
|
|
77
|
-
it
|
77
|
+
it 'defaults to 0' do
|
78
78
|
expect(DocRaptor::Configuration.default.timeout).to eq(0)
|
79
79
|
expect(config.timeout).to eq(0)
|
80
80
|
|
@@ -82,88 +82,105 @@ describe DocRaptor::ApiClient do
|
|
82
82
|
expect(request.options[:timeout]).to eq(0)
|
83
83
|
end
|
84
84
|
|
85
|
-
it
|
85
|
+
it 'can be customized' do
|
86
86
|
config.timeout = 100
|
87
87
|
request = api_client.build_request(:get, '/test')
|
88
88
|
expect(request.options[:timeout]).to eq(100)
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
|
-
describe
|
92
|
+
describe '#build_request' do
|
93
|
+
let(:config) { DocRaptor::Configuration.new }
|
94
|
+
let(:api_client) { DocRaptor::ApiClient.new(config) }
|
95
|
+
|
96
|
+
it 'does not send multipart to request' do
|
97
|
+
expect(Typhoeus::Request).to receive(:new).with(anything, hash_not_including(:multipart))
|
98
|
+
api_client.build_request(:get, '/test')
|
99
|
+
end
|
100
|
+
|
101
|
+
context 'when the content type is multipart' do
|
102
|
+
it 'sends multipart to request' do
|
103
|
+
expect(Typhoeus::Request).to receive(:new).with(anything, hash_including(multipart: true))
|
104
|
+
api_client.build_request(:get, '/test', {header_params: { 'Content-Type' => 'multipart/form-data'}})
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
describe '#deserialize' do
|
93
110
|
it "handles Array<Integer>" do
|
94
111
|
api_client = DocRaptor::ApiClient.new
|
95
|
-
headers = {'Content-Type' => 'application/json'}
|
112
|
+
headers = { 'Content-Type' => 'application/json' }
|
96
113
|
response = double('response', headers: headers, body: '[12, 34]')
|
97
114
|
data = api_client.deserialize(response, 'Array<Integer>')
|
98
115
|
expect(data).to be_instance_of(Array)
|
99
116
|
expect(data).to eq([12, 34])
|
100
117
|
end
|
101
118
|
|
102
|
-
it
|
119
|
+
it 'handles Array<Array<Integer>>' do
|
103
120
|
api_client = DocRaptor::ApiClient.new
|
104
|
-
headers = {'Content-Type' => 'application/json'}
|
121
|
+
headers = { 'Content-Type' => 'application/json' }
|
105
122
|
response = double('response', headers: headers, body: '[[12, 34], [56]]')
|
106
123
|
data = api_client.deserialize(response, 'Array<Array<Integer>>')
|
107
124
|
expect(data).to be_instance_of(Array)
|
108
125
|
expect(data).to eq([[12, 34], [56]])
|
109
126
|
end
|
110
127
|
|
111
|
-
it
|
128
|
+
it 'handles Hash<String, String>' do
|
112
129
|
api_client = DocRaptor::ApiClient.new
|
113
|
-
headers = {'Content-Type' => 'application/json'}
|
130
|
+
headers = { 'Content-Type' => 'application/json' }
|
114
131
|
response = double('response', headers: headers, body: '{"message": "Hello"}')
|
115
132
|
data = api_client.deserialize(response, 'Hash<String, String>')
|
116
133
|
expect(data).to be_instance_of(Hash)
|
117
|
-
expect(data).to eq(
|
134
|
+
expect(data).to eq(:message => 'Hello')
|
118
135
|
end
|
119
136
|
end
|
120
137
|
|
121
138
|
describe "#object_to_hash" do
|
122
|
-
it
|
139
|
+
it 'ignores nils and includes empty arrays' do
|
123
140
|
# uncomment below to test object_to_hash for model
|
124
|
-
#api_client = DocRaptor::ApiClient.new
|
125
|
-
#_model = DocRaptor::ModelName.new
|
141
|
+
# api_client = DocRaptor::ApiClient.new
|
142
|
+
# _model = DocRaptor::ModelName.new
|
126
143
|
# update the model attribute below
|
127
|
-
#_model.id = 1
|
144
|
+
# _model.id = 1
|
128
145
|
# update the expected value (hash) below
|
129
|
-
#expected = {id: 1, name: '', tags: []}
|
130
|
-
#expect(api_client.object_to_hash(_model)).to eq(expected)
|
146
|
+
# expected = {id: 1, name: '', tags: []}
|
147
|
+
# expect(api_client.object_to_hash(_model)).to eq(expected)
|
131
148
|
end
|
132
149
|
end
|
133
150
|
|
134
|
-
describe
|
151
|
+
describe '#build_collection_param' do
|
135
152
|
let(:param) { ['aa', 'bb', 'cc'] }
|
136
153
|
let(:api_client) { DocRaptor::ApiClient.new }
|
137
154
|
|
138
|
-
it
|
155
|
+
it 'works for csv' do
|
139
156
|
expect(api_client.build_collection_param(param, :csv)).to eq('aa,bb,cc')
|
140
157
|
end
|
141
158
|
|
142
|
-
it
|
159
|
+
it 'works for ssv' do
|
143
160
|
expect(api_client.build_collection_param(param, :ssv)).to eq('aa bb cc')
|
144
161
|
end
|
145
162
|
|
146
|
-
it
|
163
|
+
it 'works for tsv' do
|
147
164
|
expect(api_client.build_collection_param(param, :tsv)).to eq("aa\tbb\tcc")
|
148
165
|
end
|
149
166
|
|
150
|
-
it
|
167
|
+
it 'works for pipes' do
|
151
168
|
expect(api_client.build_collection_param(param, :pipes)).to eq('aa|bb|cc')
|
152
169
|
end
|
153
170
|
|
154
|
-
it
|
171
|
+
it 'works for multi' do
|
155
172
|
expect(api_client.build_collection_param(param, :multi)).to eq(['aa', 'bb', 'cc'])
|
156
173
|
end
|
157
174
|
|
158
|
-
it
|
175
|
+
it 'fails for invalid collection format' do
|
159
176
|
expect(proc { api_client.build_collection_param(param, :INVALID) }).to raise_error(RuntimeError, 'unknown collection format: :INVALID')
|
160
177
|
end
|
161
178
|
end
|
162
179
|
|
163
|
-
describe
|
180
|
+
describe '#json_mime?' do
|
164
181
|
let(:api_client) { DocRaptor::ApiClient.new }
|
165
182
|
|
166
|
-
it
|
183
|
+
it 'works' do
|
167
184
|
expect(api_client.json_mime?(nil)).to eq false
|
168
185
|
expect(api_client.json_mime?('')).to eq false
|
169
186
|
|
@@ -177,10 +194,10 @@ describe DocRaptor::ApiClient do
|
|
177
194
|
end
|
178
195
|
end
|
179
196
|
|
180
|
-
describe
|
197
|
+
describe '#select_header_accept' do
|
181
198
|
let(:api_client) { DocRaptor::ApiClient.new }
|
182
199
|
|
183
|
-
it
|
200
|
+
it 'works' do
|
184
201
|
expect(api_client.select_header_accept(nil)).to be_nil
|
185
202
|
expect(api_client.select_header_accept([])).to be_nil
|
186
203
|
|
@@ -193,10 +210,10 @@ describe DocRaptor::ApiClient do
|
|
193
210
|
end
|
194
211
|
end
|
195
212
|
|
196
|
-
describe
|
213
|
+
describe '#select_header_content_type' do
|
197
214
|
let(:api_client) { DocRaptor::ApiClient.new }
|
198
215
|
|
199
|
-
it
|
216
|
+
it 'works' do
|
200
217
|
expect(api_client.select_header_content_type(nil)).to eq('application/json')
|
201
218
|
expect(api_client.select_header_content_type([])).to eq('application/json')
|
202
219
|
|
@@ -208,10 +225,10 @@ describe DocRaptor::ApiClient do
|
|
208
225
|
end
|
209
226
|
end
|
210
227
|
|
211
|
-
describe
|
228
|
+
describe '#sanitize_filename' do
|
212
229
|
let(:api_client) { DocRaptor::ApiClient.new }
|
213
230
|
|
214
|
-
it
|
231
|
+
it 'works' do
|
215
232
|
expect(api_client.sanitize_filename('sun')).to eq('sun')
|
216
233
|
expect(api_client.sanitize_filename('sun.gif')).to eq('sun.gif')
|
217
234
|
expect(api_client.sanitize_filename('../sun.gif')).to eq('sun.gif')
|
data/spec/configuration_spec.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
|
|
@@ -17,25 +17,25 @@ describe DocRaptor::Configuration do
|
|
17
17
|
|
18
18
|
before(:each) do
|
19
19
|
# uncomment below to setup host and base_path
|
20
|
-
#require 'URI'
|
21
|
-
#uri = URI.parse("https://docraptor.com")
|
22
|
-
#DocRaptor.configure do |c|
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#end
|
20
|
+
# require 'URI'
|
21
|
+
# uri = URI.parse("https://docraptor.com")
|
22
|
+
# DocRaptor.configure do |c|
|
23
|
+
# c.host = uri.host
|
24
|
+
# c.base_path = uri.path
|
25
|
+
# end
|
26
26
|
end
|
27
27
|
|
28
28
|
describe '#base_url' do
|
29
29
|
it 'should have the default value' do
|
30
30
|
# uncomment below to test default value of the base path
|
31
|
-
#expect(config.base_url).to eq("https://docraptor.com")
|
31
|
+
# expect(config.base_url).to eq("https://docraptor.com")
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'should remove trailing slashes' do
|
35
35
|
[nil, '', '/', '//'].each do |base_path|
|
36
36
|
config.base_path = base_path
|
37
37
|
# uncomment below to test trailing slashes
|
38
|
-
#expect(config.base_url).to eq("https://docraptor.com")
|
38
|
+
# expect(config.base_url).to eq("https://docraptor.com")
|
39
39
|
end
|
40
40
|
end
|
41
41
|
end
|
data/spec/spec_helper.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
|
|
data/swagger-config.json
CHANGED