Class: SwaggerApi::ColumnSchema
- Inherits:
-
Object
- Object
- SwaggerApi::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.
6 7 8 |
# File 'lib/swagger_api/column_schema.rb', line 6 def column @column end |
Instance Method Details
#create ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/swagger_api/column_schema.rb', line 8 def create schema = default_schema if column.type == :integer schema[:minimum] = if column.name.to_s.ends_with?('id') 1 else 0 end end schema end |
#default_schema ⇒ Object
20 21 22 23 24 25 |
# File 'lib/swagger_api/column_schema.rb', line 20 def default_schema { type: type_from_column, format: format_from_column } end |
#format_from_column ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/swagger_api/column_schema.rb', line 37 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
27 28 29 30 31 32 33 34 35 |
# File 'lib/swagger_api/column_schema.rb', line 27 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 |