Class: Swagger::Api::ColumnSchema
- Inherits:
-
Object
- Object
- Swagger::Api::ColumnSchema
- Includes:
- ActiveAttr::Model
- Defined in:
- lib/swagger/api/column_schema.rb
Instance Attribute Summary collapse
-
#column ⇒ Object
Returns the value of attribute column.
Instance Method Summary collapse
Instance Attribute Details
#column ⇒ Object
Returns the value of attribute column.
5 6 7 |
# File 'lib/swagger/api/column_schema.rb', line 5 def column @column end |
Instance Method Details
#create ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/swagger/api/column_schema.rb', line 7 def create schema = { type: type_from_column, format: format_from_column } schema[:minimum] = 1 if column.type == :integer && column.name.to_s.ends_with?('id') schema[:minimum] = 0 if column.type == :integer && !column.name.to_s.ends_with?('id') schema end |
#format_from_column ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/swagger/api/column_schema.rb', line 27 def format_from_column case column.type when :datetime 'date-time' when :integer :int64 else if column.name.to_s == 'email' :email else column.type end end end |
#type_from_column ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/swagger/api/column_schema.rb', line 17 def type_from_column if i(datetime date time).include?(column.type) :string elsif i(float double).include?(column.type) :number else column.type end end |