Sha256: 1ae344dd164c407bc7e7f297fa39dee3e0ae5df6e058159a41f231601070df2c

Contents?: true

Size: 642 Bytes

Versions: 5

Compression:

Stored size: 642 Bytes

Contents

# Provides a setter and getter for type classes' `openapi_type`,
# for use in the OpenAPI export.
module Taro::Types::Shared::OpenAPIType
  OPENAPI_TYPES = %i[
    array
    boolean
    integer
    number
    object
    string
  ].freeze

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

  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

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
taro-1.4.0 lib/taro/types/shared/openapi_type.rb
taro-1.3.0 lib/taro/types/shared/openapi_type.rb
taro-1.2.0 lib/taro/types/shared/openapi_type.rb
taro-1.1.0 lib/taro/types/shared/openapi_type.rb
taro-1.0.0 lib/taro/types/shared/openapi_type.rb