docraptor 1.1.0 → 1.2.0beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/.gitignore +38 -2
- data/.rspec +2 -0
- data/.swagger-codegen-ignore +32 -0
- data/.swagger-codegen/VERSION +1 -0
- data/.swagger-revision +1 -1
- data/CHANGELOG.md +3 -0
- data/Gemfile +5 -1
- data/LICENSE +4 -10
- data/README.md +5 -4
- data/Rakefile +9 -0
- data/docraptor.gemspec +34 -16
- data/docraptor.yaml +5 -1
- data/lib/docraptor.rb +12 -0
- data/lib/docraptor/api/doc_api.rb +40 -56
- data/lib/docraptor/api_client.rb +102 -35
- data/lib/docraptor/api_error.rb +19 -5
- data/lib/docraptor/configuration.rb +40 -1
- data/lib/docraptor/models/async_doc.rb +61 -22
- data/lib/docraptor/models/async_doc_status.rb +66 -32
- data/lib/docraptor/models/doc.rb +122 -54
- data/lib/docraptor/models/prince_options.rb +116 -81
- data/lib/docraptor/version.rb +13 -1
- data/script/fix_gemspec.rb +31 -0
- data/script/post_generate_language +3 -0
- data/spec/api/doc_api_spec.rb +83 -0
- data/spec/api_client_spec.rb +226 -0
- data/spec/configuration_spec.rb +42 -0
- data/spec/models/async_doc_spec.rb +42 -0
- data/spec/models/async_doc_status_spec.rb +72 -0
- data/spec/models/doc_spec.rb +128 -0
- data/spec/models/prince_options_spec.rb +214 -0
- data/spec/spec_helper.rb +111 -0
- data/swagger-config.json +11 -3
- metadata +135 -112
@@ -1,6 +1,19 @@
|
|
1
|
+
=begin
|
2
|
+
#DocRaptor v1
|
3
|
+
|
4
|
+
#A native client library for the DocRaptor HTML to PDF/XLS service.
|
5
|
+
|
6
|
+
OpenAPI spec version: 1.0.0
|
7
|
+
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 2.2.3
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
1
13
|
require 'date'
|
2
14
|
|
3
15
|
module DocRaptor
|
16
|
+
|
4
17
|
class AsyncDocStatus
|
5
18
|
# The present status of the document. Can be queued, working, completed, and failed.
|
6
19
|
attr_accessor :status
|
@@ -20,22 +33,16 @@ module DocRaptor
|
|
20
33
|
# Error information.
|
21
34
|
attr_accessor :validation_errors
|
22
35
|
|
36
|
+
|
23
37
|
# Attribute mapping from ruby-style variable name to JSON key.
|
24
38
|
def self.attribute_map
|
25
39
|
{
|
26
|
-
|
27
40
|
:'status' => :'status',
|
28
|
-
|
29
41
|
:'download_url' => :'download_url',
|
30
|
-
|
31
42
|
:'download_id' => :'download_id',
|
32
|
-
|
33
43
|
:'message' => :'message',
|
34
|
-
|
35
44
|
:'number_of_pages' => :'number_of_pages',
|
36
|
-
|
37
45
|
:'validation_errors' => :'validation_errors'
|
38
|
-
|
39
46
|
}
|
40
47
|
end
|
41
48
|
|
@@ -48,44 +55,58 @@ module DocRaptor
|
|
48
55
|
:'message' => :'String',
|
49
56
|
:'number_of_pages' => :'Integer',
|
50
57
|
:'validation_errors' => :'String'
|
51
|
-
|
52
58
|
}
|
53
59
|
end
|
54
60
|
|
61
|
+
# Initializes the object
|
62
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
55
63
|
def initialize(attributes = {})
|
56
64
|
return unless attributes.is_a?(Hash)
|
57
65
|
|
58
66
|
# convert string to symbol for hash key
|
59
|
-
attributes = attributes.
|
67
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
60
68
|
|
61
|
-
|
62
|
-
if attributes[:'status']
|
69
|
+
if attributes.has_key?(:'status')
|
63
70
|
self.status = attributes[:'status']
|
64
71
|
end
|
65
72
|
|
66
|
-
if attributes
|
73
|
+
if attributes.has_key?(:'download_url')
|
67
74
|
self.download_url = attributes[:'download_url']
|
68
75
|
end
|
69
76
|
|
70
|
-
if attributes
|
77
|
+
if attributes.has_key?(:'download_id')
|
71
78
|
self.download_id = attributes[:'download_id']
|
72
79
|
end
|
73
80
|
|
74
|
-
if attributes
|
81
|
+
if attributes.has_key?(:'message')
|
75
82
|
self.message = attributes[:'message']
|
76
83
|
end
|
77
84
|
|
78
|
-
if attributes
|
85
|
+
if attributes.has_key?(:'number_of_pages')
|
79
86
|
self.number_of_pages = attributes[:'number_of_pages']
|
80
87
|
end
|
81
88
|
|
82
|
-
if attributes
|
89
|
+
if attributes.has_key?(:'validation_errors')
|
83
90
|
self.validation_errors = attributes[:'validation_errors']
|
84
91
|
end
|
85
92
|
|
86
93
|
end
|
87
94
|
|
88
|
-
#
|
95
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
96
|
+
# @return Array for valid properies with the reasons
|
97
|
+
def list_invalid_properties
|
98
|
+
invalid_properties = Array.new
|
99
|
+
return invalid_properties
|
100
|
+
end
|
101
|
+
|
102
|
+
# Check to see if the all the properties in the model are valid
|
103
|
+
# @return true if the model is valid
|
104
|
+
def valid?
|
105
|
+
return true
|
106
|
+
end
|
107
|
+
|
108
|
+
# Checks equality by comparing each attribute.
|
109
|
+
# @param [Object] Object to be compared
|
89
110
|
def ==(o)
|
90
111
|
return true if self.equal?(o)
|
91
112
|
self.class == o.class &&
|
@@ -98,35 +119,41 @@ module DocRaptor
|
|
98
119
|
end
|
99
120
|
|
100
121
|
# @see the `==` method
|
122
|
+
# @param [Object] Object to be compared
|
101
123
|
def eql?(o)
|
102
124
|
self == o
|
103
125
|
end
|
104
126
|
|
105
|
-
#
|
127
|
+
# Calculates hash code according to all attributes.
|
128
|
+
# @return [Fixnum] Hash code
|
106
129
|
def hash
|
107
130
|
[status, download_url, download_id, message, number_of_pages, validation_errors].hash
|
108
131
|
end
|
109
132
|
|
110
|
-
#
|
133
|
+
# Builds the object from hash
|
134
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
135
|
+
# @return [Object] Returns the model itself
|
111
136
|
def build_from_hash(attributes)
|
112
137
|
return nil unless attributes.is_a?(Hash)
|
113
138
|
self.class.swagger_types.each_pair do |key, type|
|
114
|
-
if type =~
|
139
|
+
if type =~ /\AArray<(.*)>/i
|
140
|
+
# check to ensure the input is an array given that the the attribute
|
141
|
+
# is documented as an array but the input is not
|
115
142
|
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
116
143
|
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
117
|
-
else
|
118
|
-
#TODO show warning in debug mode
|
119
144
|
end
|
120
145
|
elsif !attributes[self.class.attribute_map[key]].nil?
|
121
146
|
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
122
|
-
else
|
123
|
-
# data not found in attributes(hash), not an issue as the data can be optional
|
124
|
-
end
|
147
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
125
148
|
end
|
126
149
|
|
127
150
|
self
|
128
151
|
end
|
129
152
|
|
153
|
+
# Deserializes the data based on type
|
154
|
+
# @param string type Data type
|
155
|
+
# @param string value Value to be deserialized
|
156
|
+
# @return [Object] Deserialized data
|
130
157
|
def _deserialize(type, value)
|
131
158
|
case type.to_sym
|
132
159
|
when :DateTime
|
@@ -140,7 +167,7 @@ module DocRaptor
|
|
140
167
|
when :Float
|
141
168
|
value.to_f
|
142
169
|
when :BOOLEAN
|
143
|
-
if value.to_s =~
|
170
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
144
171
|
true
|
145
172
|
else
|
146
173
|
false
|
@@ -151,7 +178,7 @@ module DocRaptor
|
|
151
178
|
when /\AArray<(?<inner_type>.+)>\z/
|
152
179
|
inner_type = Regexp.last_match[:inner_type]
|
153
180
|
value.map { |v| _deserialize(inner_type, v) }
|
154
|
-
when /\AHash<(?<k_type
|
181
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
155
182
|
k_type = Regexp.last_match[:k_type]
|
156
183
|
v_type = Regexp.last_match[:v_type]
|
157
184
|
{}.tap do |hash|
|
@@ -160,21 +187,25 @@ module DocRaptor
|
|
160
187
|
end
|
161
188
|
end
|
162
189
|
else # model
|
163
|
-
|
164
|
-
|
190
|
+
temp_model = DocRaptor.const_get(type).new
|
191
|
+
temp_model.build_from_hash(value)
|
165
192
|
end
|
166
193
|
end
|
167
194
|
|
195
|
+
# Returns the string representation of the object
|
196
|
+
# @return [String] String presentation of the object
|
168
197
|
def to_s
|
169
198
|
to_hash.to_s
|
170
199
|
end
|
171
200
|
|
172
|
-
# to_body is an alias to
|
201
|
+
# to_body is an alias to to_hash (backward compatibility)
|
202
|
+
# @return [Hash] Returns the object in the form of hash
|
173
203
|
def to_body
|
174
204
|
to_hash
|
175
205
|
end
|
176
206
|
|
177
|
-
#
|
207
|
+
# Returns the object in the form of hash
|
208
|
+
# @return [Hash] Returns the object in the form of hash
|
178
209
|
def to_hash
|
179
210
|
hash = {}
|
180
211
|
self.class.attribute_map.each_pair do |attr, param|
|
@@ -185,8 +216,10 @@ module DocRaptor
|
|
185
216
|
hash
|
186
217
|
end
|
187
218
|
|
188
|
-
#
|
219
|
+
# Outputs non-array value in the form of hash
|
189
220
|
# For object, use to_hash. Otherwise, just return the value
|
221
|
+
# @param [Object] value Any valid value
|
222
|
+
# @return [Hash] Returns the value in the form of hash
|
190
223
|
def _to_hash(value)
|
191
224
|
if value.is_a?(Array)
|
192
225
|
value.compact.map{ |v| _to_hash(v) }
|
@@ -202,4 +235,5 @@ module DocRaptor
|
|
202
235
|
end
|
203
236
|
|
204
237
|
end
|
238
|
+
|
205
239
|
end
|
data/lib/docraptor/models/doc.rb
CHANGED
@@ -1,6 +1,19 @@
|
|
1
|
+
=begin
|
2
|
+
#DocRaptor v1
|
3
|
+
|
4
|
+
#A native client library for the DocRaptor HTML to PDF/XLS service.
|
5
|
+
|
6
|
+
OpenAPI spec version: 1.0.0
|
7
|
+
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 2.2.3
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
1
13
|
require 'date'
|
2
14
|
|
3
15
|
module DocRaptor
|
16
|
+
|
4
17
|
class Doc
|
5
18
|
# Specify a specific verison of the DocRaptor Pipeline to use.
|
6
19
|
attr_accessor :pipeline
|
@@ -43,38 +56,45 @@ module DocRaptor
|
|
43
56
|
|
44
57
|
attr_accessor :prince_options
|
45
58
|
|
59
|
+
class EnumAttributeValidator
|
60
|
+
attr_reader :datatype
|
61
|
+
attr_reader :allowable_values
|
62
|
+
|
63
|
+
def initialize(datatype, allowable_values)
|
64
|
+
@allowable_values = allowable_values.map do |value|
|
65
|
+
case datatype.to_s
|
66
|
+
when /Integer/i
|
67
|
+
value.to_i
|
68
|
+
when /Float/i
|
69
|
+
value.to_f
|
70
|
+
else
|
71
|
+
value
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def valid?(value)
|
77
|
+
!value || allowable_values.include?(value)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
46
81
|
# Attribute mapping from ruby-style variable name to JSON key.
|
47
82
|
def self.attribute_map
|
48
83
|
{
|
49
|
-
|
50
84
|
:'pipeline' => :'pipeline',
|
51
|
-
|
52
85
|
:'name' => :'name',
|
53
|
-
|
54
86
|
:'document_type' => :'document_type',
|
55
|
-
|
56
87
|
:'document_content' => :'document_content',
|
57
|
-
|
58
88
|
:'document_url' => :'document_url',
|
59
|
-
|
60
89
|
:'test' => :'test',
|
61
|
-
|
62
90
|
:'strict' => :'strict',
|
63
|
-
|
64
91
|
:'ignore_resource_errors' => :'ignore_resource_errors',
|
65
|
-
|
66
92
|
:'tag' => :'tag',
|
67
|
-
|
68
93
|
:'help' => :'help',
|
69
|
-
|
70
94
|
:'javascript' => :'javascript',
|
71
|
-
|
72
95
|
:'referrer' => :'referrer',
|
73
|
-
|
74
96
|
:'callback_url' => :'callback_url',
|
75
|
-
|
76
97
|
:'prince_options' => :'prince_options'
|
77
|
-
|
78
98
|
}
|
79
99
|
end
|
80
100
|
|
@@ -95,104 +115,139 @@ module DocRaptor
|
|
95
115
|
:'referrer' => :'String',
|
96
116
|
:'callback_url' => :'String',
|
97
117
|
:'prince_options' => :'PrinceOptions'
|
98
|
-
|
99
118
|
}
|
100
119
|
end
|
101
120
|
|
121
|
+
# Initializes the object
|
122
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
102
123
|
def initialize(attributes = {})
|
103
124
|
return unless attributes.is_a?(Hash)
|
104
125
|
|
105
126
|
# convert string to symbol for hash key
|
106
|
-
attributes = attributes.
|
107
|
-
|
127
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
108
128
|
|
109
|
-
if attributes
|
129
|
+
if attributes.has_key?(:'pipeline')
|
110
130
|
self.pipeline = attributes[:'pipeline']
|
111
131
|
end
|
112
132
|
|
113
|
-
if attributes
|
133
|
+
if attributes.has_key?(:'name')
|
114
134
|
self.name = attributes[:'name']
|
115
135
|
end
|
116
136
|
|
117
|
-
if attributes
|
137
|
+
if attributes.has_key?(:'document_type')
|
118
138
|
self.document_type = attributes[:'document_type']
|
119
139
|
end
|
120
140
|
|
121
|
-
if attributes
|
141
|
+
if attributes.has_key?(:'document_content')
|
122
142
|
self.document_content = attributes[:'document_content']
|
123
143
|
end
|
124
144
|
|
125
|
-
if attributes
|
145
|
+
if attributes.has_key?(:'document_url')
|
126
146
|
self.document_url = attributes[:'document_url']
|
127
147
|
end
|
128
148
|
|
129
|
-
if attributes
|
149
|
+
if attributes.has_key?(:'test')
|
130
150
|
self.test = attributes[:'test']
|
131
151
|
else
|
132
152
|
self.test = true
|
133
153
|
end
|
134
154
|
|
135
|
-
if attributes
|
155
|
+
if attributes.has_key?(:'strict')
|
136
156
|
self.strict = attributes[:'strict']
|
137
157
|
else
|
138
158
|
self.strict = "none"
|
139
159
|
end
|
140
160
|
|
141
|
-
if attributes
|
161
|
+
if attributes.has_key?(:'ignore_resource_errors')
|
142
162
|
self.ignore_resource_errors = attributes[:'ignore_resource_errors']
|
143
163
|
else
|
144
164
|
self.ignore_resource_errors = true
|
145
165
|
end
|
146
166
|
|
147
|
-
if attributes
|
167
|
+
if attributes.has_key?(:'tag')
|
148
168
|
self.tag = attributes[:'tag']
|
149
169
|
end
|
150
170
|
|
151
|
-
if attributes
|
171
|
+
if attributes.has_key?(:'help')
|
152
172
|
self.help = attributes[:'help']
|
153
173
|
else
|
154
174
|
self.help = false
|
155
175
|
end
|
156
176
|
|
157
|
-
if attributes
|
177
|
+
if attributes.has_key?(:'javascript')
|
158
178
|
self.javascript = attributes[:'javascript']
|
159
179
|
else
|
160
180
|
self.javascript = false
|
161
181
|
end
|
162
182
|
|
163
|
-
if attributes
|
183
|
+
if attributes.has_key?(:'referrer')
|
164
184
|
self.referrer = attributes[:'referrer']
|
165
185
|
end
|
166
186
|
|
167
|
-
if attributes
|
187
|
+
if attributes.has_key?(:'callback_url')
|
168
188
|
self.callback_url = attributes[:'callback_url']
|
169
189
|
end
|
170
190
|
|
171
|
-
if attributes
|
191
|
+
if attributes.has_key?(:'prince_options')
|
172
192
|
self.prince_options = attributes[:'prince_options']
|
173
193
|
end
|
174
194
|
|
175
195
|
end
|
176
196
|
|
197
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
198
|
+
# @return Array for valid properies with the reasons
|
199
|
+
def list_invalid_properties
|
200
|
+
invalid_properties = Array.new
|
201
|
+
if @name.nil?
|
202
|
+
invalid_properties.push("invalid value for 'name', name cannot be nil.")
|
203
|
+
end
|
204
|
+
|
205
|
+
if @document_type.nil?
|
206
|
+
invalid_properties.push("invalid value for 'document_type', document_type cannot be nil.")
|
207
|
+
end
|
208
|
+
|
209
|
+
if @document_content.nil?
|
210
|
+
invalid_properties.push("invalid value for 'document_content', document_content cannot be nil.")
|
211
|
+
end
|
212
|
+
|
213
|
+
return invalid_properties
|
214
|
+
end
|
215
|
+
|
216
|
+
# Check to see if the all the properties in the model are valid
|
217
|
+
# @return true if the model is valid
|
218
|
+
def valid?
|
219
|
+
return false if @name.nil?
|
220
|
+
return false if @document_type.nil?
|
221
|
+
document_type_validator = EnumAttributeValidator.new('String', ["pdf", "xls", "xlsx"])
|
222
|
+
return false unless document_type_validator.valid?(@document_type)
|
223
|
+
return false if @document_content.nil?
|
224
|
+
strict_validator = EnumAttributeValidator.new('String', ["none"])
|
225
|
+
return false unless strict_validator.valid?(@strict)
|
226
|
+
return true
|
227
|
+
end
|
228
|
+
|
177
229
|
# Custom attribute writer method checking allowed values (enum).
|
230
|
+
# @param [Object] document_type Object to be assigned
|
178
231
|
def document_type=(document_type)
|
179
|
-
|
180
|
-
|
181
|
-
fail "invalid value for 'document_type', must be one of #{
|
232
|
+
validator = EnumAttributeValidator.new('String', ["pdf", "xls", "xlsx"])
|
233
|
+
unless validator.valid?(document_type)
|
234
|
+
fail ArgumentError, "invalid value for 'document_type', must be one of #{validator.allowable_values}."
|
182
235
|
end
|
183
236
|
@document_type = document_type
|
184
237
|
end
|
185
238
|
|
186
239
|
# Custom attribute writer method checking allowed values (enum).
|
240
|
+
# @param [Object] strict Object to be assigned
|
187
241
|
def strict=(strict)
|
188
|
-
|
189
|
-
|
190
|
-
fail "invalid value for 'strict', must be one of #{
|
242
|
+
validator = EnumAttributeValidator.new('String', ["none"])
|
243
|
+
unless validator.valid?(strict)
|
244
|
+
fail ArgumentError, "invalid value for 'strict', must be one of #{validator.allowable_values}."
|
191
245
|
end
|
192
246
|
@strict = strict
|
193
247
|
end
|
194
248
|
|
195
|
-
#
|
249
|
+
# Checks equality by comparing each attribute.
|
250
|
+
# @param [Object] Object to be compared
|
196
251
|
def ==(o)
|
197
252
|
return true if self.equal?(o)
|
198
253
|
self.class == o.class &&
|
@@ -213,35 +268,41 @@ module DocRaptor
|
|
213
268
|
end
|
214
269
|
|
215
270
|
# @see the `==` method
|
271
|
+
# @param [Object] Object to be compared
|
216
272
|
def eql?(o)
|
217
273
|
self == o
|
218
274
|
end
|
219
275
|
|
220
|
-
#
|
276
|
+
# Calculates hash code according to all attributes.
|
277
|
+
# @return [Fixnum] Hash code
|
221
278
|
def hash
|
222
279
|
[pipeline, name, document_type, document_content, document_url, test, strict, ignore_resource_errors, tag, help, javascript, referrer, callback_url, prince_options].hash
|
223
280
|
end
|
224
281
|
|
225
|
-
#
|
282
|
+
# Builds the object from hash
|
283
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
284
|
+
# @return [Object] Returns the model itself
|
226
285
|
def build_from_hash(attributes)
|
227
286
|
return nil unless attributes.is_a?(Hash)
|
228
287
|
self.class.swagger_types.each_pair do |key, type|
|
229
|
-
if type =~
|
288
|
+
if type =~ /\AArray<(.*)>/i
|
289
|
+
# check to ensure the input is an array given that the the attribute
|
290
|
+
# is documented as an array but the input is not
|
230
291
|
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
231
292
|
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
232
|
-
else
|
233
|
-
#TODO show warning in debug mode
|
234
293
|
end
|
235
294
|
elsif !attributes[self.class.attribute_map[key]].nil?
|
236
295
|
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
237
|
-
else
|
238
|
-
# data not found in attributes(hash), not an issue as the data can be optional
|
239
|
-
end
|
296
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
240
297
|
end
|
241
298
|
|
242
299
|
self
|
243
300
|
end
|
244
301
|
|
302
|
+
# Deserializes the data based on type
|
303
|
+
# @param string type Data type
|
304
|
+
# @param string value Value to be deserialized
|
305
|
+
# @return [Object] Deserialized data
|
245
306
|
def _deserialize(type, value)
|
246
307
|
case type.to_sym
|
247
308
|
when :DateTime
|
@@ -255,7 +316,7 @@ module DocRaptor
|
|
255
316
|
when :Float
|
256
317
|
value.to_f
|
257
318
|
when :BOOLEAN
|
258
|
-
if value.to_s =~
|
319
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
259
320
|
true
|
260
321
|
else
|
261
322
|
false
|
@@ -266,7 +327,7 @@ module DocRaptor
|
|
266
327
|
when /\AArray<(?<inner_type>.+)>\z/
|
267
328
|
inner_type = Regexp.last_match[:inner_type]
|
268
329
|
value.map { |v| _deserialize(inner_type, v) }
|
269
|
-
when /\AHash<(?<k_type
|
330
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
270
331
|
k_type = Regexp.last_match[:k_type]
|
271
332
|
v_type = Regexp.last_match[:v_type]
|
272
333
|
{}.tap do |hash|
|
@@ -275,21 +336,25 @@ module DocRaptor
|
|
275
336
|
end
|
276
337
|
end
|
277
338
|
else # model
|
278
|
-
|
279
|
-
|
339
|
+
temp_model = DocRaptor.const_get(type).new
|
340
|
+
temp_model.build_from_hash(value)
|
280
341
|
end
|
281
342
|
end
|
282
343
|
|
344
|
+
# Returns the string representation of the object
|
345
|
+
# @return [String] String presentation of the object
|
283
346
|
def to_s
|
284
347
|
to_hash.to_s
|
285
348
|
end
|
286
349
|
|
287
|
-
# to_body is an alias to
|
350
|
+
# to_body is an alias to to_hash (backward compatibility)
|
351
|
+
# @return [Hash] Returns the object in the form of hash
|
288
352
|
def to_body
|
289
353
|
to_hash
|
290
354
|
end
|
291
355
|
|
292
|
-
#
|
356
|
+
# Returns the object in the form of hash
|
357
|
+
# @return [Hash] Returns the object in the form of hash
|
293
358
|
def to_hash
|
294
359
|
hash = {}
|
295
360
|
self.class.attribute_map.each_pair do |attr, param|
|
@@ -300,8 +365,10 @@ module DocRaptor
|
|
300
365
|
hash
|
301
366
|
end
|
302
367
|
|
303
|
-
#
|
368
|
+
# Outputs non-array value in the form of hash
|
304
369
|
# For object, use to_hash. Otherwise, just return the value
|
370
|
+
# @param [Object] value Any valid value
|
371
|
+
# @return [Hash] Returns the value in the form of hash
|
305
372
|
def _to_hash(value)
|
306
373
|
if value.is_a?(Array)
|
307
374
|
value.compact.map{ |v| _to_hash(v) }
|
@@ -317,4 +384,5 @@ module DocRaptor
|
|
317
384
|
end
|
318
385
|
|
319
386
|
end
|
387
|
+
|
320
388
|
end
|