docraptor 2.0.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/.docker_env.list +3 -0
  3. data/.generator-language-identifier +1 -0
  4. data/.generator-revision +1 -0
  5. data/.github/pull_request_template.txt +17 -0
  6. data/.gitignore +20 -14
  7. data/.gitlab-ci.yml +26 -0
  8. data/.openapi-generator/FILES +27 -0
  9. data/.openapi-generator/VERSION +1 -0
  10. data/{.swagger-codegen-ignore → .openapi-generator-ignore} +23 -7
  11. data/.review/README.md +16 -0
  12. data/.review/generated_files/.gitignore +39 -0
  13. data/.review/generated_files/README.md +107 -0
  14. data/.rubocop.yml +148 -0
  15. data/.runtime-environments +10 -0
  16. data/.travis.yml +12 -7
  17. data/CHANGELOG.md +5 -0
  18. data/Gemfile +3 -1
  19. data/README.md +8 -8
  20. data/Rakefile +1 -2
  21. data/docraptor.gemspec +5 -19
  22. data/docraptor.yaml +5 -4
  23. data/examples/async.rb +24 -30
  24. data/examples/hosted_async.rb +21 -33
  25. data/examples/hosted_sync.rb +19 -32
  26. data/examples/sync.rb +20 -26
  27. data/gemfiles/Gemfile.2.5.lock +70 -0
  28. data/gemfiles/Gemfile.2.6.lock +70 -0
  29. data/gemfiles/Gemfile.2.7.lock +70 -0
  30. data/gemfiles/Gemfile.3.0.lock +70 -0
  31. data/{swagger-config.json → generator-config.json} +3 -2
  32. data/lib/docraptor/api/doc_api.rb +154 -79
  33. data/lib/docraptor/api_client.rb +91 -90
  34. data/lib/docraptor/api_error.rb +22 -3
  35. data/lib/docraptor/configuration.rb +85 -15
  36. data/lib/docraptor/models/async_doc.rb +53 -18
  37. data/lib/docraptor/models/doc.rb +80 -45
  38. data/lib/docraptor/models/doc_status.rb +58 -23
  39. data/lib/docraptor/models/prince_options.rb +101 -66
  40. data/lib/docraptor/version.rb +4 -4
  41. data/lib/docraptor.rb +3 -3
  42. data/script/clean +2 -2
  43. data/script/console +5 -0
  44. data/script/docker +39 -0
  45. data/script/fix_gemspec.rb +3 -18
  46. data/script/generate_language +21 -4
  47. data/script/inside_container/README.md +6 -0
  48. data/script/inside_container/test +38 -0
  49. data/script/post_generate_language +10 -2
  50. data/script/setup +25 -14
  51. data/script/swagger +6 -33
  52. data/script/test +30 -27
  53. data/test/async.rb +2 -2
  54. data/test/expire_hosted.rb +2 -2
  55. data/test/hosted_async.rb +7 -1
  56. data/test/hosted_sync.rb +2 -2
  57. data/test/sync.rb +2 -2
  58. data/test/xlsx.rb +6 -3
  59. metadata +29 -217
  60. data/.swagger-codegen/VERSION +0 -1
  61. data/.swagger-revision +0 -1
  62. data/spec/api_client_spec.rb +0 -243
  63. data/spec/configuration_spec.rb +0 -42
  64. data/spec/spec_helper.rb +0 -111
@@ -3,14 +3,15 @@
3
3
 
4
4
  #A native client library for the DocRaptor HTML to PDF/XLS service.
5
5
 
6
- OpenAPI spec version: 1.4.0
6
+ The version of the OpenAPI document: 2.0.0
7
7
 
8
- Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.4.19
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.1.0-SNAPSHOT
10
10
 
11
11
  =end
12
12
 
13
13
  require 'date'
14
+ require 'time'
14
15
 
15
16
  module DocRaptor
16
17
  class Doc
@@ -109,21 +110,26 @@ module DocRaptor
109
110
  }
110
111
  end
111
112
 
113
+ # Returns all the JSON keys this model knows about
114
+ def self.acceptable_attributes
115
+ attribute_map.values
116
+ end
117
+
112
118
  # Attribute type mapping.
113
- def self.swagger_types
119
+ def self.openapi_types
114
120
  {
115
121
  :'name' => :'String',
116
122
  :'document_type' => :'String',
117
123
  :'document_content' => :'String',
118
124
  :'document_url' => :'String',
119
- :'test' => :'BOOLEAN',
125
+ :'test' => :'Boolean',
120
126
  :'pipeline' => :'String',
121
127
  :'strict' => :'String',
122
- :'ignore_resource_errors' => :'BOOLEAN',
123
- :'ignore_console_messages' => :'BOOLEAN',
128
+ :'ignore_resource_errors' => :'Boolean',
129
+ :'ignore_console_messages' => :'Boolean',
124
130
  :'tag' => :'String',
125
- :'help' => :'BOOLEAN',
126
- :'javascript' => :'BOOLEAN',
131
+ :'help' => :'Boolean',
132
+ :'javascript' => :'Boolean',
127
133
  :'referrer' => :'String',
128
134
  :'callback_url' => :'String',
129
135
  :'hosted_download_limit' => :'Integer',
@@ -132,89 +138,102 @@ module DocRaptor
132
138
  }
133
139
  end
134
140
 
141
+ # List of attributes with nullable: true
142
+ def self.openapi_nullable
143
+ Set.new([
144
+ ])
145
+ end
146
+
135
147
  # Initializes the object
136
148
  # @param [Hash] attributes Model attributes in the form of hash
137
149
  def initialize(attributes = {})
138
- return unless attributes.is_a?(Hash)
150
+ if (!attributes.is_a?(Hash))
151
+ fail ArgumentError, "The input argument (attributes) must be a hash in `DocRaptor::Doc` initialize method"
152
+ end
139
153
 
140
- # convert string to symbol for hash key
141
- attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
154
+ # check to see if the attribute exists and convert string to symbol for hash key
155
+ attributes = attributes.each_with_object({}) { |(k, v), h|
156
+ if (!self.class.attribute_map.key?(k.to_sym))
157
+ fail ArgumentError, "`#{k}` is not a valid attribute in `DocRaptor::Doc`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
158
+ end
159
+ h[k.to_sym] = v
160
+ }
142
161
 
143
- if attributes.has_key?(:'name')
162
+ if attributes.key?(:'name')
144
163
  self.name = attributes[:'name']
145
164
  end
146
165
 
147
- if attributes.has_key?(:'document_type')
166
+ if attributes.key?(:'document_type')
148
167
  self.document_type = attributes[:'document_type']
149
168
  end
150
169
 
151
- if attributes.has_key?(:'document_content')
170
+ if attributes.key?(:'document_content')
152
171
  self.document_content = attributes[:'document_content']
153
172
  end
154
173
 
155
- if attributes.has_key?(:'document_url')
174
+ if attributes.key?(:'document_url')
156
175
  self.document_url = attributes[:'document_url']
157
176
  end
158
177
 
159
- if attributes.has_key?(:'test')
178
+ if attributes.key?(:'test')
160
179
  self.test = attributes[:'test']
161
180
  else
162
181
  self.test = true
163
182
  end
164
183
 
165
- if attributes.has_key?(:'pipeline')
184
+ if attributes.key?(:'pipeline')
166
185
  self.pipeline = attributes[:'pipeline']
167
186
  end
168
187
 
169
- if attributes.has_key?(:'strict')
188
+ if attributes.key?(:'strict')
170
189
  self.strict = attributes[:'strict']
171
190
  end
172
191
 
173
- if attributes.has_key?(:'ignore_resource_errors')
192
+ if attributes.key?(:'ignore_resource_errors')
174
193
  self.ignore_resource_errors = attributes[:'ignore_resource_errors']
175
194
  else
176
195
  self.ignore_resource_errors = true
177
196
  end
178
197
 
179
- if attributes.has_key?(:'ignore_console_messages')
198
+ if attributes.key?(:'ignore_console_messages')
180
199
  self.ignore_console_messages = attributes[:'ignore_console_messages']
181
200
  else
182
201
  self.ignore_console_messages = false
183
202
  end
184
203
 
185
- if attributes.has_key?(:'tag')
204
+ if attributes.key?(:'tag')
186
205
  self.tag = attributes[:'tag']
187
206
  end
188
207
 
189
- if attributes.has_key?(:'help')
208
+ if attributes.key?(:'help')
190
209
  self.help = attributes[:'help']
191
210
  else
192
211
  self.help = false
193
212
  end
194
213
 
195
- if attributes.has_key?(:'javascript')
214
+ if attributes.key?(:'javascript')
196
215
  self.javascript = attributes[:'javascript']
197
216
  else
198
217
  self.javascript = false
199
218
  end
200
219
 
201
- if attributes.has_key?(:'referrer')
220
+ if attributes.key?(:'referrer')
202
221
  self.referrer = attributes[:'referrer']
203
222
  end
204
223
 
205
- if attributes.has_key?(:'callback_url')
224
+ if attributes.key?(:'callback_url')
206
225
  self.callback_url = attributes[:'callback_url']
207
226
  end
208
227
 
209
- if attributes.has_key?(:'hosted_download_limit')
228
+ if attributes.key?(:'hosted_download_limit')
210
229
  self.hosted_download_limit = attributes[:'hosted_download_limit']
211
230
  end
212
231
 
213
- if attributes.has_key?(:'hosted_expires_at')
232
+ if attributes.key?(:'hosted_expires_at')
214
233
  self.hosted_expires_at = attributes[:'hosted_expires_at']
215
234
  end
216
235
 
217
- if attributes.has_key?(:'prince_options')
236
+ if attributes.key?(:'prince_options')
218
237
  self.prince_options = attributes[:'prince_options']
219
238
  end
220
239
  end
@@ -243,10 +262,10 @@ module DocRaptor
243
262
  def valid?
244
263
  return false if @name.nil?
245
264
  return false if @document_type.nil?
246
- document_type_validator = EnumAttributeValidator.new('String', ['pdf', 'xls', 'xlsx'])
265
+ document_type_validator = EnumAttributeValidator.new('String', ["pdf", "xls", "xlsx"])
247
266
  return false unless document_type_validator.valid?(@document_type)
248
267
  return false if @document_content.nil?
249
- strict_validator = EnumAttributeValidator.new('String', ['none', 'html'])
268
+ strict_validator = EnumAttributeValidator.new('String', ["none", "html"])
250
269
  return false unless strict_validator.valid?(@strict)
251
270
  true
252
271
  end
@@ -254,9 +273,9 @@ module DocRaptor
254
273
  # Custom attribute writer method checking allowed values (enum).
255
274
  # @param [Object] document_type Object to be assigned
256
275
  def document_type=(document_type)
257
- validator = EnumAttributeValidator.new('String', ['pdf', 'xls', 'xlsx'])
276
+ validator = EnumAttributeValidator.new('String', ["pdf", "xls", "xlsx"])
258
277
  unless validator.valid?(document_type)
259
- fail ArgumentError, 'invalid value for "document_type", must be one of #{validator.allowable_values}.'
278
+ fail ArgumentError, "invalid value for \"document_type\", must be one of #{validator.allowable_values}."
260
279
  end
261
280
  @document_type = document_type
262
281
  end
@@ -264,9 +283,9 @@ module DocRaptor
264
283
  # Custom attribute writer method checking allowed values (enum).
265
284
  # @param [Object] strict Object to be assigned
266
285
  def strict=(strict)
267
- validator = EnumAttributeValidator.new('String', ['none', 'html'])
286
+ validator = EnumAttributeValidator.new('String', ["none", "html"])
268
287
  unless validator.valid?(strict)
269
- fail ArgumentError, 'invalid value for "strict", must be one of #{validator.allowable_values}.'
288
+ fail ArgumentError, "invalid value for \"strict\", must be one of #{validator.allowable_values}."
270
289
  end
271
290
  @strict = strict
272
291
  end
@@ -302,18 +321,28 @@ module DocRaptor
302
321
  end
303
322
 
304
323
  # Calculates hash code according to all attributes.
305
- # @return [Fixnum] Hash code
324
+ # @return [Integer] Hash code
306
325
  def hash
307
326
  [name, document_type, document_content, document_url, test, pipeline, strict, ignore_resource_errors, ignore_console_messages, tag, help, javascript, referrer, callback_url, hosted_download_limit, hosted_expires_at, prince_options].hash
308
327
  end
309
328
 
329
+ # Builds the object from hash
330
+ # @param [Hash] attributes Model attributes in the form of hash
331
+ # @return [Object] Returns the model itself
332
+ def self.build_from_hash(attributes)
333
+ new.build_from_hash(attributes)
334
+ end
335
+
310
336
  # Builds the object from hash
311
337
  # @param [Hash] attributes Model attributes in the form of hash
312
338
  # @return [Object] Returns the model itself
313
339
  def build_from_hash(attributes)
314
340
  return nil unless attributes.is_a?(Hash)
315
- self.class.swagger_types.each_pair do |key, type|
316
- if type =~ /\AArray<(.*)>/i
341
+ attributes = attributes.transform_keys(&:to_sym)
342
+ self.class.openapi_types.each_pair do |key, type|
343
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
344
+ self.send("#{key}=", nil)
345
+ elsif type =~ /\AArray<(.*)>/i
317
346
  # check to ensure the input is an array given that the attribute
318
347
  # is documented as an array but the input is not
319
348
  if attributes[self.class.attribute_map[key]].is_a?(Array)
@@ -321,7 +350,7 @@ module DocRaptor
321
350
  end
322
351
  elsif !attributes[self.class.attribute_map[key]].nil?
323
352
  self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
324
- end # or else data not found in attributes(hash), not an issue as the data can be optional
353
+ end
325
354
  end
326
355
 
327
356
  self
@@ -333,8 +362,8 @@ module DocRaptor
333
362
  # @return [Object] Deserialized data
334
363
  def _deserialize(type, value)
335
364
  case type.to_sym
336
- when :DateTime
337
- DateTime.parse(value)
365
+ when :Time
366
+ Time.parse(value)
338
367
  when :Date
339
368
  Date.parse(value)
340
369
  when :String
@@ -343,7 +372,7 @@ module DocRaptor
343
372
  value.to_i
344
373
  when :Float
345
374
  value.to_f
346
- when :BOOLEAN
375
+ when :Boolean
347
376
  if value.to_s =~ /\A(true|t|yes|y|1)\z/i
348
377
  true
349
378
  else
@@ -364,8 +393,9 @@ module DocRaptor
364
393
  end
365
394
  end
366
395
  else # model
367
- temp_model = DocRaptor.const_get(type).new
368
- temp_model.build_from_hash(value)
396
+ # models (e.g. Pet) or oneOf
397
+ klass = DocRaptor.const_get(type)
398
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
369
399
  end
370
400
  end
371
401
 
@@ -387,7 +417,11 @@ module DocRaptor
387
417
  hash = {}
388
418
  self.class.attribute_map.each_pair do |attr, param|
389
419
  value = self.send(attr)
390
- next if value.nil?
420
+ if value.nil?
421
+ is_nullable = self.class.openapi_nullable.include?(attr)
422
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
423
+ end
424
+
391
425
  hash[param] = _to_hash(value)
392
426
  end
393
427
  hash
@@ -412,4 +446,5 @@ module DocRaptor
412
446
  end
413
447
 
414
448
  end
449
+
415
450
  end
@@ -3,14 +3,15 @@
3
3
 
4
4
  #A native client library for the DocRaptor HTML to PDF/XLS service.
5
5
 
6
- OpenAPI spec version: 1.4.0
6
+ The version of the OpenAPI document: 2.0.0
7
7
 
8
- Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.4.19
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.1.0-SNAPSHOT
10
10
 
11
11
  =end
12
12
 
13
13
  require 'date'
14
+ require 'time'
14
15
 
15
16
  module DocRaptor
16
17
  class DocStatus
@@ -44,8 +45,13 @@ module DocRaptor
44
45
  }
45
46
  end
46
47
 
48
+ # Returns all the JSON keys this model knows about
49
+ def self.acceptable_attributes
50
+ attribute_map.values
51
+ end
52
+
47
53
  # Attribute type mapping.
48
- def self.swagger_types
54
+ def self.openapi_types
49
55
  {
50
56
  :'status' => :'String',
51
57
  :'download_url' => :'String',
@@ -56,35 +62,48 @@ module DocRaptor
56
62
  }
57
63
  end
58
64
 
65
+ # List of attributes with nullable: true
66
+ def self.openapi_nullable
67
+ Set.new([
68
+ ])
69
+ end
70
+
59
71
  # Initializes the object
60
72
  # @param [Hash] attributes Model attributes in the form of hash
61
73
  def initialize(attributes = {})
62
- return unless attributes.is_a?(Hash)
74
+ if (!attributes.is_a?(Hash))
75
+ fail ArgumentError, "The input argument (attributes) must be a hash in `DocRaptor::DocStatus` initialize method"
76
+ end
63
77
 
64
- # convert string to symbol for hash key
65
- attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
78
+ # check to see if the attribute exists and convert string to symbol for hash key
79
+ attributes = attributes.each_with_object({}) { |(k, v), h|
80
+ if (!self.class.attribute_map.key?(k.to_sym))
81
+ fail ArgumentError, "`#{k}` is not a valid attribute in `DocRaptor::DocStatus`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
82
+ end
83
+ h[k.to_sym] = v
84
+ }
66
85
 
67
- if attributes.has_key?(:'status')
86
+ if attributes.key?(:'status')
68
87
  self.status = attributes[:'status']
69
88
  end
70
89
 
71
- if attributes.has_key?(:'download_url')
90
+ if attributes.key?(:'download_url')
72
91
  self.download_url = attributes[:'download_url']
73
92
  end
74
93
 
75
- if attributes.has_key?(:'download_id')
94
+ if attributes.key?(:'download_id')
76
95
  self.download_id = attributes[:'download_id']
77
96
  end
78
97
 
79
- if attributes.has_key?(:'message')
98
+ if attributes.key?(:'message')
80
99
  self.message = attributes[:'message']
81
100
  end
82
101
 
83
- if attributes.has_key?(:'number_of_pages')
102
+ if attributes.key?(:'number_of_pages')
84
103
  self.number_of_pages = attributes[:'number_of_pages']
85
104
  end
86
105
 
87
- if attributes.has_key?(:'validation_errors')
106
+ if attributes.key?(:'validation_errors')
88
107
  self.validation_errors = attributes[:'validation_errors']
89
108
  end
90
109
  end
@@ -122,18 +141,28 @@ module DocRaptor
122
141
  end
123
142
 
124
143
  # Calculates hash code according to all attributes.
125
- # @return [Fixnum] Hash code
144
+ # @return [Integer] Hash code
126
145
  def hash
127
146
  [status, download_url, download_id, message, number_of_pages, validation_errors].hash
128
147
  end
129
148
 
149
+ # Builds the object from hash
150
+ # @param [Hash] attributes Model attributes in the form of hash
151
+ # @return [Object] Returns the model itself
152
+ def self.build_from_hash(attributes)
153
+ new.build_from_hash(attributes)
154
+ end
155
+
130
156
  # Builds the object from hash
131
157
  # @param [Hash] attributes Model attributes in the form of hash
132
158
  # @return [Object] Returns the model itself
133
159
  def build_from_hash(attributes)
134
160
  return nil unless attributes.is_a?(Hash)
135
- self.class.swagger_types.each_pair do |key, type|
136
- if type =~ /\AArray<(.*)>/i
161
+ attributes = attributes.transform_keys(&:to_sym)
162
+ self.class.openapi_types.each_pair do |key, type|
163
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
164
+ self.send("#{key}=", nil)
165
+ elsif type =~ /\AArray<(.*)>/i
137
166
  # check to ensure the input is an array given that the attribute
138
167
  # is documented as an array but the input is not
139
168
  if attributes[self.class.attribute_map[key]].is_a?(Array)
@@ -141,7 +170,7 @@ module DocRaptor
141
170
  end
142
171
  elsif !attributes[self.class.attribute_map[key]].nil?
143
172
  self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
144
- end # or else data not found in attributes(hash), not an issue as the data can be optional
173
+ end
145
174
  end
146
175
 
147
176
  self
@@ -153,8 +182,8 @@ module DocRaptor
153
182
  # @return [Object] Deserialized data
154
183
  def _deserialize(type, value)
155
184
  case type.to_sym
156
- when :DateTime
157
- DateTime.parse(value)
185
+ when :Time
186
+ Time.parse(value)
158
187
  when :Date
159
188
  Date.parse(value)
160
189
  when :String
@@ -163,7 +192,7 @@ module DocRaptor
163
192
  value.to_i
164
193
  when :Float
165
194
  value.to_f
166
- when :BOOLEAN
195
+ when :Boolean
167
196
  if value.to_s =~ /\A(true|t|yes|y|1)\z/i
168
197
  true
169
198
  else
@@ -184,8 +213,9 @@ module DocRaptor
184
213
  end
185
214
  end
186
215
  else # model
187
- temp_model = DocRaptor.const_get(type).new
188
- temp_model.build_from_hash(value)
216
+ # models (e.g. Pet) or oneOf
217
+ klass = DocRaptor.const_get(type)
218
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
189
219
  end
190
220
  end
191
221
 
@@ -207,7 +237,11 @@ module DocRaptor
207
237
  hash = {}
208
238
  self.class.attribute_map.each_pair do |attr, param|
209
239
  value = self.send(attr)
210
- next if value.nil?
240
+ if value.nil?
241
+ is_nullable = self.class.openapi_nullable.include?(attr)
242
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
243
+ end
244
+
211
245
  hash[param] = _to_hash(value)
212
246
  end
213
247
  hash
@@ -232,4 +266,5 @@ module DocRaptor
232
266
  end
233
267
 
234
268
  end
269
+
235
270
  end