Skip to content

Commit

Permalink
fixed objects without type array but items
Browse files Browse the repository at this point in the history
  • Loading branch information
Mario.RuizSanchez committed Jun 25, 2019
1 parent 1969fab commit 0320dc5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/open_api_import.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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(\\\'))

Expand Down Expand Up @@ -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]}\", "
Expand Down Expand Up @@ -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]}\"]"
Expand Down
2 changes: 1 addition & 1 deletion open_api_import.gemspec
Original file line number Diff line number Diff line change
@@ -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"]
Expand Down

0 comments on commit 0320dc5

Please sign in to comment.