Class: OasParser::Property
- Inherits:
-
AbstractAttribute
- Object
- AbstractAttribute
- OasParser::Property
- Defined in:
- lib/oas_parser/property.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
writeonly
Sets the attribute name.
-
#owner ⇒ Object
Returns the value of attribute owner.
-
#raw ⇒ Object
Returns the value of attribute raw.
-
#schema ⇒ Object
Returns the value of attribute schema.
Instance Method Summary collapse
- #convert_property_schema_to_properties(schema) ⇒ Object
-
#initialize(owner, schema, name, raw) ⇒ Property
constructor
A new instance of Property.
- #required ⇒ Object
Methods inherited from AbstractAttribute
#allOf?, #array?, #collection?, #empty?, #enum, #has_xml_name?, #has_xml_options?, #is_xml_attribute?, #is_xml_text?, #name, #object?, #oneOf?, #properties, #subproperties_are_one_of_many?, #xml_name
Methods included from RawAccessor
included, #method_missing, #respond_to_missing?
Constructor Details
#initialize(owner, schema, name, raw) ⇒ Property
Returns a new instance of Property.
9 10 11 12 13 14 |
# File 'lib/oas_parser/property.rb', line 9 def initialize(owner, schema, name, raw) super(name) @owner = owner @schema = schema @raw = raw end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class OasParser::RawAccessor
Instance Attribute Details
#name=(value) ⇒ Object (writeonly)
Sets the attribute name
7 8 9 |
# File 'lib/oas_parser/property.rb', line 7 def name=(value) @name = value end |
#owner ⇒ Object
Returns the value of attribute owner.
6 7 8 |
# File 'lib/oas_parser/property.rb', line 6 def owner @owner end |
#raw ⇒ Object
Returns the value of attribute raw.
6 7 8 |
# File 'lib/oas_parser/property.rb', line 6 def raw @raw end |
#schema ⇒ Object
Returns the value of attribute schema.
6 7 8 |
# File 'lib/oas_parser/property.rb', line 6 def schema @schema end |
Instance Method Details
#convert_property_schema_to_properties(schema) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/oas_parser/property.rb', line 22 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 |
#required ⇒ Object
16 17 18 19 20 |
# File 'lib/oas_parser/property.rb', line 16 def required return true if raw['required'] return false unless schema['required'] schema['required'].include? name end |