Skip to content

Commit

Permalink
Merge pull request superiorlu#10 from jksy/feature/fix-raise-error-on…
Browse files Browse the repository at this point in the history
…-mysql

Fixed an error that occurred when using this on mysql.
  • Loading branch information
superiorlu authored Nov 20, 2020
2 parents 9eae4f0 + a0f7422 commit 1b01e6a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/generators/jsonapi/swagger/swagger_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,15 @@ def columns_with_comment(need_encoding: true)
end
model_klass.columns.each do |col|
col_name = transform_method ? col.name.send(transform_method) : col.name
clos[col_name.to_sym] = { type: swagger_type(col), items_type: col.type, is_array: col.array, nullable: col.null, comment: col.comment }
is_array = col.respond_to?(:array) ? col.array : false
clos[col_name.to_sym] = { type: swagger_type(col), items_type: col.type, is_array: is_array, nullable: col.null, comment: col.comment }
clos[col_name.to_sym][:comment] = safe_encode(col.comment) if need_encoding
end
end
end

def swagger_type(column)
return 'array' if column.array
return 'array' if column.respond_to?(:array) && column.array

case column.type
when :bigint, :integer then 'integer'
Expand Down Expand Up @@ -168,4 +169,4 @@ def safe_encode(content)
content&.force_encoding('ASCII-8BIT')
end
end
end
end

0 comments on commit 1b01e6a

Please sign in to comment.