Class: Gitlab::GrapeOpenapi::Converters::OperationConverter

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/grape_openapi/converters/operation_converter.rb

Constant Summary collapse

DASH_SEGMENT =
'Dash'

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(route, schema_registry, request_body_registry, inherited_path_params: {}) ⇒ OperationConverter

Returns a new instance of OperationConverter.



20
21
22
23
24
25
26
27
28
29
# File 'lib/gitlab/grape_openapi/converters/operation_converter.rb', line 20

def initialize(route, schema_registry, request_body_registry, inherited_path_params: {})
  @route = route
  @schema_registry = schema_registry
  @request_body_registry = request_body_registry
  @inherited_path_params = inherited_path_params
  @config = Gitlab::GrapeOpenapi.configuration
  @options = route.options
  @pattern = route.pattern
  @endpoint = route.app
end

Class Method Details

.convert(route, schema_registry, request_body_registry, inherited_path_params: {}) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/gitlab/grape_openapi/converters/operation_converter.rb', line 11

def self.convert(route, schema_registry, request_body_registry, inherited_path_params: {})
  new(
    route,
    schema_registry,
    request_body_registry,
    inherited_path_params: inherited_path_params
  ).convert
end

Instance Method Details

#convertObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/gitlab/grape_openapi/converters/operation_converter.rb', line 31

def convert
  Models::Operation.new.tap do |operation|
    operation.operation_id = operation_id
    operation.summary = extract_description
    operation.description = extract_detail
    operation.tags = extract_tags
    operation.deprecated = extract_deprecated
    operation.hidden = extract_hidden
    operation.parameters = extract_parameters
    operation.responses = ResponseConverter.new(@route, @schema_registry).convert
    operation.request_body = extract_request_body || {}
    operation.annotations = extract_annotations
  end
end