class Apipie::Configuration

Attributes

action_on_non_validated_keys[RW]
api_action_matcher[R]

An object that responds to a `.call(controller)` method responsible for matching the correct controller action

api_base_url[RW]
api_controllers_matcher[RW]

matcher to be used in Dir.glob to find controllers to be reloaded e.g.

"#{Rails.root}/app/controllers/api/*.rb"
api_routes[RW]

specify routes if used router differ from default e.g.

Api::Engine.routes

app_info[RW]
app_name[RW]
authenticate[RW]
authorize[RW]
cache_dir[W]
checksum_path[RW]
compress_examples[RW]
debug[RW]
default_locale[RW]
default_version[RW]
disqus_shortname[RW]
doc_base_url[RW]
doc_path[RW]
force_dsl[W]

if there is not obvious reason why the DSL should be turned on (no validations, cache turned on etc.), it's disabled to avoid unneeded allocation. It you need the DSL for other reasons, you can force the activation.

generated_doc_disclaimer[W]

comment to put before docs that was generated automatically. It's used to determine if the description should be overwritten next recording. If you want to keep the documentation (prevent from overriding), remove the line above the docs.

ignore_allow_blank_false[RW]
ignored[W]

array of controller names (strings) (might include actions as well) to be ignored # when generating the documentation e.g. %w[Api::CommentsController Api::PostsController#post]

ignored_by_recorder[W]

array of controller names (strings) (might include actions as well) to be ignored # when extracting description form calls. e.g. %w[Api::CommentsController Api::PostsController#post]

languages[RW]
layout[RW]
locale[RW]
markup[RW]
namespaced_resources[RW]
namespaced_resources?[RW]
persist_show_in_doc[RW]
process_params[RW]
record[RW]
reload_controllers[W]

set to true if you want to reload the controllers at each refresh of the documentation. It requires :api_controllers_matcher to be set to work properly.

required_by_default[RW]
required_by_default?[RW]
routes_formatter[RW]

a object responsible for transforming the routes loaded from Rails to a form to be used in the documentation, when using the `api!` keyword. By default, it's Apipie::RoutesFormatter. To customize the behaviour, one can inherit from from this class and override the methods as needed.

show_all_examples[RW]
translate[RW]
update_checksum[RW]
use_cache[RW]

set to true if you want to use pregenerated documentation cache and avoid generating the documentation on runtime (useful for production environment). You can generate the cache by running

rake apipie:cache
use_cache?[RW]

set to true if you want to use pregenerated documentation cache and avoid generating the documentation on runtime (useful for production environment). You can generate the cache by running

rake apipie:cache
validate[RW]
validate?[RW]
validate_key[RW]
validate_key?[RW]
validate_presence[RW]
validate_presence?[RW]
validate_value[RW]
validate_value?[RW]
version_in_url[RW]

Public Class Methods

new() click to toggle source
# File lib/apipie/configuration.rb, line 161
def initialize
  @markup = Apipie::Markup::RDoc.new
  @app_name = "Another API"
  @app_info = ActiveSupport::HashWithIndifferentAccess.new
  @copyright = nil
  @validate = :implicitly
  @validate_value = true
  @validate_presence = true
  @validate_key = false
  @action_on_non_validated_keys = :raise
  @required_by_default = false
  @api_base_url = ActiveSupport::HashWithIndifferentAccess.new
  @api_action_matcher = proc { |controller| controller.params[:action] }
  @doc_base_url = "/apipie"
  @layout = "apipie/apipie"
  @disqus_shortname = nil
  @default_version = "1.0"
  @debug = false
  @ignore_allow_blank_false = false
  @version_in_url = true
  @namespaced_resources = false
  @doc_path = "doc"
  @process_params = false
  @checksum_path = [@doc_base_url, '/api/']
  @update_checksum = false
  @link_extension = ".html"
  @record = false
  @languages = []
  @default_locale = 'en'
  @locale = lambda { |locale| @default_locale }
  @translate = lambda { |str, locale| str }
  @persist_show_in_doc = false
  @routes_formatter = RoutesFormatter.new
end

Public Instance Methods

api_action_matcher=(callable) click to toggle source
# File lib/apipie/configuration.rb, line 37
def api_action_matcher=(callable)
  raise 'Must implement .call method' unless callable.respond_to?(:call)

  @api_action_matcher = callable
end
api_base_url=(url) click to toggle source

set base url for default version of API to set it for specific version use config.api_base_url = url

# File lib/apipie/configuration.rb, line 152
def api_base_url=(url)
  version = Apipie.configuration.default_version
  @api_base_url[version] = url
end
app_info=(description) click to toggle source

set app description for default version to maintain backward compatibility new way: config.app_info = description

# File lib/apipie/configuration.rb, line 144
def app_info=(description)
  version = Apipie.configuration.default_version
  @app_info[version] = description
end
cache_dir() click to toggle source
# File lib/apipie/configuration.rb, line 93
def cache_dir
  @cache_dir ||= File.join(Rails.root, "public", "apipie-cache")
end
force_dsl?() click to toggle source
# File lib/apipie/configuration.rb, line 102
def force_dsl?
  @force_dsl
end
generated_doc_disclaimer() click to toggle source
# File lib/apipie/configuration.rb, line 133
def generated_doc_disclaimer
  @generated_doc_disclaimer ||= "# DOC GENERATED AUTOMATICALLY: REMOVE THIS LINE TO PREVENT REGENERATING NEXT TIME"
end
generator() click to toggle source
# File lib/apipie/configuration.rb, line 20
def generator
  Apipie::Generator::Config.instance
end
ignored() click to toggle source
# File lib/apipie/configuration.rb, line 119
def ignored
  @ignored ||= []
  @ignored.map(&:to_s)
end
ignored_by_recorder() click to toggle source
# File lib/apipie/configuration.rb, line 110
def ignored_by_recorder
  @ignored_by_recorder ||= []
  @ignored_by_recorder.map(&:to_s)
end
process_value?() click to toggle source
# File lib/apipie/configuration.rb, line 80
def process_value?
  @process_params
end
reload_controllers?() click to toggle source
# File lib/apipie/configuration.rb, line 59
def reload_controllers?
  @reload_controllers = Rails.env.development? unless defined? @reload_controllers

  @reload_controllers && @api_controllers_matcher
end
swagger() click to toggle source
# File lib/apipie/configuration.rb, line 16
def swagger
  Apipie::Generator::Swagger::Config.instance
end
use_disqus?() click to toggle source
# File lib/apipie/configuration.rb, line 137
def use_disqus?
  !@disqus_shortname.blank?
end