Infusion.Gen.Operations (infusion v0.1.0)

Copy Markdown View Source

Generates one module per resource with one function per operation.

defmodule OpenAI.Models do
  @retrieve_operation %{method: :get, path: "/models/{model}", ...}

  @spec retrieve(String.t(), keyword()) :: {:ok, OpenAI.Schemas.Model.t()} | {:error, Infusion.Runtime.Error.t()}
  def retrieve(model, opts \\ []), do: OpenAI.__request__(@retrieve_operation, [model], %{}, opts)

  def retrieve!(model, opts \\ []), do: ...
end

Path parameters are positional. Query, header and body parameters are one map or keyword list, params; operations that take none have no params argument. Call options (timeout:, max_retries:, raw:, ...) come last. The operation itself is data handed to Infusion.Runtime.Request.

Summary

Functions

Renders the operations of ir under base ("OpenAI"), with modules the schema-name-to-module mapping from Infusion.Gen.Schemas.render/2.

Functions

render(ir, base, modules)

@spec render(
  %Infusion.IR{
    auth: term(),
    operations: term(),
    schemas: term(),
    servers: term(),
    warnings: term()
  },
  String.t(),
  %{required(String.t()) => String.t()}
) :: [Infusion.Gen.Schemas.file()]

Renders the operations of ir under base ("OpenAI"), with modules the schema-name-to-module mapping from Infusion.Gen.Schemas.render/2.