class Openapi::SwaggerRoot

Public Class Methods

build_specification(config, controller_classes) click to toggle source
# File lib/openapi/mongoid/spec_builder.rb, line 5
def self.build_specification(config, controller_classes)
  swagger_root do
    key :swagger,  '2.0'
    key :host,     ENV['HOST'] || 'localhost:3000'
    key :basePath, config[:base_path] || '/api'
    key :consumes, %w(application/json)
    key :produces, %w(application/json text/csv)
    key :schemes,  ['https', 'http']

    info do
      key :title,       config[:title] || 'Default'
      key :description, config[:description] || ''
      key :version,     config[:version] || '1.0'
    end

    controller_classes.each do |c|
      tag do
        key :name, c.spec_collection_name
      end
    end
  end
end