class Swagger::Api::ColumnSchema
Attributes
column[RW]
Public Instance Methods
create()
click to toggle source
# 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()
click to toggle source
# 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()
click to toggle source
# 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