Skip to content

Commit

Permalink
import openapi: fix when missing operation id in spec
Browse files Browse the repository at this point in the history
  • Loading branch information
eguzki committed Mar 7, 2019
1 parent 6d903af commit 091fc1e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/3scale_toolbox/commands/import_command/openapi/method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@ def method
end

def friendly_name
operation[:operationId]
operation[:operationId] || operation_id
end

def system_name
friendly_name.downcase
end

def operation_id
"#{operation[:verb]}#{operation[:path].gsub(/[^\w]/, '')}"
end
end
end
end
Expand Down
14 changes: 14 additions & 0 deletions spec/unit/commands/import_command/openapi/method_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,18 @@ def initialize(operation)
is_expected.to include('system_name' => operationId.downcase)
end
end

context 'operation id not available' do
let(:operation) { { verb: 'get', path: '/pet/{petId}' } }

subject { OpenAPIMethodClass.new(operation).method }

it 'contains "friendly_name"' do
is_expected.to include('friendly_name' => 'getpetpetId')
end

it 'contains "system_name"' do
is_expected.to include('system_name' => 'getpetpetid')
end
end
end

0 comments on commit 091fc1e

Please sign in to comment.