11
12
13
14
15
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
|
# File 'lib/openapi_ruby/middleware/installer.rb', line 11
def install!(stack, root: OpenapiRuby.app_root)
config = OpenapiRuby.configuration
return if ENV["OPENAPI_RUBY_GENERATING"]
return if config.request_validation == :disabled && config.response_validation == :disabled
config.schemas.each do |name, schema_config|
schema_path = resolve_schema_path(config, name, root)
next unless schema_path && File.exist?(schema_path)
resolver = SchemaResolver.new(
spec_path: schema_path,
strict_reference_validation: config.strict_reference_validation
)
prefix = schema_config[:prefix]
if config.request_validation != :disabled
stack.use RequestValidation,
schema_resolver: resolver,
mode: config.request_validation,
prefix: prefix
end
if config.response_validation != :disabled
stack.use ResponseValidation,
schema_resolver: resolver,
mode: config.response_validation,
prefix: prefix
end
end
end
|