View Source AvroEx.Schema (AvroEx v2.1.0)

Link to this section Summary

Link to this section Types

Specs

alias() :: name()

Specs

doc() :: nil | String.t()

Specs

full_name() :: String.t()

Specs

json_schema() :: String.t()

Specs

metadata() :: %{required(String.t()) => String.t()}

Specs

name() :: String.t()

Specs

Specs

namespace() :: nil | String.t()

Specs

Specs

t() :: %AvroEx.Schema{
  context: AvroEx.Schema.Context.t(),
  schema: schema_types() | nil
}

Link to this section Functions

Link to this function

encodable?(schema, data)

View Source

Specs

encodable?(t(), any()) :: boolean()
Link to this function

encodable?(record, context, bool)

View Source

Specs

encodable?(any(), any(), any()) :: boolean()
Link to this function

full_name(schema, parent_namespace \\ nil)

View Source

Specs

full_name(schema_types() | name(), namespace()) :: nil | String.t()

The fully-qualified name of the type

examples

Examples

iex> full_name(%Primitive{type: "string"})
nil

iex> full_name(%Record{name: "foo", namespace: "beam.community"})
"beam.community.foo"

iex> full_name(%Record{name: "foo"}, "top.level.namespace")
"top.level.namespace.foo"
Link to this function

namespace(schema, parent_namespace \\ nil)

View Source

Specs

namespace(schema_types(), namespace()) :: namespace()

The namespace of the given Schema type

examples

Examples

iex> namespace(%Primitive{type: :string})
nil

iex> namespace(%Record{name: "MyRecord"}, "namespace")
"namespace"

iex> namespace(%Record{name: "MyRecord", namespace: "inner"}, "namespace")
"inner"

iex> namespace(%Record{name: "qualified.MyRecord", namespace: "inner"}, "namespace")
"qualified"

Specs

type_name(schema_types()) :: String.t()

The name of the schema type

examples

Examples

iex> type_name(%Primitive{type: "string"})
"string"

iex> type_name(%Primitive{type: :long, metadata: %{"logicalType" => "timestamp-millis"}})
"timestamp-millis"

iex> type_name(%AvroEnum{name: "switch", symbols: []})
"Enum<name=switch>"

iex> type_name(%Array{items: %Primitive{type: "int"}})
"Array<items=int>"

iex> type_name(%Fixed{size: 2, name: "double"})
"Fixed<name=double, size=2>"

iex> type_name(%Union{possibilities: [%Primitive{type: "string"}, %Primitive{type: "int"}]})
"Union<possibilities=string|int>"

iex> type_name(%Record{name: "foo"})
"Record<name=foo>"

iex> type_name(%Reference{type: "foo"})
"Reference<name=foo>"