Class: APISpec::Field

Inherits:
Node
  • Object
show all
Defined in:
lib/apispec/field.rb

Instance Attribute Summary

Attributes inherited from Node

#name, #parent

Instance Method Summary collapse

Methods inherited from Node

#full_name, #node_path, #root?, #to_html, #to_path, #to_s

Constructor Details

#initialize(name, &block) ⇒ Field

default type is String and field is not optional



3
4
5
6
7
8
# File 'lib/apispec/field.rb', line 3

def initialize(name, &block)
  @optional = false
  @nullable = false
  @type = :string
  super(name, &block)
end

Instance Method Details

#default(value) ⇒ Object



18
19
20
# File 'lib/apispec/field.rb', line 18

def default(value)
  @default = value
end

#desc(value) ⇒ Object



14
15
16
# File 'lib/apispec/field.rb', line 14

def desc(value)
  @desc = value
end

#example(value) ⇒ Object



30
31
32
# File 'lib/apispec/field.rb', line 30

def example(value)
  @example = value
end

#nullable(value) ⇒ Object



26
27
28
# File 'lib/apispec/field.rb', line 26

def nullable(value)
  @nullable = value
end

#optional(value) ⇒ Object



22
23
24
# File 'lib/apispec/field.rb', line 22

def optional(value)
  @optional = value
end

#resolve_references!(root_namespace) ⇒ Object



34
35
36
# File 'lib/apispec/field.rb', line 34

def resolve_references!(root_namespace)
  @type = root_namespace.find_object(@type) if @type.is_a? String
end

#type(value) ⇒ Object



10
11
12
# File 'lib/apispec/field.rb', line 10

def type(value)
  @type = value
end