Class: OpenAPIParser::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/openapi_parser/config.rb

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Config

Returns a new instance of Config.



2
3
4
5
6
7
8
9
10
11
12
# File 'lib/openapi_parser/config.rb', line 2

def initialize(config)
  # TODO: This deprecation warning can be removed after we set the default to `true`
  # in a later (major?) version update.
  unless config.key?(:strict_reference_validation)
    msg = "[DEPRECATION] strict_reference_validation config is not set. It defaults to `false` now, " +
        "but will be `true` in a future version. Please explicitly set to `false` " +
        "if you want to skip reference validation on schema load."
    warn(msg)
  end
  @config = config
end

Instance Method Details

#coerce_valueObject



18
19
20
# File 'lib/openapi_parser/config.rb', line 18

def coerce_value
  @config[:coerce_value]
end

#datetime_coerce_classObject



14
15
16
# File 'lib/openapi_parser/config.rb', line 14

def datetime_coerce_class
  @config[:datetime_coerce_class]
end

#expand_referenceObject



22
23
24
# File 'lib/openapi_parser/config.rb', line 22

def expand_reference
  @config.fetch(:expand_reference, true)
end

#request_validator_optionsOpenAPIParser::SchemaValidator::Options Also known as: request_body_options, path_params_options



41
42
43
44
45
# File 'lib/openapi_parser/config.rb', line 41

def request_validator_options
  @request_validator_options ||= OpenAPIParser::SchemaValidator::Options.new(coerce_value: coerce_value,
                                                                             datetime_coerce_class: datetime_coerce_class,
                                                                             validate_header: validate_header)
end

#response_validate_optionsOpenAPIParser::SchemaValidator::ResponseValidateOptions



51
52
53
54
# File 'lib/openapi_parser/config.rb', line 51

def response_validate_options
  @response_validate_options ||= OpenAPIParser::SchemaValidator::ResponseValidateOptions.
                                   new(strict: strict_response_validation, validate_header: validate_header)
end

#strict_reference_validationObject



32
33
34
# File 'lib/openapi_parser/config.rb', line 32

def strict_reference_validation
  @config.fetch(:strict_reference_validation, false)
end

#strict_response_validationObject



26
27
28
29
30
# File 'lib/openapi_parser/config.rb', line 26

def strict_response_validation
  # TODO: in a major version update, change this to default to `true`.
  # https://github.com/ota42y/openapi_parser/pull/123/files#r767142217
  @config.fetch(:strict_response_validation, false)
end

#validate_headerObject



36
37
38
# File 'lib/openapi_parser/config.rb', line 36

def validate_header
  @config.fetch(:validate_header, true)
end