lib/dry/swagger/struct_parser.rb in dry-swagger-0.7.2 vs lib/dry/swagger/struct_parser.rb in dry-swagger-1.0.0
- old
+ new
@@ -2,11 +2,12 @@
module Swagger
class StructParser
PREDICATE_TYPES = {
String: 'string',
Integer: 'integer',
- Bool: 'boolean',
+ TrueClass: 'boolean',
+ FalseClass: 'boolean',
Float: 'float',
Date: 'date',
DateTime: 'datetime',
Time: 'time'
}.freeze
@@ -87,10 +88,15 @@
if name.equal?(:type?)
type = type.to_s.to_sym
return unless PREDICATE_TYPES[type]
+ # print node
+ # puts
+ # print opts
+ # puts
+
type_definition = {
type: PREDICATE_TYPES[type],
required: opts.fetch(:required),
@config.nullable_type => opts.fetch(:nullable, false)
}
@@ -115,10 +121,10 @@
visit(node[0], opts)
end
def visit_sum(node, opts = {})
if node[0][0].equal?(:constrained)
- opts[:nullable] = true
+ opts[:nullable] = true if node[0][1][0][1][0].equal?(NilClass)
visit(node[1], opts) # ignore NilClass constrained
elsif node[0][0].equal?(:struct) || node[0][0].equal?(:sum)
opts[:oneOf] = true
node.each { |child| visit(child, opts) unless child.is_a?(Hash) }
end
\ No newline at end of file