@@ -81,13 +81,7 @@ def schema_class
81
81
82
82
# These are fields that the OpenAPI 2 spec considers mandatory to be
83
83
# included in the document's top level.
84
- REQUIRED_FIELDS = [
85
- :consumes ,
86
- :definitions ,
87
- :paths ,
88
- :produces ,
89
- :swagger ,
90
- ] . map ( &:to_s ) . freeze
84
+ REQUIRED_FIELDS = [ :consumes , :definitions , :paths , :produces , :swagger , ] . map ( &:to_s ) . freeze
91
85
92
86
def find_best_fit_response ( link_data )
93
87
if response_data = link_data [ "responses" ] [ "200" ] || response_data = link_data [ "responses" ] [ 200 ]
@@ -97,8 +91,7 @@ def find_best_fit_response(link_data)
97
91
else
98
92
# Sort responses so that we can try to prefer any 3-digit status code.
99
93
# If there are none, we'll just take anything from the list.
100
- ordered_responses = link_data [ "responses" ] .
101
- select { |k , v | k . to_s =~ /[0-9]{3}/ }
94
+ ordered_responses = link_data [ "responses" ] . select { |k , v | k . to_s =~ /[0-9]{3}/ }
102
95
if first = ordered_responses . first
103
96
[ first [ 0 ] . to_i , first [ 1 ] ]
104
97
else
@@ -117,9 +110,7 @@ def parse_definitions!(data)
117
110
# that all references to it will still have correct paths (i.e. we can
118
111
# still find a resource at '#/definitions/resource' instead of
119
112
# '#/resource').
120
- schema = JsonSchema . parse! ( {
121
- "definitions" => data [ 'definitions' ] ,
122
- } )
113
+ schema = JsonSchema . parse! ( { "definitions" => data [ 'definitions' ] , } )
123
114
schema . expand_references!
124
115
schema . uri = DEFINITIONS_PSEUDO_URI
125
116
@@ -182,8 +173,7 @@ def parse_routes!(data, schema, store)
182
173
183
174
# A link need not necessarily specify a target schema.
184
175
if response_data [ "schema" ]
185
- target_schemas_data [ "properties" ] [ href ] [ "properties" ] [ method ] =
186
- response_data [ "schema" ]
176
+ target_schemas_data [ "properties" ] [ href ] [ "properties" ] [ method ] = response_data [ "schema" ]
187
177
end
188
178
end
189
179
@@ -199,10 +189,8 @@ def parse_routes!(data, schema, store)
199
189
# #parse_definitions!, but what we're doing here is prefixing references
200
190
# with a specialized internal URI so that they can reference definitions
201
191
# from another document in the store.
202
- schemas =
203
- rewrite_references_and_parse ( schemas_data , store )
204
- target_schemas =
205
- rewrite_references_and_parse ( target_schemas_data , store )
192
+ schemas = rewrite_references_and_parse ( schemas_data , store )
193
+ target_schemas = rewrite_references_and_parse ( target_schemas_data , store )
206
194
207
195
# As noted above, now that we've parsed our aggregate response schema, go
208
196
# back through each link and them their response schema.
@@ -218,8 +206,7 @@ def parse_routes!(data, schema, store)
218
206
end
219
207
220
208
# response
221
- link . target_schema =
222
- target_schemas . properties [ link . href ] . properties [ method ]
209
+ link . target_schema = target_schemas . properties [ link . href ] . properties [ method ]
223
210
end
224
211
end
225
212
0 commit comments