module RatPackSwagger::DefinitionClass

Public Instance Methods

definition() click to toggle source

makes sure @definition is initialized

# File lib/rat_pack_swagger.rb, line 11
def definition
  @definition ||= {
    type: 'object',
    required: [],
    properties: {}
  }
  @definition
end
properties(&block) click to toggle source

Class declaration API

# File lib/rat_pack_swagger.rb, line 25
def properties(&block)
  definition[:properties].merge!(SwaggerObject.new(&block).to_h)
  # create top-level property accessors for instance-like usage
  definition[:properties].keys.each do |k|
    self.send(:attr_accessor, k)
  end
end
required(*args) click to toggle source
# File lib/rat_pack_swagger.rb, line 32
def required(*args)
  definition[:required].concat([*args]).uniq!
end
to_swagger_h() click to toggle source
# File lib/rat_pack_swagger.rb, line 20
def to_swagger_h
  definition
end