class SwaggerDocsGenerator::MetadataJsons

Parse temporary json files

Public Class Methods

new() click to toggle source
# File lib/swagger_docs_generator/metadata/jsons.rb, line 8
def initialize
  @paths = { paths: {} }
  @tags_array = []
end

Public Instance Methods

construct_swagger_file() click to toggle source
# File lib/swagger_docs_generator/metadata/jsons.rb, line 13
def construct_swagger_file
  hash = {}
  files_tmp.each do |file|
    @paths[:paths].merge!(read_part_json(file, 'paths'))
    @tags_array.push read_part_json(file, 'tags')
  end
  hash.merge(sort_paths).merge(tags: @tags_array)
end

Private Instance Methods

files_tmp() click to toggle source

:reek: UtilityFunction

# File lib/swagger_docs_generator/metadata/jsons.rb, line 25
def files_tmp
  Dir[Rails.root.join(SwaggerDocsGenerator.temporary_folder, '*.json')]
end
read_part_json(file, key) click to toggle source

:reek: UtilityFunction

# File lib/swagger_docs_generator/metadata/jsons.rb, line 30
def read_part_json(file, key)
  JSON.parse(File.read(file))[key]
end
sort_paths() click to toggle source
# File lib/swagger_docs_generator/metadata/jsons.rb, line 34
def sort_paths
  order = Sort.new(@paths)
  case SwaggerDocsGenerator.configure.sort
  when 'path' then order.sort_by_path
  when 'tag' then order.sort_by_tag
  else
    @paths
  end
end