Class: Apigen::Rest::Output

Inherits:
Object
  • Object
show all
Defined in:
lib/apigen/rest/output.rb

Overview

Output is the response type associated with a specific status code for an API endpoint.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Output

Returns a new instance of Output.



13
14
15
16
17
18
# File 'lib/apigen/rest/output.rb', line 13

def initialize(name)
  @name = name
  @status = nil
  @type = nil
  @description = nil
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/apigen/rest/output.rb', line 8

def name
  @name
end

Instance Method Details

#to_sObject



32
33
34
# File 'lib/apigen/rest/output.rb', line 32

def to_s
  "#{@name} #{@status} #{@type}"
end

#type(type = nil, &block) ⇒ Object

Declares the output type.



22
23
24
25
# File 'lib/apigen/rest/output.rb', line 22

def type(type = nil, &block)
  return @type unless type
  @type = Apigen::Model.type type, &block
end

#validate(model_registry) ⇒ Object



27
28
29
30
# File 'lib/apigen/rest/output.rb', line 27

def validate(model_registry)
  validate_properties
  model_registry.check_type @type
end