diff --git a/lib/starter/importer/description.rb b/lib/starter/importer/description.rb index 011108d..3c002bc 100644 --- a/lib/starter/importer/description.rb +++ b/lib/starter/importer/description.rb @@ -9,18 +9,28 @@ def initialize(content:) @content = content end - def to_s + def to_s # rubocop:disable Metrics/AbcSize return if content.blank? - desc = content['summary'] || name + desc = content['summary'] || content['operationId'] + entry = "desc '#{desc}'\n" - entry = "desc '#{desc}' do\n" + return entry unless block_keys.intersect?(content.keys) + + entry.sub!("\n", " do\n") entry << " detail '#{content['description']}'\n" if content.key?('description') entry << " tags #{content['tags']}\n" if content.key?('tags') entry << 'end' entry end + + def block_keys + %w[ + description + tags + ] + end end end end