Class: Apipie::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/apipie/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# File 'lib/apipie/configuration.rb', line 146

def initialize
  @markup = Apipie::Markup::RDoc.new
  @app_name = "Another API"
  @app_info = HashWithIndifferentAccess.new
  @copyright = nil
  @validate = :implicitly
  @validate_value = true
  @validate_presence = true
  @validate_key = false
  @required_by_default = false
  @api_base_url = HashWithIndifferentAccess.new
  @doc_base_url = "/apipie"
  @layout = "apipie/apipie"
  @disqus_shortname = nil
  @default_version = "1.0"
  @debug = 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
  @swagger_content_type_input = :form_data  # this can be :json or :form_data
  @swagger_json_input_uses_refs = false
  @swagger_include_warning_tags = false
  @swagger_suppress_warnings = false #[105,100,102]
  @swagger_api_host = "localhost:3000"
  @swagger_generate_x_computed_id_field = false
  @swagger_allow_additional_properties_in_response = false
  @swagger_responses_use_refs = true
end

Instance Attribute Details

#api_base_urlObject

Returns the value of attribute api_base_url.



4
5
6
# File 'lib/apipie/configuration.rb', line 4

def api_base_url
  @api_base_url
end

#api_controllers_matcherObject

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

"#{Rails.root}/app/controllers/api/*.rb"


27
28
29
# File 'lib/apipie/configuration.rb', line 27

def api_controllers_matcher
  @api_controllers_matcher
end

#api_routesObject

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

Api::Engine.routes



37
38
39
# File 'lib/apipie/configuration.rb', line 37

def api_routes
  @api_routes
end

#app_infoObject

Returns the value of attribute app_info.



4
5
6
# File 'lib/apipie/configuration.rb', line 4

def app_info
  @app_info
end

#app_nameObject

Returns the value of attribute app_name.



4
5
6
# File 'lib/apipie/configuration.rb', line 4

def app_name
  @app_name
end

#authenticateObject

Returns the value of attribute authenticate.



4
5
6
# File 'lib/apipie/configuration.rb', line 4

def authenticate
  @authenticate
end

#authorizeObject

Returns the value of attribute authorize.



4
5
6
# File 'lib/apipie/configuration.rb', line 4

def authorize
  @authorize
end

#cache_dirObject



78
79
80
# File 'lib/apipie/configuration.rb', line 78

def cache_dir
  @cache_dir ||= File.join(Rails.root, "public", "apipie-cache")
end

#checksum_pathObject

Returns the value of attribute checksum_path.



4
5
6
# File 'lib/apipie/configuration.rb', line 4

def checksum_path
  @checksum_path
end

#compress_examplesObject

Returns the value of attribute compress_examples.



4
5
6
# File 'lib/apipie/configuration.rb', line 4

def compress_examples
  @compress_examples
end

Returns the value of attribute copyright.



4
5
6
# File 'lib/apipie/configuration.rb', line 4

def copyright
  @copyright
end

#debugObject

Returns the value of attribute debug.



4
5
6
# File 'lib/apipie/configuration.rb', line 4

def debug
  @debug
end

#default_localeObject

Returns the value of attribute default_locale.



4
5
6
# File 'lib/apipie/configuration.rb', line 4

def default_locale
  @default_locale
end

#default_versionObject

Returns the value of attribute default_version.



4
5
6
# File 'lib/apipie/configuration.rb', line 4

def default_version
  @default_version
end

#disqus_shortnameObject

Returns the value of attribute disqus_shortname.



4
5
6
# File 'lib/apipie/configuration.rb', line 4

def disqus_shortname
  @disqus_shortname
end

#doc_base_urlObject

Returns the value of attribute doc_base_url.



4
5
6
# File 'lib/apipie/configuration.rb', line 4

def doc_base_url
  @doc_base_url
end

#doc_pathObject

Returns the value of attribute doc_path.



4
5
6
# File 'lib/apipie/configuration.rb', line 4

def doc_path
  @doc_path
end

#force_dsl=(value) ⇒ Object (writeonly)

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.



86
87
88
# File 'lib/apipie/configuration.rb', line 86

def force_dsl=(value)
  @force_dsl = value
end

#generated_doc_disclaimerObject



118
119
120
# File 'lib/apipie/configuration.rb', line 118

def generated_doc_disclaimer
  @generated_doc_disclaimer ||= "# DOC GENERATED AUTOMATICALLY: REMOVE THIS LINE TO PREVENT REGENERATING NEXT TIME"
end

#ignoredObject



104
105
106
107
# File 'lib/apipie/configuration.rb', line 104

def ignored
  @ignored ||= []
  @ignored.map(&:to_s)
end

#ignored_by_recorderObject



95
96
97
98
# File 'lib/apipie/configuration.rb', line 95

def ignored_by_recorder
  @ignored_by_recorder ||= []
  @ignored_by_recorder.map(&:to_s)
end

#languagesObject

Returns the value of attribute languages.



4
5
6
# File 'lib/apipie/configuration.rb', line 4

def languages
  @languages
end

#layoutObject

Returns the value of attribute layout.



4
5
6
# File 'lib/apipie/configuration.rb', line 4

def layout
  @layout
end

Returns the value of attribute link_extension.



4
5
6
# File 'lib/apipie/configuration.rb', line 4

def link_extension
  @link_extension
end

#localeObject

Returns the value of attribute locale.



4
5
6
# File 'lib/apipie/configuration.rb', line 4

def locale
  @locale
end

#markupObject

Returns the value of attribute markup.



4
5
6
# File 'lib/apipie/configuration.rb', line 4

def markup
  @markup
end

#namespaced_resourcesObject Also known as: namespaced_resources?

Returns the value of attribute namespaced_resources.



4
5
6
# File 'lib/apipie/configuration.rb', line 4

def namespaced_resources
  @namespaced_resources
end

#persist_show_in_docObject

Returns the value of attribute persist_show_in_doc.



4
5
6
# File 'lib/apipie/configuration.rb', line 4

def persist_show_in_doc
  @persist_show_in_doc
end

#process_paramsObject

Returns the value of attribute process_params.



4
5
6
# File 'lib/apipie/configuration.rb', line 4

def process_params
  @process_params
end

#recordObject

Returns the value of attribute record.



4
5
6
# File 'lib/apipie/configuration.rb', line 4

def record
  @record
end

#reload_controllers=(value) ⇒ Object (writeonly)

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.



32
33
34
# File 'lib/apipie/configuration.rb', line 32

def reload_controllers=(value)
  @reload_controllers = value
end

#required_by_defaultObject Also known as: required_by_default?

Returns the value of attribute required_by_default.



4
5
6
# File 'lib/apipie/configuration.rb', line 4

def required_by_default
  @required_by_default
end

#routes_formatterObject

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.



43
44
45
# File 'lib/apipie/configuration.rb', line 43

def routes_formatter
  @routes_formatter
end

#show_all_examplesObject

Returns the value of attribute show_all_examples.



4
5
6
# File 'lib/apipie/configuration.rb', line 4

def show_all_examples
  @show_all_examples
end

#swagger_allow_additional_properties_in_responseObject

Returns the value of attribute swagger_allow_additional_properties_in_response.



4
5
6
# File 'lib/apipie/configuration.rb', line 4

def swagger_allow_additional_properties_in_response
  @swagger_allow_additional_properties_in_response
end

#swagger_api_hostObject

Returns the value of attribute swagger_api_host.



4
5
6
# File 'lib/apipie/configuration.rb', line 4

def swagger_api_host
  @swagger_api_host
end

#swagger_content_type_inputObject

Returns the value of attribute swagger_content_type_input.



4
5
6
# File 'lib/apipie/configuration.rb', line 4

def swagger_content_type_input
  @swagger_content_type_input
end

#swagger_generate_x_computed_id_fieldObject Also known as: swagger_generate_x_computed_id_field?

Returns the value of attribute swagger_generate_x_computed_id_field.



4
5
6
# File 'lib/apipie/configuration.rb', line 4

def swagger_generate_x_computed_id_field
  @swagger_generate_x_computed_id_field
end

#swagger_include_warning_tagsObject Also known as: swagger_include_warning_tags?

Returns the value of attribute swagger_include_warning_tags.



4
5
6
# File 'lib/apipie/configuration.rb', line 4

def swagger_include_warning_tags
  @swagger_include_warning_tags
end

#swagger_json_input_uses_refsObject Also known as: swagger_json_input_uses_refs?

Returns the value of attribute swagger_json_input_uses_refs.



4
5
6
# File 'lib/apipie/configuration.rb', line 4

def swagger_json_input_uses_refs
  @swagger_json_input_uses_refs
end

#swagger_responses_use_refsObject Also known as: swagger_responses_use_refs?

Returns the value of attribute swagger_responses_use_refs.



4
5
6
# File 'lib/apipie/configuration.rb', line 4

def swagger_responses_use_refs
  @swagger_responses_use_refs
end

#swagger_suppress_warningsObject

Returns the value of attribute swagger_suppress_warnings.



4
5
6
# File 'lib/apipie/configuration.rb', line 4

def swagger_suppress_warnings
  @swagger_suppress_warnings
end

#translateObject

Returns the value of attribute translate.



4
5
6
# File 'lib/apipie/configuration.rb', line 4

def translate
  @translate
end

#update_checksumObject

Returns the value of attribute update_checksum.



4
5
6
# File 'lib/apipie/configuration.rb', line 4

def update_checksum
  @update_checksum
end

#use_cacheObject Also known as: use_cache?

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

rake apipie:cache


74
75
76
# File 'lib/apipie/configuration.rb', line 74

def use_cache
  @use_cache
end

#validateObject Also known as: validate?

Returns the value of attribute validate.



4
5
6
# File 'lib/apipie/configuration.rb', line 4

def validate
  @validate
end

#validate_keyObject Also known as: validate_key?

Returns the value of attribute validate_key.



4
5
6
# File 'lib/apipie/configuration.rb', line 4

def validate_key
  @validate_key
end

#validate_presenceObject Also known as: validate_presence?

Returns the value of attribute validate_presence.



4
5
6
# File 'lib/apipie/configuration.rb', line 4

def validate_presence
  @validate_presence
end

#validate_valueObject Also known as: validate_value?

Returns the value of attribute validate_value.



4
5
6
# File 'lib/apipie/configuration.rb', line 4

def validate_value
  @validate_value
end

#version_in_urlObject

Returns the value of attribute version_in_url.



4
5
6
# File 'lib/apipie/configuration.rb', line 4

def version_in_url
  @version_in_url
end

Instance Method Details

#force_dsl?Boolean

Returns:

  • (Boolean)


87
88
89
# File 'lib/apipie/configuration.rb', line 87

def force_dsl?
  @force_dsl
end

#process_value?Boolean

Returns:

  • (Boolean)


65
66
67
# File 'lib/apipie/configuration.rb', line 65

def process_value?
  @process_params
end

#reload_controllers?Boolean

Returns:

  • (Boolean)


45
46
47
48
# File 'lib/apipie/configuration.rb', line 45

def reload_controllers?
  @reload_controllers = Rails.env.development? unless defined? @reload_controllers
  return @reload_controllers && @api_controllers_matcher
end

#use_disqus?Boolean

Returns:

  • (Boolean)


122
123
124
# File 'lib/apipie/configuration.rb', line 122

def use_disqus?
  !@disqus_shortname.blank?
end