Infusion (infusion v0.1.0)

Copy Markdown View Source

Generates Elixir SDKs from OpenAPI specs.

{:ok, result} = Infusion.generate("openapi.yaml", name: "OpenAI")
result.files     #=> [%{path: "lib/openai/models.ex", source: "..."}, ...]
result.warnings  #=> what the spec does that the SDK can't represent

Or from the command line, mix infusion.gen. See the design for how specs become SDKs.

Summary

Functions

Generates the files of an SDK from source (a path or URL).

Writes generated files under dir.

Functions

generate(source, opts)

@spec generate(String.t(), keyword()) ::
  {:ok,
   %{
     files: [Infusion.Gen.Schemas.file()],
     warnings: [String.t()],
     ir: %Infusion.IR{
       auth: term(),
       operations: term(),
       schemas: term(),
       servers: term(),
       warnings: term()
     }
   }}
  | {:error, String.t()}

Generates the files of an SDK from source (a path or URL).

Options: :name (the base module, required), plus those of Infusion.Gen.Project.render/4 and Infusion.Spec.load/2.

write(files, dir)

@spec write([Infusion.Gen.Schemas.file()], Path.t()) :: :ok

Writes generated files under dir.