Class: Apicraft::Openapi::Operation

Inherits:
Object
  • Object
show all
Defined in:
lib/apicraft/openapi/operation.rb

Overview

Represents an OpenAPI operation. like GET /pets

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(operation) ⇒ Operation

Returns a new instance of Operation.



10
11
12
13
# File 'lib/apicraft/openapi/operation.rb', line 10

def initialize(operation)
  @operation = operation
  @operation_object = operation.operation_object
end

Instance Attribute Details

#operationObject

Returns the value of attribute operation.



8
9
10
# File 'lib/apicraft/openapi/operation.rb', line 8

def operation
  @operation
end

Instance Method Details

#raw_schemaObject



32
33
34
# File 'lib/apicraft/openapi/operation.rb', line 32

def raw_schema
  @operation_object.raw_schema
end

#response_for(code) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/apicraft/openapi/operation.rb', line 23

def response_for(code)
  response = responses.response[code.to_s]
  return unless response.present?

  Response.new(
    response
  )
end

#responsesObject



15
16
17
# File 'lib/apicraft/openapi/operation.rb', line 15

def responses
  @operation_object.responses
end

#summaryObject



19
20
21
# File 'lib/apicraft/openapi/operation.rb', line 19

def summary
  @operation_object.summary
end

#validate_request_body(content_type, body) ⇒ Object



36
37
38
39
40
41
# File 'lib/apicraft/openapi/operation.rb', line 36

def validate_request_body(content_type, body)
  operation.validate_request_body(
    content_type,
    body
  )
end