Class: TypeSpecFromSerializers::Resource
- Inherits:
-
Struct
- Object
- Struct
- TypeSpecFromSerializers::Resource
- Defined in:
- lib/typespec_from_serializers/generator.rb
Overview
Internal: Represents a TypeSpec resource interface
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#operations ⇒ Object
Returns the value of attribute operations.
-
#parent_namespace ⇒ Object
Returns the value of attribute parent_namespace.
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name
445 446 447 |
# File 'lib/typespec_from_serializers/generator.rb', line 445 def name @name end |
#operations ⇒ Object
Returns the value of attribute operations
445 446 447 |
# File 'lib/typespec_from_serializers/generator.rb', line 445 def operations @operations end |
#parent_namespace ⇒ Object
Returns the value of attribute parent_namespace
445 446 447 |
# File 'lib/typespec_from_serializers/generator.rb', line 445 def parent_namespace @parent_namespace end |
#path ⇒ Object
Returns the value of attribute path
445 446 447 |
# File 'lib/typespec_from_serializers/generator.rb', line 445 def path @path end |
Instance Method Details
#as_typespec ⇒ Object
446 447 448 449 450 451 452 453 454 455 456 457 458 |
# File 'lib/typespec_from_serializers/generator.rb', line 446 def as_typespec operations_str = operations.map { |op| " #{op.as_typespec(resource_path: path)}" }.join("\n") interface_block = <<~TSP.strip @route("#{path}") interface #{name} { #{operations_str} } TSP # Wrap in namespace if this is a nested resource parent_namespace ? wrap_in_namespace(interface_block) : interface_block end |