From 0320dc5a91ecdcaf8682d0ee5444a5bb50f837c4 Mon Sep 17 00:00:00 2001 From: "Mario.RuizSanchez" Date: Tue, 25 Jun 2019 14:13:16 +0000 Subject: [PATCH] fixed objects without type array but items --- lib/open_api_import.rb | 5 +++++ open_api_import.gemspec | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/open_api_import.rb b/lib/open_api_import.rb index f237150..63e99de 100644 --- a/lib/open_api_import.rb +++ b/lib/open_api_import.rb @@ -218,6 +218,7 @@ def self.from(swagger_file, create_method_name: :operation_id, include_responses cont[:responses].each do |k, v| response_example = [] response_example = get_response_examples(v) + data_pattern += get_patterns(k, v[:schema]) if v.key?(:schema) v[:description] = v[:description].to_s.gsub("'", %q(\\\')) @@ -586,6 +587,9 @@ class << self if val.key?(:properties) and !val.key?(:example) and !val.key?(:type) val[:type]='object' end + if val.key?(:items) and !val.key?(:example) and !val.key?(:type) + val[:type]='array' + end if val.key?(:example) example << if val[:example].is_a?(String) or val[:example].is_a?(Time) " #{prop.to_sym}: \"#{val[:example]}\", " @@ -739,6 +743,7 @@ class << self response_example << "]" end end + elsif v.key?(:schema) and v[:schema].key?(:items) and v[:schema][:items].key?(:type) # for the case only type supplied but nothing else for the array response_example << "[\"#{v[:schema][:items][:type]}\"]" diff --git a/open_api_import.gemspec b/open_api_import.gemspec index 99b77fc..544a096 100644 --- a/open_api_import.gemspec +++ b/open_api_import.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |s| s.name = 'open_api_import' - s.version = '0.8.1' + s.version = '0.8.2' s.summary = "OpenApiImport -- Import a Swagger or Open API file and create a Ruby Request Hash file including all requests and responses with all the examples. The file can be in JSON or YAML" s.description = "OpenApiImport -- Import a Swagger or Open API file and create a Ruby Request Hash file including all requests and responses with all the examples. The file can be in JSON or YAML" s.authors = ["Mario Ruiz"]