Class: ThreeScaleToolbox::Commands::ImportCommand::OpenAPI::OpenAPISubcommand

Inherits:
Cri::CommandRunner
  • Object
show all
Includes:
ThreeScaleToolbox::Command, ResourceReader
Defined in:
lib/3scale_toolbox/commands/import_command/openapi.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ResourceReader

#load_resource, #read_content, #read_file, #read_stdin, #read_stringio, #read_url

Methods included from ThreeScaleToolbox::Command

#config, #config_file, #exit_with_message, #fetch_required_option, included, #keep_alive, #remotes, #threescale_client, #verbose, #verify_ssl

Class Method Details

.commandObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/3scale_toolbox/commands/import_command/openapi.rb', line 27

def self.command
  Cri::Command.define do
    name        'openapi'
    usage       'openapi [opts] -d <destination> <spec> (/path/to/your/spec/file.[json|yaml|yml] OR http[s]://domain/resource/path.[json|yaml|yml])'
    summary     'Import API defintion in OpenAPI specification from a local file or URL'
    description 'Using an API definition format like OpenAPI, import to your 3scale API directly from a local OpenAPI spec compliant file or a remote URL'

    option  :d, :destination, '3scale target instance. Format: "http[s]://<authentication>@3scale_domain"', argument: :required
    option  :t, 'target_system_name', 'Target system name', argument: :required
    flag    nil, 'activedocs-hidden', 'Create ActiveDocs in hidden state'
    flag    nil, 'skip-openapi-validation', 'Skip OpenAPI schema validation'
    flag    nil, 'prefix-matching', 'Use prefix matching instead of strict matching on mapping rules derived from openapi operations'
    flag    nil, 'backend', 'Create backend API from OAS'
    option  nil, 'oidc-issuer-type', 'OIDC Issuer Type (rest, keycloak)', argument: :required, transform: IssuerTypeTransformer.new
    option  nil, 'oidc-issuer-endpoint', 'OIDC Issuer Endpoint', argument: :required
    option  nil, 'default-credentials-userkey', 'Default credentials policy userkey', argument: :required
    option  nil, 'override-private-basepath', 'Override the basepath for the private URLs', argument: :required
    option  nil, 'override-public-basepath', 'Override the basepath for the public URLs', argument: :required
    option  nil, 'staging-public-base-url', 'Custom public staging URL', argument: :required
    option  nil, 'production-public-base-url', 'Custom public production URL', argument: :required
    option  nil, 'override-private-base-url', 'Custom private base URL', argument: :required
    option nil, 'backend-api-secret-token', 'Custom secret token sent by the API gateway to the backend API',argument: :required
    option nil, 'backend-api-host-header', 'Custom host header sent by the API gateway to the backend API', argument: :required
    ThreeScaleToolbox::CLI.output_flag(self)
    param   :openapi_resource

    runner OpenAPISubcommand
  end
end

Instance Method Details

#runObject



57
58
59
60
61
62
63
64
65
# File 'lib/3scale_toolbox/commands/import_command/openapi.rb', line 57

def run
  if backend?
    ImportBackendStep.new(context).call
  else
    ImportProductStep.new(context).call
  end

  printer.print_record context.fetch(:report)
end