class Apigen::Rest::Input

Input is the request body expected by an API endpoint.

Public Class Methods

new() click to toggle source
# File lib/apigen/rest/input.rb, line 11
def initialize
  @type = nil
  @description = nil
end

Public Instance Methods

to_s() click to toggle source
# File lib/apigen/rest/input.rb, line 28
def to_s
  @type.to_s
end
type(type = nil, &block) click to toggle source

Declares the input type.

# 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) click to toggle source
# File lib/apigen/rest/input.rb, line 23
def validate(model_registry)
  validate_properties
  model_registry.check_type @type
end

Private Instance Methods

validate_properties() click to toggle source
# File lib/apigen/rest/input.rb, line 34
def validate_properties
  raise 'Use `type :typename` to assign a type to the input.' unless @type
end