Class: Apigen::Rest::Input

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

Overview

Input is the request body expected by an API endpoint.

Instance Method Summary collapse

Constructor Details

#initializeInput

Returns a new instance of Input.



11
12
13
14
# File 'lib/apigen/rest/input.rb', line 11

def initialize
  @type = nil
  @description = nil
end

Instance Method Details

#to_sObject



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

def to_s
  @type.to_s
end

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

Declares the input type.



18
19
20
21
# File 'lib/apigen/rest/input.rb', line 18

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

#validate(model_registry) ⇒ Object



23
24
25
26
# File 'lib/apigen/rest/input.rb', line 23

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