Infusion.Spec (infusion v0.1.0)

Copy Markdown View Source

Loads an OpenAPI document from a file or a URL.

{:ok, spec} = Infusion.Spec.load("openapi.json")
{:ok, spec} = Infusion.Spec.load("https://example.com/openapi.yaml")

JSON and YAML are both accepted, told apart by content rather than by file extension. Prefer JSON when a vendor publishes both: it is about 50 times faster to parse. YAML is read with full YAML type resolution, so true, false and null arrive as booleans and nil (a faster YAML library was measured returning them as strings, which silently changes meaning, e.g. additionalProperties: "false").

Only OpenAPI 3.0 and 3.1 are supported.

Summary

Functions

Loads and checks an OpenAPI document.

Types

t()

@type t() :: %Infusion.Spec{document: map(), source: String.t(), version: String.t()}

Functions

load(source, opts \\ [])

@spec load(String.t(), keyword()) :: {:ok, t()} | {:error, String.t()}

Loads and checks an OpenAPI document.

Options

  • :req_options - extra options for Req.get/2 when source is a URL.