Class: Swagger::Api

Inherits:
Object
  • Object
show all
Defined in:
lib/swagger/api.rb

Instance Method Summary collapse

Constructor Details

#initialize(path, opts) ⇒ Api

Returns a new instance of Api.



3
4
5
6
7
8
# File 'lib/swagger/api.rb', line 3

def initialize path, opts
  defaults = { 
    :path => path,
    :operations => []}
  @values = defaults.merge opts
end

Instance Method Details

#as_json(options) ⇒ Object



20
21
22
# File 'lib/swagger/api.rb', line 20

def as_json options
  @values.as_json options
end

#operations(http_methods, opts = {}) ⇒ Object



14
15
16
17
18
# File 'lib/swagger/api.rb', line 14

def operations http_methods, opts = {}
  operations = Array(http_methods).map { |m| Operation.new self, m, opts }
  operations.each { |o| yield(o) }
  @values[:operations].concat operations
end

#pathObject



10
11
12
# File 'lib/swagger/api.rb', line 10

def path
  @values[:path]
end