Class: FaradayMiddleware::OpenAPI::RequestValidator::RequestOperation

Inherits:
Object
  • Object
show all
Defined in:
lib/faraday_middleware/openapi/request_validator.rb

Instance Method Summary collapse

Constructor Details

#initialize(env:, schema_path:) ⇒ RequestOperation

Returns a new instance of RequestOperation.



31
32
33
34
# File 'lib/faraday_middleware/openapi/request_validator.rb', line 31

def initialize(env:, schema_path:)
  @env = env
  @schema_path = schema_path
end

Instance Method Details

#validate_request_bodyObject



42
43
44
45
46
# File 'lib/faraday_middleware/openapi/request_validator.rb', line 42

def validate_request_body
  request_operation.validate_request_body(content_type, request_body)
rescue OpenAPIParser::OpenAPIError => e
  raise ::FaradayMiddleware::OpenAPI::Error.new(e.message)
end

#validate_request_parameterObject



36
37
38
39
40
# File 'lib/faraday_middleware/openapi/request_validator.rb', line 36

def validate_request_parameter
  request_operation.validate_request_parameter(env.params || {}, {})
rescue OpenAPIParser::OpenAPIError => e
  raise ::FaradayMiddleware::OpenAPI::Error.new(e.message)
end