Method: OpenapiFirst::Request#initialize

Defined in:
lib/openapi_first/request.rb

#initialize(path:, request_method:, operation_object:, parameters:, content_type:, content_schema:, required_body:, key:) ⇒ Request

rubocop:disable Metrics/MethodLength



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
# File 'lib/openapi_first/request.rb', line 14

def initialize(path:, request_method:, operation_object:,
               parameters:, content_type:, content_schema:, required_body:, key:)
  @path = path
  @request_method = request_method
  @content_type = content_type
  @content_schema = content_schema
  @operation = operation_object
  @allow_empty_content = content_type.nil? || required_body == false
  @key = key
  @request_parser = RequestParser.new(
    query_parameters: parameters.query,
    path_parameters: parameters.path,
    header_parameters: parameters.header,
    cookie_parameters: parameters.cookie,
    content_type:
  )
  @validator = RequestValidator.new(
    content_schema:,
    required_request_body: required_body == true,
    path_schema: parameters.path_schema,
    query_schema: parameters.query_schema,
    header_schema: parameters.header_schema,
    cookie_schema: parameters.cookie_schema
  )
end