Class: Swagger::SwaggerObject

Inherits:
Hashie::Dash
  • Object
show all
Includes:
Hashie::Extensions::Coercion, Hashie::Extensions::IndifferentAccess, Attachable
Defined in:
lib/swagger/swagger_object.rb

Overview

A class that represents an Object defined in the Swagger specification. Provides methods for defining fields in the object.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Attachable

#attach_parent, #attach_to_children, #root

Constructor Details

#initialize(hash) ⇒ SwaggerObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initializes a Swagger object, using Hashie::Dash, and attaches to children objects so navigation via parent and root is possible.



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

def initialize(hash)
  super
  attach_to_children
end

Instance Attribute Details

#parentObject

Returns the value of attribute parent.



9
10
11
# File 'lib/swagger/swagger_object.rb', line 9

def parent
  @parent
end

Class Method Details

.field(name, type, opts = {}) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Defines a Swagger field on a class.



26
27
28
29
# File 'lib/swagger/swagger_object.rb', line 26

def self.field(name, type, opts = {})
  property name, opts
  coerce_key name, type
end

.required_field(name, type, opts = {}) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Defines a required Swagger field on a class.



37
38
39
40
# File 'lib/swagger/swagger_object.rb', line 37

def self.required_field(name, type, opts = {})
  opts[:required] = true
  field(name, type, opts)
end