Module: Taro::Types::Shared::OpenAPIType

Defined in:
lib/taro/types/shared/openapi_type.rb

Overview

Provides a setter and getter for type classes’ ‘openapi_type`, for use in the OpenAPI export.

Constant Summary collapse

OPENAPI_TYPES =
%i[
  array
  boolean
  integer
  number
  object
  string
].freeze

Instance Method Summary collapse

Instance Method Details

#inherited(subclass) ⇒ Object



23
24
25
26
# File 'lib/taro/types/shared/openapi_type.rb', line 23

def inherited(subclass)
  subclass.instance_variable_set(:@openapi_type, @openapi_type)
  super
end

#openapi_typeObject



13
14
15
# File 'lib/taro/types/shared/openapi_type.rb', line 13

def openapi_type
  @openapi_type || raise(Taro::RuntimeError, "Type lacks openapi_type: #{self}")
end

#openapi_type=(arg) ⇒ Object



17
18
19
20
21
# File 'lib/taro/types/shared/openapi_type.rb', line 17

def openapi_type=(arg)
  OPENAPI_TYPES.include?(arg) ||
    raise(Taro::ArgumentError, "openapi_type must be a Symbol, one of #{OPENAPI_TYPES}")
  @openapi_type = arg
end