Class: GrapeOAS::ApiModelBuilders::Operation
- Inherits:
-
Object
- Object
- GrapeOAS::ApiModelBuilders::Operation
- Defined in:
- lib/grape_oas/api_model_builders/operation.rb
Constant Summary
Constants included from Concerns::OasUtilities
Concerns::OasUtilities::VALID_CONSTANT_PATTERN
Instance Attribute Summary collapse
-
#api ⇒ Object
readonly
Returns the value of attribute api.
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#path_param_name_map ⇒ Object
readonly
Returns the value of attribute path_param_name_map.
-
#route ⇒ Object
readonly
Returns the value of attribute route.
-
#template_override ⇒ Object
readonly
Returns the value of attribute template_override.
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(api:, route:, app: nil, path_param_name_map: nil, template_override: nil) ⇒ Operation
constructor
A new instance of Operation.
Methods included from Concerns::OasUtilities
extract_extensions, #extract_extensions, pluralize, #pluralize, underscore, #underscore, valid_constant_name?, #valid_constant_name?
Constructor Details
#initialize(api:, route:, app: nil, path_param_name_map: nil, template_override: nil) ⇒ Operation
Returns a new instance of Operation.
11 12 13 14 15 16 17 |
# File 'lib/grape_oas/api_model_builders/operation.rb', line 11 def initialize(api:, route:, app: nil, path_param_name_map: nil, template_override: nil) @api = api @route = route @app = app @path_param_name_map = path_param_name_map || {} @template_override = template_override end |
Instance Attribute Details
#api ⇒ Object (readonly)
Returns the value of attribute api.
9 10 11 |
# File 'lib/grape_oas/api_model_builders/operation.rb', line 9 def api @api end |
#app ⇒ Object (readonly)
Returns the value of attribute app.
9 10 11 |
# File 'lib/grape_oas/api_model_builders/operation.rb', line 9 def app @app end |
#path_param_name_map ⇒ Object (readonly)
Returns the value of attribute path_param_name_map.
9 10 11 |
# File 'lib/grape_oas/api_model_builders/operation.rb', line 9 def path_param_name_map @path_param_name_map end |
#route ⇒ Object (readonly)
Returns the value of attribute route.
9 10 11 |
# File 'lib/grape_oas/api_model_builders/operation.rb', line 9 def route @route end |
#template_override ⇒ Object (readonly)
Returns the value of attribute template_override.
9 10 11 |
# File 'lib/grape_oas/api_model_builders/operation.rb', line 9 def template_override @template_override end |
Instance Method Details
#build ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/grape_oas/api_model_builders/operation.rb', line 19 def build operation = GrapeOAS::ApiModel::Operation.new( http_method: http_method, operation_id: operation_id, summary: route.[:description], description: build_description, tag_names: tag_names, extensions: operation_extensions, consumes: consumes, produces: produces, deprecated: build_deprecated, ) operation.suppress_default_error_response = build_suppress_default_error_response api.(*tag_names) if tag_names.any? build_request(operation) build_responses.each { |resp| operation.add_response(resp) } ensure_path_parameters(operation) operation.security = build_security if build_security operation end |