lib/dry/swagger/documentation_generator.rb in dry-swagger-0.5.0 vs lib/dry/swagger/documentation_generator.rb in dry-swagger-0.5.1

- old
+ new

@@ -38,15 +38,28 @@ if attributes_hash.is_a?(Array) properties = {} attributes_hash.each_with_index do |_, index| properties["definition_#{index + 1}"] = generate_field_properties(attributes_hash[index]) end - { - oneOf: attributes_hash.map{ |it| generate_field_properties(it) }, - type: :object, - properties: properties, - example: 'Dynamic Field. See Model Definitions' - } + if attributes_hash[0][:type] == 'array' + attributes_hash.each { |definition| definition[:type] = 'hash'} + { + type: :array, + items: { + type: :object, + properties: properties, + oneOf: attributes_hash.map{ |it| generate_field_properties(it) }, + example: 'Dynamic Field. See Model Definitions' + }, + } + else + { + oneOf: attributes_hash.map{ |it| generate_field_properties(it) }, + type: :object, + properties: properties, + example: 'Dynamic Field. See Model Definitions' + } + end else if attributes_hash[:type] == 'array' items = generate_documentation(attributes_hash.fetch(:keys)) items = @config.enable_nullable_validation ? items.merge(@config.nullable_type => attributes_hash.fetch(@config.nullable_type, false)) :