Class: Swagger::Base

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Base

Returns a new instance of Base


30
31
32
33
# File 'lib/swagger/base.rb', line 30

def initialize(data)
  @spec = data
  JSON::Validator.validate!({ "$ref" => "http://swagger.io/v2/schema.json#" }, @spec)
end

Instance Attribute Details

#specObject (readonly)

Returns the value of attribute spec


22
23
24
# File 'lib/swagger/base.rb', line 22

def spec
  @spec
end

Class Method Details

.from_file(filepath) ⇒ Object


35
36
37
# File 'lib/swagger/base.rb', line 35

def self.from_file(filepath)
  new(YAML.load(open(filepath)))
end

Instance Method Details

#[](key) ⇒ Object


39
40
41
# File 'lib/swagger/base.rb', line 39

def [](key)
  @spec[key]
end