class Swagger::SwaggerObject

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

Constants

CUSTOM_PROPERTY_PREFIX

Attributes

parent[RW]

Public Class Methods

field(name, type, opts = {}) click to toggle source

@api private @!macro [attach] field

@!attribute [rw] $1
  Swagger field $1. $3
  @return [$2]

Defines a Swagger field on a class.

# File lib/swagger/swagger_object.rb, line 33
def self.field(name, type, opts = {})
  property name, opts
  coerce_key name, type
end
new(hash) click to toggle source

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

Calls superclass method
# File lib/swagger/swagger_object.rb, line 22
def initialize(hash)
  super
  attach_to_children
end
property?(name) click to toggle source

Swagger allows any properties starting with `x-`

Calls superclass method
# File lib/swagger/swagger_object.rb, line 12
def self.property?(name)
  super(name) || name.to_s =~ CUSTOM_PROPERTY_PREFIX
end
required_field(name, type, opts = {}) click to toggle source

@api private @!macro [attach] required_field

@!attribute [rw] $1
  **Required** Swagger field $1. $3
  @return [$2]

Defines a required Swagger field on a class.

# File lib/swagger/swagger_object.rb, line 44
def self.required_field(name, type, opts = {})
  opts[:required] = true
  field(name, type, opts)
end