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.



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

def ref
  @ref
end

Class Method Details

.parse(schema) ⇒ Object



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

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



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

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

#[]=(attrib, value) ⇒ Object



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

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

#as_swaggerObject



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

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

#externalDocs=(new_doc) ⇒ Object



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

def externalDocs=(new_doc)
  return nil unless new_doc

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

  @externalDocs = new_doc
end

#xml=(new_xml) ⇒ Object



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

def xml=(new_xml)
  return nil unless new_xml

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

  @xml = new_xml
end