Class: Docit::Operation
- Inherits:
-
Object
- Object
- Docit::Operation
- 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
-
#_deprecated ⇒ Object
readonly
Returns the value of attribute _deprecated.
-
#_description ⇒ Object
readonly
Returns the value of attribute _description.
-
#_parameters ⇒ Object
readonly
Returns the value of attribute _parameters.
-
#_request_body ⇒ Object
readonly
Returns the value of attribute _request_body.
-
#_responses ⇒ Object
readonly
Returns the value of attribute _responses.
-
#_security ⇒ Object
readonly
Returns the value of attribute _security.
-
#_summary ⇒ Object
readonly
Returns the value of attribute _summary.
-
#_tags ⇒ Object
readonly
Returns the value of attribute _tags.
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#controller ⇒ Object
readonly
Returns the value of attribute controller.
Instance Method Summary collapse
- #deprecated(value: true) ⇒ Object
- #description(text) ⇒ Object
-
#initialize(controller:, action:) ⇒ Operation
constructor
A new instance of Operation.
- #parameter(name, location:, type: :string, required: false, description: nil, **opts) ⇒ Object
- #request_body(required: false, content_type: "application/json", &block) ⇒ Object
- #response(status, description = "", &block) ⇒ Object
- #security(scheme) ⇒ Object
- #summary(text) ⇒ Object
- #tags(*tags_list) ⇒ Object
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
#_deprecated ⇒ Object (readonly)
Returns the value of attribute _deprecated.
7 8 9 |
# File 'lib/docit/operation.rb', line 7 def _deprecated @_deprecated end |
#_description ⇒ Object (readonly)
Returns the value of attribute _description.
7 8 9 |
# File 'lib/docit/operation.rb', line 7 def _description @_description end |
#_parameters ⇒ Object (readonly)
Returns the value of attribute _parameters.
7 8 9 |
# File 'lib/docit/operation.rb', line 7 def _parameters @_parameters end |
#_request_body ⇒ Object (readonly)
Returns the value of attribute _request_body.
7 8 9 |
# File 'lib/docit/operation.rb', line 7 def _request_body @_request_body end |
#_responses ⇒ Object (readonly)
Returns the value of attribute _responses.
7 8 9 |
# File 'lib/docit/operation.rb', line 7 def _responses @_responses end |
#_security ⇒ Object (readonly)
Returns the value of attribute _security.
7 8 9 |
# File 'lib/docit/operation.rb', line 7 def _security @_security end |
#_summary ⇒ Object (readonly)
Returns the value of attribute _summary.
7 8 9 |
# File 'lib/docit/operation.rb', line 7 def _summary @_summary end |
#_tags ⇒ Object (readonly)
Returns the value of attribute _tags.
7 8 9 |
# File 'lib/docit/operation.rb', line 7 def @_tags end |
#action ⇒ Object (readonly)
Returns the value of attribute action.
7 8 9 |
# File 'lib/docit/operation.rb', line 7 def action @action end |
#controller ⇒ Object (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 = .flatten end |