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

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

Overview

Specifies an example object.

Constant Summary

Constants included from Base::Attributes

Base::Attributes::DEFAULT_ARRAY, Base::Attributes::DEFAULT_HASH

Instance Method Summary collapse

Methods included from OpenAPI::Extensions

#add_openapi_extension, #openapi_extensions, #openapi_extensions=

Methods inherited from Base::Model

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

Methods included from Base::Attributes

#attribute, #attribute_names

Constructor Details

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

Instance Method Details

#descriptionObject

:attr: description The description of the example.



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

attribute :description, String

#externalObject

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



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

attribute :external, values: [true, false]

#summaryObject

:attr: summary The summary of the example.



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

attribute :summary, String

#to_openapiObject

Returns a hash representing the OpenAPI example object.



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

def to_openapi(*)
  with_openapi_extensions(summary: summary, description: description).tap do |hash|
    if external?
      hash[:external_value] = value
    else
      hash[:value] = value
    end
  end
end

#valueObject

:attr: value The sample value.



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

attribute :value