Class: Jsapi::Meta::Parameter::Reference
- Inherits:
-
Base::Reference
- Object
- Base::Model
- Base::Reference
- Jsapi::Meta::Parameter::Reference
- Includes:
- ToOpenAPI
- Defined in:
- lib/jsapi/meta/parameter/reference.rb
Overview
Specifies a parameter reference.
Constant Summary
Constants included from Base::Attributes
Base::Attributes::DEFAULT_ARRAY, Base::Attributes::DEFAULT_HASH
Instance Method Summary collapse
-
#to_openapi_parameters(version, definitions) ⇒ Object
Returns an array of hashes.
Methods included from ToOpenAPI
Methods inherited from Base::Reference
component_type, #ref, #reference?, #resolve
Methods inherited from Base::Model
#initialize, #inspect, #merge!, #reference?, #resolve
Methods included from Base::Attributes
Constructor Details
This class inherits a constructor from Jsapi::Meta::Base::Model
Instance Method Details
#to_openapi_parameters(version, definitions) ⇒ Object
Returns an array of hashes. If the type of the referred parameter is "object"
, each hash represents an OpenAPI parameter object. Otherwise the array contains a single hash representing the OpenAPI reference object.
Raises a ReferenceError when the reference could not be resolved.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/jsapi/meta/parameter/reference.rb', line 16 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 path = version.major == 2 ? 'parameters' : 'components/parameters' [{ '$ref': "#/#{path}/#{ref}" }] end end |