Class: Committee::SchemaValidator::OpenAPI3
- Inherits:
-
Object
- Object
- Committee::SchemaValidator::OpenAPI3
show all
- Defined in:
- lib/committee/schema_validator/open_api_3.rb
Defined Under Namespace
Classes: OperationWrapper, RequestValidator, ResponseValidator, Router
Instance Method Summary
collapse
Constructor Details
#initialize(router, request, validator_option) ⇒ OpenAPI3
Returns a new instance of OpenAPI3.
4
5
6
7
8
9
|
# File 'lib/committee/schema_validator/open_api_3.rb', line 4
def initialize(router, request, validator_option)
@router = router
@request = request
@operation_object = router.operation_object(request)
@validator_option = validator_option
end
|
Instance Method Details
40
41
42
|
# File 'lib/committee/schema_validator/open_api_3.rb', line 40
def coerce_form_params(_parameter)
end
|
#link_exist? ⇒ Boolean
36
37
38
|
# File 'lib/committee/schema_validator/open_api_3.rb', line 36
def link_exist?
!@operation_object.nil?
end
|
#request_validate(request) ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/committee/schema_validator/open_api_3.rb', line 11
def request_validate(request)
path_params = validator_option.coerce_path_params ? coerce_path_params : {}
request_unpack(request)
request.env[validator_option.params_key]&.merge!(path_params) unless path_params.empty?
request_schema_validation(request)
copy_coerced_data_to_query_hash(request)
end
|
#response_validate(status, headers, response, test_method = false) ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/committee/schema_validator/open_api_3.rb', line 23
def response_validate(status, , response, test_method = false)
full_body = ""
response.each do |chunk|
full_body << chunk
end
data = full_body.empty? ? {} : JSON.parse(full_body)
strict = test_method
Committee::SchemaValidator::OpenAPI3::ResponseValidator.
new(@operation_object, validator_option).
call(status, , data, strict)
end
|