class Swagger::Grape::EntityNestingExposure

Public Class Methods

new(exposure) click to toggle source
# File lib/ruby-swagger/grape/entity_nesting_exposure.rb, line 3
def initialize(exposure)
  raise ArgumentError.new("Expecting a NestingExposure - Can't translate #{exposure}!") unless exposure.is_a? Grape::Entity::Exposure::NestingExposure

  @exposure = exposure
  @properties = {}
end

Public Instance Methods

to_swagger() click to toggle source
# File lib/ruby-swagger/grape/entity_nesting_exposure.rb, line 10
def to_swagger
  nested_exposures.each do |exposure|
    @properties.merge!(Swagger::Grape::EntityExposure.new(exposure).to_swagger)
  end

  array? ? array_schema : object_schema
end

Private Instance Methods

array_schema() click to toggle source
# File lib/ruby-swagger/grape/entity_nesting_exposure.rb, line 27
def array_schema
  {
    'type' => 'array',
    'description' => description,
    'items' => {
      'type' => 'object',
      'properties' => @properties
    }
  }
end
object_schema() click to toggle source
# File lib/ruby-swagger/grape/entity_nesting_exposure.rb, line 20
def object_schema
  {
    'type' => 'object',
    'properties' => @properties
  }
end