diff --git a/lib/starter/importer/parameter.rb b/lib/starter/importer/parameter.rb index 11ca40c..e709f96 100644 --- a/lib/starter/importer/parameter.rb +++ b/lib/starter/importer/parameter.rb @@ -15,7 +15,7 @@ def initialize(definition:, components: {}) end def to_s - return serialized_object if nested.present? + return serialized_object if nested? serialized end @@ -121,10 +121,16 @@ def serialized_object end parent = NestedParams.new(name: name, definition: definition) - entry = "#{parent} do\n" nested.each { |n| entry << " #{n}\n" } entry << ' end' + if entry.include?("format: 'binary', type: 'File'") + entry.sub!('type: JSON', 'type: Hash') + entry.sub!(", documentation: { in: 'body' }", '') + entry.gsub!(", in: 'body'", '') + end + + entry end def serialized @@ -149,7 +155,9 @@ def documentation @documentation ||= begin tmp = {} tmp['desc'] = definition['description'] if definition.key?('description') - tmp['in'] = definition['in'] if definition.key?('in') && !definition['format'] == 'binary' + if definition.key?('in') && !(definition['type'] == 'File' && definition['format'] == 'binary') + tmp['in'] = definition['in'] + end if definition.key?('format') tmp['format'] = definition['format'] diff --git a/template/.rubocop.yml b/template/.rubocop.yml index 7c4d11e..83e2d73 100644 --- a/template/.rubocop.yml +++ b/template/.rubocop.yml @@ -25,3 +25,6 @@ Style/AsciiComments: Style/Documentation: Enabled: false + +Style/RedundantArrayConstructor: + Enabled: false \ No newline at end of file