352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
|
# File 'lib/betterdocs/generator/swagger.rb', line 352
def get_section_data(map, section)
section.each do |action|
name = get_name(action.title)
p = { description: action.description, summary: name }
is_a_list = action.response.data.instance_of?(ApiTools::ResultSet)
slugs = get_request_url_slugs(action.request)
add_path_params(p, slugs[:params])
add_query_params(p, action.params.values, is_a_list)
add_body(map[:components][:schemas], p, action, name)
item = add_response_schema(map[:components][:schemas], action.response)
schema = item
if is_a_list
list = get_list_response_wrapper_schema
list[:properties][:data] = { type: 'array', items: item }
schema = list
end
ok = { schema: schema }
unless action.response.nil?
add_example(ok, 'example', JSON.parse(JSON.pretty_generate(action.response.to_json, quirks_mode: true)))
end
p[:responses] =
{ "200": wrap_content_object(ok, 'OK'),
default: wrap_content_object(get_error_envelope_schema_ref, 'Error') }
wrapped = {}
wrapped = map[slugs[:path]] if map.key?(slugs[:path])
wrapped[slugs[:method]] = p
map[:paths][slugs[:path]] = wrapped
end
add_required_to_definitions(map[:components][:schemas])
map
end
|