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.
4 5 6 |
# File 'lib/swagger_api/column_schema.rb', line 4 def column @column end |
Instance Method Details
#create ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/swagger_api/column_schema.rb', line 6 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
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/swagger_api/column_schema.rb', line 26 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
16 17 18 19 20 21 22 23 24 |
# File 'lib/swagger_api/column_schema.rb', line 16 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 |