Sha256: 5683860fd0725bc6b37cf2ceb96863c6e55b5b7ed19c49fa9a32b4436d88127b

Contents?: true

Size: 1.31 KB

Versions: 20

Compression:

Stored size: 1.31 KB

Contents

require 'rake'
require 'yaml'
require 'appmap/node_cli'
require 'appmap/swagger/markdown_descriptions'
require 'appmap/swagger/stable'

module AppMap
  module Swagger
    module RakeTasks
      extend self
      extend Rake::DSL

      def configuration
        AppMap.configuration
      end

      def define_tasks
        generate_swagger = lambda do |t, args|
          appmap_js = AppMap::NodeCLI.new(verbose: Rake.verbose == true)

          FileUtils.mkdir_p configuration.swagger_config.output_dir

          cmd = %w[swagger]
  
          swagger_raw, = appmap_js.command(cmd)

          gen_swagger = YAML.load(swagger_raw)
          gen_swagger_full = AppMap::Swagger::MarkdownDescriptions.new(gen_swagger).perform
          gen_swagger_stable = AppMap::Swagger::Stable.new(gen_swagger).perform
  
          swagger = configuration.swagger_config.template.merge(gen_swagger_full)
          File.write File.join(configuration.swagger_config.output_dir, 'openapi.yaml'), YAML.dump(swagger)
  
          swagger = configuration.swagger_config.template.merge(gen_swagger_stable)
          File.write File.join(configuration.swagger_config.output_dir, 'openapi_stable.yaml'), YAML.dump(swagger)  
        end

        desc configuration.swagger_config.description
        task :swagger, &generate_swagger
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
appmap-0.64.0 lib/appmap/swagger/rake_tasks.rb
appmap-0.63.0 lib/appmap/swagger/rake_tasks.rb
appmap-0.62.1 lib/appmap/swagger/rake_tasks.rb
appmap-0.62.0 lib/appmap/swagger/rake_tasks.rb
appmap-0.61.1 lib/appmap/swagger/rake_tasks.rb
appmap-0.61.0 lib/appmap/swagger/rake_tasks.rb
appmap-0.60.0 lib/appmap/swagger/rake_tasks.rb
appmap-0.59.2 lib/appmap/swagger/rake_tasks.rb
appmap-0.59.1 lib/appmap/swagger/rake_tasks.rb
appmap-0.59.0 lib/appmap/swagger/rake_tasks.rb
appmap-0.58.0 lib/appmap/swagger/rake_tasks.rb
appmap-0.57.1 lib/appmap/swagger/rake_tasks.rb
appmap-0.57.0 lib/appmap/swagger/rake_tasks.rb
appmap-0.56.0 lib/appmap/swagger/rake_tasks.rb
appmap-0.55.0 lib/appmap/swagger/rake_tasks.rb
appmap-0.54.4 lib/appmap/swagger/rake_tasks.rb
appmap-0.54.3 lib/appmap/swagger/rake_tasks.rb
appmap-0.54.2 lib/appmap/swagger/rake_tasks.rb
appmap-0.54.1 lib/appmap/swagger/rake_tasks.rb
appmap-0.54.0 lib/appmap/swagger/rake_tasks.rb