module Swaggable::GrapeEntityTranslator

Public Class Methods

parameter_from(entity) click to toggle source
# File lib/swaggable/grape_entity_translator.rb, line 3
def self.parameter_from entity
  ParameterDefinition.new do
    location :body
    name entity.name
    schema.name entity.name

    entity.exposures.each do |name, opts|
      schema.attributes.add_new do
        this.name name
        type type_from_options(opts)
        description description_from_options(opts)
        required required_from_options(opts)
      end
    end
  end
end

Private Class Methods

description_from_options(opts) click to toggle source
# File lib/swaggable/grape_entity_translator.rb, line 28
def self.description_from_options opts
  documentation = opts[:documentation] || {}
  documentation[:desc]
end
required_from_options(opts) click to toggle source
# File lib/swaggable/grape_entity_translator.rb, line 33
def self.required_from_options opts
  documentation = opts[:documentation] || {}
  documentation[:required]
end
type_from_options(opts) click to toggle source
# File lib/swaggable/grape_entity_translator.rb, line 22
def self.type_from_options opts
  documentation = opts[:documentation] || {}
  type = documentation[:type] || 'string'
  type.downcase.to_sym
end