Class: OpenapiRuby::Configuration
- Inherits:
-
Object
- Object
- OpenapiRuby::Configuration
- Defined in:
- lib/openapi_ruby/configuration.rb
Instance Attribute Summary collapse
-
#auto_validation_error_response ⇒ Object
Returns the value of attribute auto_validation_error_response.
-
#camelize_keys ⇒ Object
Returns the value of attribute camelize_keys.
-
#coerce_params ⇒ Object
Returns the value of attribute coerce_params.
-
#component_paths ⇒ Object
Components.
-
#component_scope_paths ⇒ Object
Returns the value of attribute component_scope_paths.
-
#coverage_enabled ⇒ Object
Coverage.
-
#coverage_report_path ⇒ Object
Returns the value of attribute coverage_report_path.
-
#error_handler ⇒ Object
Returns the value of attribute error_handler.
-
#key_transform ⇒ Object
Returns the value of attribute key_transform.
-
#request_validation ⇒ Object
Middleware (runtime validation).
-
#response_validation ⇒ Object
Returns the value of attribute response_validation.
-
#schema_output_dir ⇒ Object
Test / Generation.
-
#schema_output_format ⇒ Object
Returns the value of attribute schema_output_format.
-
#schemas ⇒ Object
Schema definitions — supports multiple schemas (e.g. public_api, admin_api) Each key maps to a hash with :info, :servers, :component_scope, :strict_mode, etc.
-
#strict_query_params ⇒ Object
Returns the value of attribute strict_query_params.
-
#strict_reference_validation ⇒ Object
Returns the value of attribute strict_reference_validation.
-
#ui_config ⇒ Object
Returns the value of attribute ui_config.
-
#ui_enabled ⇒ Object
UI (optional).
-
#ui_path ⇒ Object
Returns the value of attribute ui_path.
-
#validate_responses_in_tests ⇒ Object
Returns the value of attribute validate_responses_in_tests.
-
#validation_error_schema ⇒ Object
Returns the value of attribute validation_error_schema.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #validate! ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/openapi_ruby/configuration.rb', line 30 def initialize @schemas = {} @component_paths = ["app/api_components"] @component_scope_paths = {} @camelize_keys = true @key_transform = nil @request_validation = :disabled @response_validation = :disabled @strict_query_params = false @coerce_params = true @error_handler = nil @schema_output_dir = "swagger" @schema_output_format = :yaml @validate_responses_in_tests = true @ui_enabled = false @ui_path = "/api-docs" @ui_config = {} @strict_reference_validation = true @auto_validation_error_response = true @validation_error_schema = nil @coverage_enabled = false @coverage_report_path = "tmp/openapi_coverage.json" end |
Instance Attribute Details
#auto_validation_error_response ⇒ Object
Returns the value of attribute auto_validation_error_response.
15 16 17 |
# File 'lib/openapi_ruby/configuration.rb', line 15 def auto_validation_error_response @auto_validation_error_response end |
#camelize_keys ⇒ Object
Returns the value of attribute camelize_keys.
12 13 14 |
# File 'lib/openapi_ruby/configuration.rb', line 12 def camelize_keys @camelize_keys end |
#coerce_params ⇒ Object
Returns the value of attribute coerce_params.
12 13 14 |
# File 'lib/openapi_ruby/configuration.rb', line 12 def coerce_params @coerce_params end |
#component_paths ⇒ Object
Components
10 11 12 |
# File 'lib/openapi_ruby/configuration.rb', line 10 def component_paths @component_paths end |
#component_scope_paths ⇒ Object
Returns the value of attribute component_scope_paths.
11 12 13 |
# File 'lib/openapi_ruby/configuration.rb', line 11 def component_scope_paths @component_scope_paths end |
#coverage_enabled ⇒ Object
Coverage
28 29 30 |
# File 'lib/openapi_ruby/configuration.rb', line 28 def coverage_enabled @coverage_enabled end |
#coverage_report_path ⇒ Object
Returns the value of attribute coverage_report_path.
12 13 14 |
# File 'lib/openapi_ruby/configuration.rb', line 12 def coverage_report_path @coverage_report_path end |
#error_handler ⇒ Object
Returns the value of attribute error_handler.
12 13 14 |
# File 'lib/openapi_ruby/configuration.rb', line 12 def error_handler @error_handler end |
#key_transform ⇒ Object
Returns the value of attribute key_transform.
12 13 14 |
# File 'lib/openapi_ruby/configuration.rb', line 12 def key_transform @key_transform end |
#request_validation ⇒ Object
Middleware (runtime validation)
19 20 21 |
# File 'lib/openapi_ruby/configuration.rb', line 19 def request_validation @request_validation end |
#response_validation ⇒ Object
Returns the value of attribute response_validation.
12 13 14 |
# File 'lib/openapi_ruby/configuration.rb', line 12 def response_validation @response_validation end |
#schema_output_dir ⇒ Object
Test / Generation
22 23 24 |
# File 'lib/openapi_ruby/configuration.rb', line 22 def schema_output_dir @schema_output_dir end |
#schema_output_format ⇒ Object
Returns the value of attribute schema_output_format.
12 13 14 |
# File 'lib/openapi_ruby/configuration.rb', line 12 def schema_output_format @schema_output_format end |
#schemas ⇒ Object
Schema definitions — supports multiple schemas (e.g. public_api, admin_api) Each key maps to a hash with :info, :servers, :component_scope, :strict_mode, etc.
7 8 9 |
# File 'lib/openapi_ruby/configuration.rb', line 7 def schemas @schemas end |
#strict_query_params ⇒ Object
Returns the value of attribute strict_query_params.
12 13 14 |
# File 'lib/openapi_ruby/configuration.rb', line 12 def strict_query_params @strict_query_params end |
#strict_reference_validation ⇒ Object
Returns the value of attribute strict_reference_validation.
14 15 16 |
# File 'lib/openapi_ruby/configuration.rb', line 14 def strict_reference_validation @strict_reference_validation end |
#ui_config ⇒ Object
Returns the value of attribute ui_config.
12 13 14 |
# File 'lib/openapi_ruby/configuration.rb', line 12 def ui_config @ui_config end |
#ui_enabled ⇒ Object
UI (optional)
25 26 27 |
# File 'lib/openapi_ruby/configuration.rb', line 25 def ui_enabled @ui_enabled end |
#ui_path ⇒ Object
Returns the value of attribute ui_path.
12 13 14 |
# File 'lib/openapi_ruby/configuration.rb', line 12 def ui_path @ui_path end |
#validate_responses_in_tests ⇒ Object
Returns the value of attribute validate_responses_in_tests.
12 13 14 |
# File 'lib/openapi_ruby/configuration.rb', line 12 def validate_responses_in_tests @validate_responses_in_tests end |
#validation_error_schema ⇒ Object
Returns the value of attribute validation_error_schema.
16 17 18 |
# File 'lib/openapi_ruby/configuration.rb', line 16 def validation_error_schema @validation_error_schema end |
Instance Method Details
#validate! ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/openapi_ruby/configuration.rb', line 54 def validate! unless %i[disabled enabled warn_only].include?(@request_validation) raise ConfigurationError, "request_validation must be :disabled, :enabled, or :warn_only" end unless %i[disabled enabled warn_only].include?(@response_validation) raise ConfigurationError, "response_validation must be :disabled, :enabled, or :warn_only" end return if %i[yaml json].include?(@schema_output_format) raise ConfigurationError, "schema_output_format must be :yaml or :json" end |