Module: ThreeScaleToolbox::Commands::ImportCommand::OpenAPI::MappingRule

Included in:
Operation
Defined in:
lib/3scale_toolbox/commands/import_command/openapi/mapping_rule.rb

Instance Method Summary collapse

Instance Method Details

#deltaObject



35
36
37
# File 'lib/3scale_toolbox/commands/import_command/openapi/mapping_rule.rb', line 35

def delta
  1
end

#http_methodObject



15
16
17
# File 'lib/3scale_toolbox/commands/import_command/openapi/mapping_rule.rb', line 15

def http_method
  operation[:verb].upcase
end

#mapping_ruleObject



6
7
8
9
10
11
12
13
# File 'lib/3scale_toolbox/commands/import_command/openapi/mapping_rule.rb', line 6

def mapping_rule
  {
    'pattern' => pattern,
    'http_method' => http_method,
    'delta' => delta,
    'metric_id' => metric_id
  }
end

#metric_idObject



39
40
41
# File 'lib/3scale_toolbox/commands/import_command/openapi/mapping_rule.rb', line 39

def metric_id
  operation[:metric_id]
end

#patternObject



19
20
21
22
23
# File 'lib/3scale_toolbox/commands/import_command/openapi/mapping_rule.rb', line 19

def pattern
  res = "#{raw_pattern}"
  res = "#{res}$" if !operation[:prefix_matching] # apply strict matching
  res
end

#public_base_pathObject



30
31
32
33
# File 'lib/3scale_toolbox/commands/import_command/openapi/mapping_rule.rb', line 30

def public_base_path
  # remove the last slash of the basePath
  operation[:public_base_path].gsub(%r{/$}, '')
end

#raw_patternObject



25
26
27
28
# File 'lib/3scale_toolbox/commands/import_command/openapi/mapping_rule.rb', line 25

def raw_pattern
  # According OAS 2.0: path MUST begin with a slash
  "#{public_base_path}#{operation[:path]}"
end