Class: Jsapi::Meta::Example::Model

Inherits:
Base
  • Object
show all
Defined in:
lib/jsapi/meta/example/model.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize, #inspect, #reference?, #resolve

Methods included from Attributes::ClassMethods

#attribute, #attribute_names

Constructor Details

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

Instance Method Details

#descriptionObject

:attr: description The optional description of the example.



10
# File 'lib/jsapi/meta/example/model.rb', line 10

attribute :description, String

#externalObject

:attr: external If true, value is interpreted as a URI pointing to an external sample value.



16
# File 'lib/jsapi/meta/example/model.rb', line 16

attribute :external, values: [true, false]

#summaryObject

:attr: summary The optional summary of the example.



21
# File 'lib/jsapi/meta/example/model.rb', line 21

attribute :summary, String

#to_openapiObject

Returns a hash representing the OpenAPI example object.



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/jsapi/meta/example/model.rb', line 29

def to_openapi(*)
  {}.tap do |hash|
    hash[:summary] = summary if summary.present?
    hash[:description] = description if description.present?

    if external?
      hash[:external_value] = value
    else
      hash[:value] = value
    end
  end
end

#valueObject

:attr: value The sample value.



26
# File 'lib/jsapi/meta/example/model.rb', line 26

attribute :value