Class: OpenApi::DSL::CombinedSchema

Inherits:
Hash
  • Object
show all
Includes:
Helpers
Defined in:
lib/oas_objs/combined_schema.rb

Overview

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers

#_combined_schema, #arrow_writing_support, #process_schema_input

Constructor Details

#initialize(combined_schema) ⇒ CombinedSchema

Returns a new instance of CombinedSchema.



12
13
14
15
16
# File 'lib/oas_objs/combined_schema.rb', line 12

def initialize(combined_schema)
  combined_schema.delete_if { |_, v| v.nil? }
  self.mode = combined_schema.keys.first.to_s.camelize(:lower).to_sym
  self.schemas = combined_schema.values.first
end

Instance Attribute Details

#modeObject

Returns the value of attribute mode.



10
11
12
# File 'lib/oas_objs/combined_schema.rb', line 10

def mode
  @mode
end

#processedObject

Returns the value of attribute processed.



10
11
12
# File 'lib/oas_objs/combined_schema.rb', line 10

def processed
  @processed
end

#schemasObject

Returns the value of attribute schemas.



10
11
12
# File 'lib/oas_objs/combined_schema.rb', line 10

def schemas
  @schemas
end

Instance Method Details

#processObject



18
19
20
21
22
23
24
25
26
27
# File 'lib/oas_objs/combined_schema.rb', line 18

def process
  self.processed = {
      mode =>
          schemas.map do |schema|
            type = schema.is_a?(Hash) ? schema[:type] : schema
            schema = { } unless schema.is_a?(Hash)
            SchemaObj.new(type, schema).process
          end
  }
end