Class: Jsapi::Meta::Example::Base

Inherits:
Model::Base show all
Includes:
OpenAPI::Extensions
Defined in:
lib/jsapi/meta/example/base.rb

Overview

Specifies an example.

Instance Method Summary collapse

Methods included from OpenAPI::Extensions

included

Methods inherited from Model::Base

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

Methods included from Model::Attributes

#attributes_frozen?, #freeze_attributes, included

Constructor Details

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

Instance Method Details

#descriptionObject

:attr: description The description of the example.



13
# File 'lib/jsapi/meta/example/base.rb', line 13

attribute :description, String

#external_valueObject

:attr: external_value The URI of an external sample value.



18
# File 'lib/jsapi/meta/example/base.rb', line 18

attribute :external_value, String, accessors: i[reader]

#external_value=(value) ⇒ Object

:nodoc:



35
36
37
38
39
40
41
42
# File 'lib/jsapi/meta/example/base.rb', line 35

def external_value=(value) # :nodoc:
  try_modify_attribute!(:external_value) do
    raise 'external value and serialized value are mutually exclusive' \
    unless serialized_value.nil?

    @external_value = value
  end
end

#serialized_valueObject

:attr: serialized_value The serialized form of the sample value.



23
# File 'lib/jsapi/meta/example/base.rb', line 23

attribute :serialized_value, accessors: i[reader]

#serialized_value=(value) ⇒ Object

:nodoc:



44
45
46
47
48
49
50
51
# File 'lib/jsapi/meta/example/base.rb', line 44

def serialized_value=(value)  # :nodoc:
  try_modify_attribute!(:serialized_value) do
    raise 'external value and serialized value are mutually exclusive' \
    unless external_value.nil?

    @serialized_value = value
  end
end

#summaryObject

:attr: summary The short summary of the example.



28
# File 'lib/jsapi/meta/example/base.rb', line 28

attribute :summary, String

#to_openapi(version) ⇒ Object

Returns a hash representing the OpenAPI example object.



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/jsapi/meta/example/base.rb', line 54

def to_openapi(version, *)
  version = OpenAPI::Version.from(version)

  with_openapi_extensions(
    summary: summary,
    description: description,
    **if version < OpenAPI::V3_2
        { value: value }
      else
        {
          dataValue: value,
          serializedValue: serialized_value
        }
      end,
    externalValue: external_value
  )
end

#valueObject

:attr: value The sample value.



33
# File 'lib/jsapi/meta/example/base.rb', line 33

attribute :value