Skip to content

Commit

Permalink
whitespace ResourceBase.api_method_name_by_operation
Browse files Browse the repository at this point in the history
  • Loading branch information
notEthan committed Feb 20, 2022
1 parent b0a78bf commit 722eaf1
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions lib/scorpio/resource_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -214,25 +214,25 @@ def operation_for_api_method_name(name)
# @param name [Scorpio::OpenAPI::Operation]
# @return [String, nil]
def api_method_name_by_operation(operation)
raise(ArgumentError, operation.pretty_inspect) unless operation.is_a?(Scorpio::OpenAPI::Operation)

# if Pet is the Scorpio resource class
# and Pet.tag_name is "pet"
# and operation's operationId is "pet.add"
# then the operation's method name on Pet will be "add".
# if the operationId is just "addPet"
# then the operation's method name on Pet will be "addPet".
tag_name_match = tag_name &&
operation.tags.respond_to?(:to_ary) && # TODO maybe operation.tags.valid?
operation.tags.include?(tag_name) &&
operation.operationId &&
operation.operationId.match(/\A#{Regexp.escape(tag_name)}\.(\w+)\z/)

if tag_name_match
tag_name_match[1]
else
operation.operationId
end
raise(ArgumentError, operation.pretty_inspect) unless operation.is_a?(Scorpio::OpenAPI::Operation)

# if Pet is the Scorpio resource class
# and Pet.tag_name is "pet"
# and operation's operationId is "pet.add"
# then the operation's method name on Pet will be "add".
# if the operationId is just "addPet"
# then the operation's method name on Pet will be "addPet".
tag_name_match = tag_name &&
operation.tags.respond_to?(:to_ary) && # TODO maybe operation.tags.valid?
operation.tags.include?(tag_name) &&
operation.operationId &&
operation.operationId.match(/\A#{Regexp.escape(tag_name)}\.(\w+)\z/)

if tag_name_match
tag_name_match[1]
else
operation.operationId
end
end

def update_class_and_instance_api_methods
Expand Down

0 comments on commit 722eaf1

Please sign in to comment.