Sha256: be9b314785f526e9426b0f520162ce5e0a7cccd6ed5385189612ea4b14046481
Contents?: true
Size: 956 Bytes
Versions: 6
Compression:
Stored size: 956 Bytes
Contents
# frozen_string_literal: true module GrapeSwagger module DocMethods class OperationId class << self def build(route, path = nil) if route.options[:nickname] route.options[:nickname] else verb = route.request_method.to_s.downcase operation = manipulate(path) unless path.nil? "#{verb}#{operation}" end end def manipulate(path) operation = path.split('/').map(&:capitalize).join operation.gsub!(/\-(\w)/, &:upcase).delete!('-') if operation[/\-(\w)/] operation.gsub!(/\_(\w)/, &:upcase).delete!('_') if operation.include?('_') operation.gsub!(/\.(\w)/, &:upcase).delete!('.') if operation[/\.(\w)/] if path.include?('{') operation.gsub!(/\{(\w)/, &:upcase) operation.delete!('{').delete!('}') end operation end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems