Class: OasCore::Configuration
- Inherits:
-
Object
- Object
- OasCore::Configuration
- Defined in:
- lib/oas_core/configuration.rb
Instance Attribute Summary collapse
-
#api_path ⇒ Object
Returns the value of attribute api_path.
-
#authenticate_all_routes_by_default ⇒ Object
Returns the value of attribute authenticate_all_routes_by_default.
-
#default_tags_from ⇒ Object
Returns the value of attribute default_tags_from.
-
#http_verbs ⇒ Object
Returns the value of attribute http_verbs.
-
#info ⇒ Object
Returns the value of attribute info.
-
#possible_default_responses ⇒ Object
Returns the value of attribute possible_default_responses.
-
#response_body_of_default ⇒ Object
Returns the value of attribute response_body_of_default.
-
#security_schema ⇒ Object
Returns the value of attribute security_schema.
-
#security_schemas ⇒ Object
Returns the value of attribute security_schemas.
-
#servers ⇒ Object
Returns the value of attribute servers.
-
#set_default_responses ⇒ Object
Returns the value of attribute set_default_responses.
-
#tags ⇒ Object
Returns the value of attribute tags.
Instance Method Summary collapse
- #default_servers ⇒ Object
-
#initialize(**args) ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize(**args) ⇒ Configuration
Returns a new instance of Configuration.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/oas_core/configuration.rb', line 16 def initialize(**args) @info = args.fetch(:info, Spec::Info.new) @servers = args.fetch(:servers, default_servers) = [] @swagger_version = '3.1.0' = :namespace @api_path = '/' @authenticate_all_routes_by_default = true @security_schema = nil @security_schemas = {} @set_default_responses = true @possible_default_responses = i[not_found forbidden internal_server_error unprocessable_entity] @http_verbs = i[get post put patch delete] @response_body_of_default = 'Hash{ status: !Integer, error: String }' @possible_default_responses.each do |response| method_name = "response_body_of_#{response}=" variable_name = "@response_body_of_#{response}" define_singleton_method(method_name) do |value| raise ArgumentError, "#{method_name} must be a String With a valid object" unless value.is_a?(String) OasCore::JsonSchemaGenerator.parse_type(value) instance_variable_set(variable_name, value) end define_singleton_method("response_body_of_#{response}") do instance_variable_get(variable_name) || @response_body_of_default end end end |
Instance Attribute Details
#api_path ⇒ Object
Returns the value of attribute api_path.
5 6 7 |
# File 'lib/oas_core/configuration.rb', line 5 def api_path @api_path end |
#authenticate_all_routes_by_default ⇒ Object
Returns the value of attribute authenticate_all_routes_by_default.
5 6 7 |
# File 'lib/oas_core/configuration.rb', line 5 def authenticate_all_routes_by_default @authenticate_all_routes_by_default end |
#default_tags_from ⇒ Object
Returns the value of attribute default_tags_from.
5 6 7 |
# File 'lib/oas_core/configuration.rb', line 5 def end |
#http_verbs ⇒ Object
Returns the value of attribute http_verbs.
5 6 7 |
# File 'lib/oas_core/configuration.rb', line 5 def http_verbs @http_verbs end |
#info ⇒ Object
Returns the value of attribute info.
5 6 7 |
# File 'lib/oas_core/configuration.rb', line 5 def info @info end |
#possible_default_responses ⇒ Object
Returns the value of attribute possible_default_responses.
5 6 7 |
# File 'lib/oas_core/configuration.rb', line 5 def possible_default_responses @possible_default_responses end |
#response_body_of_default ⇒ Object
Returns the value of attribute response_body_of_default.
14 15 16 |
# File 'lib/oas_core/configuration.rb', line 14 def response_body_of_default @response_body_of_default end |
#security_schema ⇒ Object
Returns the value of attribute security_schema.
14 15 16 |
# File 'lib/oas_core/configuration.rb', line 14 def security_schema @security_schema end |
#security_schemas ⇒ Object
Returns the value of attribute security_schemas.
5 6 7 |
# File 'lib/oas_core/configuration.rb', line 5 def security_schemas @security_schemas end |
#servers ⇒ Object
Returns the value of attribute servers.
14 15 16 |
# File 'lib/oas_core/configuration.rb', line 14 def servers @servers end |
#set_default_responses ⇒ Object
Returns the value of attribute set_default_responses.
5 6 7 |
# File 'lib/oas_core/configuration.rb', line 5 def set_default_responses @set_default_responses end |
#tags ⇒ Object
Returns the value of attribute tags.
14 15 16 |
# File 'lib/oas_core/configuration.rb', line 14 def end |
Instance Method Details
#default_servers ⇒ Object
55 56 57 |
# File 'lib/oas_core/configuration.rb', line 55 def default_servers [Spec::Server.new(url: 'http://localhost:3000', description: 'Development Server')] end |