class OasParser::Property

Attributes

name[W]
owner[RW]
raw[RW]
schema[RW]

Public Class Methods

new(owner, schema, name, raw) click to toggle source
Calls superclass method OasParser::AbstractAttribute::new
# File lib/oas_parser/property.rb, line 9
def initialize(owner, schema, name, raw)
  super(name)
  @owner = owner
  @schema = schema
  @raw = raw
end

Public Instance Methods

convert_property_schema_to_properties(schema) click to toggle source
# File lib/oas_parser/property.rb, line 26
def convert_property_schema_to_properties(schema)
  if schema['allOf']
    schema['properties'] = {}
    schema['allOf'].each do |p|
      schema['properties'].deep_merge!(p['properties'])
    end
    schema.delete('allOf')
  end

  if schema['oneOf']
    schema['oneOf'].map do |subschema|
      subschema['properties'] = convert_property_schema_to_properties(subschema)
      subschema['subschema_property'] = true
      subschema
    end
  elsif schema['subschema_property']
    schema = schema['properties'] if schema['properties']
    schema.map do |definition|
      OasParser::Property.new(self, raw, definition.name, definition.raw)
    end
  else
    schema = schema['properties'] if schema['properties']
    schema.map do |key, definition|
      OasParser::Property.new(self, raw, key, definition)
    end
  end
end
nullable?() click to toggle source
# File lib/oas_parser/property.rb, line 21
def nullable?
  return true if raw['nullable']
  return false unless schema['nullable']
end
required() click to toggle source
# File lib/oas_parser/property.rb, line 16
def required
  return false unless schema['required']
  schema['required'].include? name
end