Add #is_primitive? and #generate_typeref
This commit is contained in:
parent
d205202ddc
commit
2f35d85bb8
|
|
@ -322,8 +322,10 @@ module Grape
|
|||
end
|
||||
|
||||
if p.delete(:is_array)
|
||||
p[:items] = {"$ref" => p[:type]}
|
||||
p[:items] = generate_typeref(p[:type])
|
||||
p[:type] = "array"
|
||||
else
|
||||
p.merge! generate_typeref(p.delete(:type))
|
||||
end
|
||||
|
||||
# rename Grape Entity's "desc" to "description"
|
||||
|
|
@ -344,6 +346,18 @@ module Grape
|
|||
result
|
||||
end
|
||||
|
||||
def is_primitive?(type)
|
||||
%w(integer long float double string byte boolean date dateTime).include? type
|
||||
end
|
||||
|
||||
def generate_typeref(type)
|
||||
if is_primitive? type
|
||||
{ "type" => type }
|
||||
else
|
||||
{ "$ref" => type }
|
||||
end
|
||||
end
|
||||
|
||||
def parse_http_codes codes
|
||||
codes ||= {}
|
||||
codes.map do |k, v|
|
||||
|
|
|
|||
Loading…
Reference in New Issue