Class: TypeSpecFromSerializers::Operation
- Inherits:
-
Struct
- Object
- Struct
- TypeSpecFromSerializers::Operation
- Defined in:
- lib/typespec_from_serializers/generator.rb
Overview
Internal: Represents a TypeSpec operation within a resource
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the value of attribute action.
-
#body_params ⇒ Object
Returns the value of attribute body_params.
-
#doc ⇒ Object
Returns the value of attribute doc.
-
#method ⇒ Object
Returns the value of attribute method.
-
#path ⇒ Object
Returns the value of attribute path.
-
#path_params ⇒ Object
Returns the value of attribute path_params.
-
#response_type ⇒ Object
Returns the value of attribute response_type.
Instance Method Summary collapse
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action
473 474 475 |
# File 'lib/typespec_from_serializers/generator.rb', line 473 def action @action end |
#body_params ⇒ Object
Returns the value of attribute body_params
473 474 475 |
# File 'lib/typespec_from_serializers/generator.rb', line 473 def body_params @body_params end |
#doc ⇒ Object
Returns the value of attribute doc
473 474 475 |
# File 'lib/typespec_from_serializers/generator.rb', line 473 def doc @doc end |
#method ⇒ Object
Returns the value of attribute method
473 474 475 |
# File 'lib/typespec_from_serializers/generator.rb', line 473 def method @method end |
#path ⇒ Object
Returns the value of attribute path
473 474 475 |
# File 'lib/typespec_from_serializers/generator.rb', line 473 def path @path end |
#path_params ⇒ Object
Returns the value of attribute path_params
473 474 475 |
# File 'lib/typespec_from_serializers/generator.rb', line 473 def path_params @path_params end |
#response_type ⇒ Object
Returns the value of attribute response_type
473 474 475 |
# File 'lib/typespec_from_serializers/generator.rb', line 473 def response_type @response_type end |
Instance Method Details
#as_typespec(resource_path: nil) ⇒ Object
474 475 476 477 478 479 480 481 482 483 484 485 486 |
# File 'lib/typespec_from_serializers/generator.rb', line 474 def as_typespec(resource_path: nil) tsp_method = method.downcase operation_name = TypeSpecFromSerializers.config.action_to_operation_mapping[action] || action route_line = build_route_decorator(resource_path) doc_line = doc ? "@doc(\"#{escape_doc(doc)}\")\n " : "" # Check if we need multiline formatting single_line = build_single_line(tsp_method, operation_name) too_long_for_single_line?(single_line) ? "#{doc_line}#{multiline_format(route_line, tsp_method, operation_name)}" : "#{doc_line}#{route_line}#{single_line}" end |