Class: Apipie::Generator::Swagger::ParamDescription::ReferencedComposite

Inherits:
Object
  • Object
show all
Defined in:
lib/apipie/generator/swagger/param_description/referenced_composite.rb

Overview

A Composite that keeps track when a param description has been added to references

and returns the reference instead of the complete object

Instance Method Summary collapse

Constructor Details

#initialize(composite, param_type) ⇒ ReferencedComposite

Returns a new instance of ReferencedComposite.

Parameters:



6
7
8
9
# File 'lib/apipie/generator/swagger/param_description/referenced_composite.rb', line 6

def initialize(composite, param_type)
  @composite = composite
  @param_type = param_type.to_sym
end

Instance Method Details

#to_swaggerObject



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/apipie/generator/swagger/param_description/referenced_composite.rb', line 11

def to_swagger
  return ref_to(:name) if added?(:name)

  schema_obj = @composite.to_swagger

  return nil if schema_obj.nil?

  add(schema_obj)

  { '$ref' => ref_to(@param_type) }
end