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
Output / formatting.
-
#coerce_params ⇒ Object
Middleware (runtime validation).
-
#component_paths ⇒ Object
Components.
-
#component_scope_paths ⇒ Object
Returns the value of attribute component_scope_paths.
-
#request_validation ⇒ Object
Middleware (runtime validation).
-
#response_validation ⇒ Object
Middleware (runtime validation).
-
#schema_output_dir ⇒ Object
Output / formatting.
-
#schema_output_format ⇒ Object
Output / formatting.
-
#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.
-
#single_api_path_per_class ⇒ Object
Style 2 only: require each test class to declare a single api_path.
-
#strict_reference_validation ⇒ Object
OpenAPI meta-schema validation of generated specs and middleware-loaded documents.
-
#test_request_validation ⇒ Object
Test DSL: validate that requests match the declared operation before sending.
-
#ui_config ⇒ Object
UI (optional).
-
#ui_enabled ⇒ Object
UI (optional).
-
#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.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/openapi_ruby/configuration.rb', line 51 def initialize @schemas = {} @component_paths = ["app/api_components"] @component_scope_paths = {} @camelize_keys = true @request_validation = :disabled @response_validation = :disabled @coerce_params = true @test_request_validation = true @single_api_path_per_class = false @schema_output_dir = "openapi" @schema_output_format = :yaml @ui_enabled = false @ui_config = {} @strict_reference_validation = :warn_only @auto_validation_error_response = true @validation_error_schema = nil 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
Output / formatting
14 15 16 |
# File 'lib/openapi_ruby/configuration.rb', line 14 def camelize_keys @camelize_keys end |
#coerce_params ⇒ Object
Middleware (runtime validation)
19 20 21 |
# File 'lib/openapi_ruby/configuration.rb', line 19 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 |
#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
Middleware (runtime validation)
19 20 21 |
# File 'lib/openapi_ruby/configuration.rb', line 19 def response_validation @response_validation end |
#schema_output_dir ⇒ Object
Output / formatting
14 15 16 |
# File 'lib/openapi_ruby/configuration.rb', line 14 def schema_output_dir @schema_output_dir end |
#schema_output_format ⇒ Object
Output / formatting
14 15 16 |
# File 'lib/openapi_ruby/configuration.rb', line 14 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 |
#single_api_path_per_class ⇒ Object
Style 2 only: require each test class to declare a single api_path. Off by default — resolution handles more than one path per class, so this is for suites that want the convention enforced anyway. See Adapters::ContextResolution for how a request is matched.
25 26 27 |
# File 'lib/openapi_ruby/configuration.rb', line 25 def single_api_path_per_class @single_api_path_per_class end |
#strict_reference_validation ⇒ Object
OpenAPI meta-schema validation of generated specs and middleware-loaded
documents. One of :disabled, :enabled (raise on errors), :warn_only
(default, log warnings). Boolean values are accepted for backwards
compatibility: true → :warn_only, false → :disabled.
35 36 37 |
# File 'lib/openapi_ruby/configuration.rb', line 35 def strict_reference_validation @strict_reference_validation end |
#test_request_validation ⇒ Object
Test DSL: validate that requests match the declared operation before sending. Enabled by default; set to false to disable.
29 30 31 |
# File 'lib/openapi_ruby/configuration.rb', line 29 def test_request_validation @test_request_validation end |
#ui_config ⇒ Object
UI (optional)
49 50 51 |
# File 'lib/openapi_ruby/configuration.rb', line 49 def ui_config @ui_config end |
#ui_enabled ⇒ Object
UI (optional)
49 50 51 |
# File 'lib/openapi_ruby/configuration.rb', line 49 def ui_enabled @ui_enabled 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
70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/openapi_ruby/configuration.rb', line 70 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 |