Class: Synthra::Parser::AST::ApiDefinitionNode

Inherits:
Node
  • Object
show all
Defined in:
lib/synthra/parser/ast.rb

Overview

API definition node

Represents an API endpoint definition with HTTP method, path, and response scenarios.

Examples:

DSL

api GET /users:
  scenario Success:
    @status 200
    users: schema(:User).array

AST

ApiDefinitionNode.new(
  method: :get,
  path: "/users",
  scenarios: [ScenarioNode.new(...)]
)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method:, path:, scenarios: [], line: nil) ⇒ ApiDefinitionNode

Create a new ApiDefinitionNode

Parameters:

  • method (Symbol)

    HTTP method (:get, :post, etc.)

  • path (String)

    URL path

  • scenarios (Array<ScenarioNode>) (defaults to: [])

    response scenarios

  • line (Integer, nil) (defaults to: nil)

    source line number



895
896
897
898
899
900
# File 'lib/synthra/parser/ast.rb', line 895

def initialize(method:, path:, scenarios: [], line: nil)
  super(line: line)
  @method = method
  @path = path
  @scenarios = scenarios
end

Instance Attribute Details

#methodObject (readonly)

Returns the value of attribute method.



873
874
875
# File 'lib/synthra/parser/ast.rb', line 873

def method
  @method
end

#pathObject (readonly)

Returns the value of attribute path.



879
880
881
# File 'lib/synthra/parser/ast.rb', line 879

def path
  @path
end

#scenariosObject (readonly)

Returns the value of attribute scenarios.



885
886
887
# File 'lib/synthra/parser/ast.rb', line 885

def scenarios
  @scenarios
end