Avrogen.Schema (avrogen v1.1.0)

Copy Markdown View Source

Utils for extracting various info from avro schemas. Schemas can be records or enums.

Summary

Functions

Get a list of external types referenced in a given record/enum.

Get a schema's fully qualified name by combining its namespace and name.

Load a schema from a file.

Get a schema's name.

Get a schema's namespace.

Resolve a schema's file path from its fqn.

Sort a list of avro schemas in topological order based on dependencies.

Types

schema()

@type schema() :: map()

Functions

external_dependencies(arg1)

@spec external_dependencies(schema()) :: [String.t()]

Get a list of external types referenced in a given record/enum.

fqn(map)

@spec fqn(schema()) :: String.t()

Get a schema's fully qualified name by combining its namespace and name.

load_schema!(path_to_schema)

@spec load_schema!(Path.t()) :: schema()

Load a schema from a file.

name(map)

@spec name(schema()) :: String.t()

Get a schema's name.

namespace(map)

@spec namespace(schema()) :: String.t()

Get a schema's namespace.

Note: Unsure what to do if the schema has no namespace - make it a MatchError for now...

path_from_fqn(root, schema_fqn, atom)

@spec path_from_fqn(Path.t(), String.t(), :flat | :tree) :: Path.t()

Resolve a schema's file path from its fqn.

topological_sort(elements)

@spec topological_sort([schema()]) :: {:ok, [schema()]} | {:error, any()}

Sort a list of avro schemas in topological order based on dependencies.