Class: Eazypi::Schema::Primitive

Inherits:
Object
  • Object
show all
Includes:
Eazypi::SpecObject
Defined in:
lib/eazypi/schema/primitive.rb

Overview

Primitive schema definition

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Eazypi::SpecObject

included, #load

Constructor Details

#initialize(type: nil, format: nil) ⇒ Primitive

Returns a new instance of Primitive.



11
12
13
14
# File 'lib/eazypi/schema/primitive.rb', line 11

def initialize(type: nil, format: nil)
  @type = type
  @format = format
end

Instance Attribute Details

#formatObject (readonly)

Returns the value of attribute format.



9
10
11
# File 'lib/eazypi/schema/primitive.rb', line 9

def format
  @format
end

#typeObject (readonly)

Returns the value of attribute type.



9
10
11
# File 'lib/eazypi/schema/primitive.rb', line 9

def type
  @type
end

Instance Method Details

#==(other) ⇒ Object



25
26
27
28
29
30
# File 'lib/eazypi/schema/primitive.rb', line 25

def ==(other)
  return false unless other.is_a?(Primitive)

  type == other.type &&
    format == other.format
end

#collect_components(**_kwargs) ⇒ Object



16
# File 'lib/eazypi/schema/primitive.rb', line 16

def collect_components(**_kwargs); end

#to_openapi_specObject



18
19
20
21
22
23
# File 'lib/eazypi/schema/primitive.rb', line 18

def to_openapi_spec
  {
    "type" => type,
    "format" => format
  }.compact
end