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.
-
#strict_reference_validation ⇒ Object
OpenAPI meta-schema validation of generated specs and middleware-loaded documents.
-
#ui_config ⇒ Object
UI (optional).
-
#ui_enabled ⇒ Object
UI (optional).
-
#ui_path ⇒ 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.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/openapi_ruby/configuration.rb', line 41 def initialize @schemas = {} @component_paths = ["app/api_components"] @component_scope_paths = {} @camelize_keys = true @request_validation = :disabled @response_validation = :disabled @coerce_params = true @schema_output_dir = "swagger" @schema_output_format = :yaml @ui_enabled = false @ui_path = "/api-docs" @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 |
#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.
25 26 27 |
# File 'lib/openapi_ruby/configuration.rb', line 25 def strict_reference_validation @strict_reference_validation end |
#ui_config ⇒ Object
UI (optional)
39 40 41 |
# File 'lib/openapi_ruby/configuration.rb', line 39 def ui_config @ui_config end |
#ui_enabled ⇒ Object
UI (optional)
39 40 41 |
# File 'lib/openapi_ruby/configuration.rb', line 39 def ui_enabled @ui_enabled end |
#ui_path ⇒ Object
UI (optional)
39 40 41 |
# File 'lib/openapi_ruby/configuration.rb', line 39 def ui_path @ui_path 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
59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/openapi_ruby/configuration.rb', line 59 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 |