Class: Jsapi::Meta::Parameter::Reference

Inherits:
Model::Reference show all
Defined in:
lib/jsapi/meta/parameter/reference.rb

Overview

Refers a reusable parameter.

Constant Summary

Constants included from Model::Attributes

Model::Attributes::DEFAULT_ARRAY, Model::Attributes::DEFAULT_HASH

Instance Method Summary collapse

Methods inherited from Model::Reference

component_type, #description, openapi_component_type, #ref, #reference?, #resolve, #summary, #to_openapi

Methods inherited from Model::Base

#initialize, #inspect, #merge!, #reference?, #resolve

Methods included from Model::Attributes

#attribute, #attribute_names

Constructor Details

This class inherits a constructor from Jsapi::Meta::Model::Base

Instance Method Details

#to_openapi_parameters(version, definitions) ⇒ Object

Returns an array of hashes representing the OpenAPI parameter or reference objects.

Raises a ReferenceError when the reference could not be resolved.



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/jsapi/meta/parameter/reference.rb', line 11

def to_openapi_parameters(version, definitions)
  version = OpenAPI::Version.from(version)
  parameter = resolve(definitions)

  if parameter.schema.resolve(definitions).object?
    # Explode referred parameter
    parameter.to_openapi_parameters(version, definitions)
  else
    # Return an array containing the reference object
    [to_openapi(version)]
  end
end