Skip to content

Commit

Permalink
Fixes handling of File parameter type.
Browse files Browse the repository at this point in the history
- makes rubocop happy
  • Loading branch information
LeFnord committed Oct 22, 2023
1 parent a8771fe commit 091587b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lib/starter/importer/parameter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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']
Expand Down
3 changes: 3 additions & 0 deletions template/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ Style/AsciiComments:

Style/Documentation:
Enabled: false

Style/RedundantArrayConstructor:
Enabled: false

0 comments on commit 091587b

Please sign in to comment.