Module: Committee::SchemaValidator
- Defined in:
- lib/committee/schema_validator.rb,
lib/committee/schema_validator/option.rb,
lib/committee/schema_validator/open_api_3.rb,
lib/committee/schema_validator/hyper_schema.rb,
lib/committee/schema_validator/open_api_3/router.rb,
lib/committee/schema_validator/hyper_schema/router.rb,
lib/committee/schema_validator/open_api_3/operation_wrapper.rb,
lib/committee/schema_validator/open_api_3/request_validator.rb,
lib/committee/schema_validator/open_api_3/response_validator.rb,
lib/committee/schema_validator/hyper_schema/parameter_coercer.rb,
lib/committee/schema_validator/hyper_schema/request_validator.rb,
lib/committee/schema_validator/hyper_schema/response_generator.rb,
lib/committee/schema_validator/hyper_schema/response_validator.rb,
lib/committee/schema_validator/open_api_3/parameter_deserializer.rb,
lib/committee/schema_validator/hyper_schema/string_params_coercer.rb
Defined Under Namespace
Classes: HyperSchema, OpenAPI3, Option
Constant Summary
collapse
- JSON_MEDIA_TYPE_PATTERN =
%r{\Aapplication/(?:.+\+)?json\z}.freeze
Class Method Summary
collapse
Class Method Details
.build_prefix_regexp(prefix) ⇒ Regexp
19
20
21
22
23
24
25
26
27
|
# File 'lib/committee/schema_validator.rb', line 19
def build_prefix_regexp(prefix)
return nil unless prefix
if prefix == "/" || prefix.end_with?("/")
/\A#{Regexp.escape(prefix)}/.freeze
else
/\A#{Regexp.escape(prefix)}(?=\/|\z)/.freeze
end
end
|
12
13
14
15
|
# File 'lib/committee/schema_validator.rb', line 12
def json_media_type?(content_type)
normalized_content_type = Rack::MediaType.type(content_type)
normalized_content_type&.match?(JSON_MEDIA_TYPE_PATTERN) || false
end
|
8
9
10
|
# File 'lib/committee/schema_validator.rb', line 8
def request_media_type(request)
Rack::MediaType.type(request.env['CONTENT_TYPE'])
end
|