Sha256: fc62f6301561b7bdb0f77d8e69fe53944af91d5d247ad661fbfb0e5786ae03c9

Contents?: true

Size: 1.49 KB

Versions: 6

Compression:

Stored size: 1.49 KB

Contents

require 'fileutils'

namespace 'dry-swagger' do
  desc 'Create a configuration file for Dry Swagger Documentation Generator'
  task :create_configuration_file do
    FileUtils.mkdir_p "#{ Dir.pwd }/config/initializers/"
    puts "Created #{ Dir.pwd }/config/initializers/dry-swagger.rb"
    File.open("#{ Dir.pwd }/config/initializers/dry-swagger.rb", "w") { |file|
file.puts 'Dry::Swagger::Config::SwaggerConfiguration.configuration do |config|
  config.enable_required_validation = true
  config.enable_nullable_validation = true
  config.enable_enums = true
  config.enable_descriptions = true
  config.nullable_type = :"x-nullable" # or :nullable
end
'
    }
  end

  desc 'Create a YAML file for Contract swagger field descriptions'
  task :create_contract_descriptions_yaml do
    FileUtils.mkdir_p "#{ Dir.pwd }/config/locales/"
    puts "Created #{ Dir.pwd }/config/locales/dry-swagger.yml"
    File.open("#{ Dir.pwd }/config/locales/dry-swagger.yml", "w") { |file|
file.puts 'en:
  contract:
    descriptions:
      eql?: "Must be equal to %{value}"
      max_size?: "Maximum size: %{value}"
      min_size?: "Minimum size: %{value}"
      gteq?: "Greater than or equal to %{value}"
      gt?: "Greater than %{value}"
      lt?: "Lower than %{value}"
      lteq?: "Lower than or equal to %{value}"
'
    }
  end

  desc 'Creates configuration files'
  task :install do
    Rake::Task['dry-swagger:create_configuration_file'].execute
    Rake::Task['dry-swagger:create_contract_descriptions_yaml'].execute
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
dry-swagger-2.0.5 lib/dry/swagger/tasks/configuration_generator.rake
dry-swagger-2.0.4 lib/dry/swagger/tasks/configuration_generator.rake
dry-swagger-2.0.3 lib/dry/swagger/tasks/configuration_generator.rake
dry-swagger-2.0.2 lib/dry/swagger/tasks/configuration_generator.rake
dry-swagger-2.0.1 lib/dry/swagger/tasks/configuration_generator.rake
dry-swagger-2.0.0 lib/dry/swagger/tasks/configuration_generator.rake