Class: Swagger::Template

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-swagger/template.rb

Class Method Summary collapse

Class Method Details

.generateObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/ruby-swagger/template.rb', line 5

def self.generate
  swagger_doc = Swagger::Data::Document.new

  if defined?(Rails)
    swagger_doc.info.title = Rails.application.class.name.split('::').first.underscore
    swagger_doc.info.description = Rails.application.class.name.split('::').first.underscore
  end

  swagger_doc.host = 'localhost:80'
  swagger_doc.basePath = '/api/v1'

  swagger_doc.schemes = %w(https http)
  swagger_doc.produces = ['application/json']
  swagger_doc.consumes = ['application/json']

  swagger_doc.info.contact = Swagger::Data::Contact.new
  swagger_doc.info.license = Swagger::Data::License.new
  swagger_doc.info.termsOfService = 'https://localhost/tos.html'

  swagger_doc
end