Class: Openapi2ruby::Openapi::Schema::Property
- Inherits:
-
Object
- Object
- Openapi2ruby::Openapi::Schema::Property
- Defined in:
- lib/openapi2ruby/openapi/schema/property.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(content) ⇒ Property
constructor
A new instance of Property.
-
#ref ⇒ String
OpenAPI schema ref property name.
-
#ref? ⇒ Boolean
Whether property is ref or not.
-
#ref_class ⇒ String
OpenAPI schema ref property class name.
-
#ref_items? ⇒ Boolean
Whether property has ref array items.
-
#types ⇒ Array[Class]
OpenAPI schema property types.
Constructor Details
#initialize(content) ⇒ Property
Returns a new instance of Property.
5 6 7 8 9 10 11 |
# File 'lib/openapi2ruby/openapi/schema/property.rb', line 5 def initialize(content) @name = content[:name] @type = content[:definition]['type'] @items = content[:definition]['items'] @format = content[:definition]['format'] @ref = content[:definition]['$ref'] end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/openapi2ruby/openapi/schema/property.rb', line 3 def name @name end |
Instance Method Details
#ref ⇒ String
OpenAPI schema ref property name
15 16 17 18 |
# File 'lib/openapi2ruby/openapi/schema/property.rb', line 15 def ref return @items['$ref'].split('/').last if ref_items? @ref.split('/').last end |
#ref? ⇒ Boolean
Whether property is ref or not
28 29 30 |
# File 'lib/openapi2ruby/openapi/schema/property.rb', line 28 def ref? !@ref.nil? end |
#ref_class ⇒ String
OpenAPI schema ref property class name
22 23 24 |
# File 'lib/openapi2ruby/openapi/schema/property.rb', line 22 def ref_class ref.camelcase end |
#ref_items? ⇒ Boolean
Whether property has ref array items
34 35 36 |
# File 'lib/openapi2ruby/openapi/schema/property.rb', line 34 def ref_items? @type == 'array' && !@items['$ref'].nil? end |
#types ⇒ Array[Class]
OpenAPI schema property types
40 41 42 43 |
# File 'lib/openapi2ruby/openapi/schema/property.rb', line 40 def types return [ref] if @type.nil? converted_types end |