Class: Swagger::Data::Schema

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

Overview

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Object

attr_swagger, #bulk_set, #swagger_attributes, #to_json, #to_swagger, #to_yaml

Instance Attribute Details

#refObject

Returns the value of attribute ref.



17
18
19
# File 'lib/ruby-swagger/data/schema.rb', line 17

def ref
  @ref
end

Class Method Details

.parse(schema) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/ruby-swagger/data/schema.rb', line 19

def self.parse(schema)
  return nil if schema.nil?

  sc = Swagger::Data::Schema.new.bulk_set(schema)
  sc.ref= schema['$ref']
  sc
end

Instance Method Details

#[](attrib) ⇒ Object



57
58
59
# File 'lib/ruby-swagger/data/schema.rb', line 57

def [](attrib)
  self.send("#{attrib}")
end

#[]=(attrib, value) ⇒ Object



53
54
55
# File 'lib/ruby-swagger/data/schema.rb', line 53

def []=(attrib, value)
  self.send("#{attrib}=", value)
end

#as_swaggerObject



61
62
63
64
65
# File 'lib/ruby-swagger/data/schema.rb', line 61

def as_swagger
  res = super
  res['$ref'] = @ref if @ref
  res
end

#externalDocs=(new_doc) ⇒ Object



33
34
35
36
37
38
39
40
41
# File 'lib/ruby-swagger/data/schema.rb', line 33

def externalDocs=(new_doc)
  return nil unless new_doc

  if !new_doc.is_a?(Swagger::Data::ExternalDocumentation)
    new_doc = Swagger::Data::ExternalDocumentation.parse(new_doc)
  end

  @externalDocs = new_doc
end

#xml=(new_xml) ⇒ Object



43
44
45
46
47
48
49
50
51
# File 'lib/ruby-swagger/data/schema.rb', line 43

def xml=(new_xml)
  return nil unless new_xml

  if !new_xml.is_a?(Swagger::Data::XMLObject)
    new_xml = Swagger::Data::XMLObject.parse(new_xml)
  end

  @xml = new_xml
end