View Source ExOpenAI.Codegen.FunctionBodyGenerator (ex_openai.ex v2.0.0-beta2)
Generates function body AST for OpenAPI operations.
This module is primarily exercised via unit tests and mirrors the
high‑level behaviour documented in docs/parsingv2.md:
- Replaces path parameters in the URL using
String.replace/3 - Builds query strings from
optsusingURI.encode_www_form/1 - Collects body parameters from the non‑
optsfunction arguments - Delegates the HTTP call to
ExOpenAI.Config.http_client().api_call/6
In the current v2 codegen the real, production function bodies are
generated inline in PathModuleGenerator. generate_body/3 exists as
a focused unit under test that captures the same ideas without being
wired into the runtime generator.
Summary
Functions
Generates the function body AST for an operation.
Functions
@spec generate_body(ExOpenAI.Codegen.DocsParser.Operation.t(), String.t(), [Macro.t()]) :: Macro.t()
Generates the function body AST for an operation.
The arg_asts parameter is the list of argument AST nodes that would
appear in a function head, e.g. [quote(do: item_id), quote(do: opts)].
The generated body:
- Captures arguments via
binding/0intoall_args - Replaces any
{path_param}segments usingKeyword.get(all_args, name) - Builds a query string from query parameters present in
all_args - Builds
body_paramsfrom non‑path, non‑optsarguments - Calls
api_call/6with&Function.identity/1as the converter