Skip to content

Commit 1b01e6a

Browse files
authored
Merge pull request #10 from jksy/feature/fix-raise-error-on-mysql
Fixed an error that occurred when using this on mysql.
2 parents 9eae4f0 + a0f7422 commit 1b01e6a

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/generators/jsonapi/swagger/swagger_generator.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,15 @@ def columns_with_comment(need_encoding: true)
132132
end
133133
model_klass.columns.each do |col|
134134
col_name = transform_method ? col.name.send(transform_method) : col.name
135-
clos[col_name.to_sym] = { type: swagger_type(col), items_type: col.type, is_array: col.array, nullable: col.null, comment: col.comment }
135+
is_array = col.respond_to?(:array) ? col.array : false
136+
clos[col_name.to_sym] = { type: swagger_type(col), items_type: col.type, is_array: is_array, nullable: col.null, comment: col.comment }
136137
clos[col_name.to_sym][:comment] = safe_encode(col.comment) if need_encoding
137138
end
138139
end
139140
end
140141

141142
def swagger_type(column)
142-
return 'array' if column.array
143+
return 'array' if column.respond_to?(:array) && column.array
143144

144145
case column.type
145146
when :bigint, :integer then 'integer'
@@ -168,4 +169,4 @@ def safe_encode(content)
168169
content&.force_encoding('ASCII-8BIT')
169170
end
170171
end
171-
end
172+
end

0 commit comments

Comments
 (0)