Class: Docit::Operation

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

Overview

Represents the documentation for a single controller action. Created by swagger_doc and stored in the Registry.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(controller:, action:) ⇒ Operation

Returns a new instance of Operation.



11
12
13
14
15
16
17
18
19
20
# File 'lib/docit/operation.rb', line 11

def initialize(controller:, action:)
  @controller = controller
  @action = action.to_s
  @_tags = []
  @_responses = []
  @_parameters = Builders::ParameterBuilder.new
  @_request_body = nil
  @_security = []
  @_deprecated = false
end

Instance Attribute Details

#_deprecatedObject (readonly)

Returns the value of attribute _deprecated.



7
8
9
# File 'lib/docit/operation.rb', line 7

def _deprecated
  @_deprecated
end

#_descriptionObject (readonly)

Returns the value of attribute _description.



7
8
9
# File 'lib/docit/operation.rb', line 7

def _description
  @_description
end

#_parametersObject (readonly)

Returns the value of attribute _parameters.



7
8
9
# File 'lib/docit/operation.rb', line 7

def _parameters
  @_parameters
end

#_request_bodyObject (readonly)

Returns the value of attribute _request_body.



7
8
9
# File 'lib/docit/operation.rb', line 7

def _request_body
  @_request_body
end

#_responsesObject (readonly)

Returns the value of attribute _responses.



7
8
9
# File 'lib/docit/operation.rb', line 7

def _responses
  @_responses
end

#_securityObject (readonly)

Returns the value of attribute _security.



7
8
9
# File 'lib/docit/operation.rb', line 7

def _security
  @_security
end

#_summaryObject (readonly)

Returns the value of attribute _summary.



7
8
9
# File 'lib/docit/operation.rb', line 7

def _summary
  @_summary
end

#_tagsObject (readonly)

Returns the value of attribute _tags.



7
8
9
# File 'lib/docit/operation.rb', line 7

def _tags
  @_tags
end

#actionObject (readonly)

Returns the value of attribute action.



7
8
9
# File 'lib/docit/operation.rb', line 7

def action
  @action
end

#controllerObject (readonly)

Returns the value of attribute controller.



7
8
9
# File 'lib/docit/operation.rb', line 7

def controller
  @controller
end

Instance Method Details

#deprecated(value: true) ⇒ Object



34
35
36
# File 'lib/docit/operation.rb', line 34

def deprecated(value: true)
  @_deprecated = value
end

#description(text) ⇒ Object



26
27
28
# File 'lib/docit/operation.rb', line 26

def description(text)
  @_description = text
end

#parameter(name, location:, type: :string, required: false, description: nil, **opts) ⇒ Object



42
43
44
# File 'lib/docit/operation.rb', line 42

def parameter(name, location:, type: :string, required: false, description: nil, **opts)
  @_parameters.add(name, location: location, type: type, required: required, description: description, **opts)
end

#request_body(required: false, content_type: "application/json", &block) ⇒ Object



46
47
48
49
50
# File 'lib/docit/operation.rb', line 46

def request_body(required: false, content_type: "application/json", &block)
  builder = Builders::RequestBodyBuilder.new(required: required, content_type: content_type)
  builder.instance_eval(&block) if block_given?
  @_request_body = builder
end

#response(status, description = "", &block) ⇒ Object



52
53
54
55
56
# File 'lib/docit/operation.rb', line 52

def response(status, description = "", &block)
  builder = Builders::ResponseBuilder.new(status: status, description: description)
  builder.instance_eval(&block) if block_given?
  @_responses << builder
end

#security(scheme) ⇒ Object



38
39
40
# File 'lib/docit/operation.rb', line 38

def security(scheme)
  @_security << scheme
end

#summary(text) ⇒ Object



22
23
24
# File 'lib/docit/operation.rb', line 22

def summary(text)
  @_summary = text
end

#tags(*tags_list) ⇒ Object



30
31
32
# File 'lib/docit/operation.rb', line 30

def tags(*tags_list)
  @_tags = tags_list.flatten
end