# `OzMcp.Structs.EnumSchema`
[🔗](https://github.com/oz-elixir/oz_mcp/blob/v0.9.0/lib/oz_mcp/structs/enum_schema.ex#L1)

Helper module used to build a single-select enum field of an elicitation
form (`UntitledSingleSelectEnumSchema` or `TitledSingleSelectEnumSchema`).

_(MCP protocol: 2025-11-25)_

The options are strings, `{value, title}` tuples, or maps with `const` and
`title` (see `OzMcp.Structs.EnumOptions`). Without titles the schema uses
`enum`; with at least one title it uses `oneOf`.

## Short example:

```elixir
%EnumSchema{}
  |> EnumSchema.options(["low", "high"])
  |> EnumSchema.default("low")
  |> EnumSchema.build()
```

Result:

```elixir
%{type: "string", enum: ["low", "high"], default: "low"}
```

With titles:

```elixir
%EnumSchema{}
  |> EnumSchema.options([{"#ff0000", "Red"}, {"#00ff00", "Green"}])
  |> EnumSchema.build()
```

Result:

```elixir
%{
  type: "string",
  oneOf: [%{const: "#ff0000", title: "Red"}, %{const: "#00ff00", title: "Green"}]
}
```

Specification: [EnumSchema](https://modelcontextprotocol.io/specification/2025-11-25/schema#enumschema)

## Fields

| Field | Setter | Type | Required |
|---|---|---|---|
| `title` | `title/2` | string | no |
| `description` | `description/2` | string | no |
| `options` | `options/2` | list(OzMcp.Structs.EnumOptions.option()) | no |
| `default` | `default/2` | string | no |

# `t`

```elixir
@type t() :: %OzMcp.Structs.EnumSchema{
  default: String.t() | nil,
  description: String.t() | nil,
  options: [OzMcp.Structs.EnumOptions.option()],
  title: String.t() | nil
}
```

# `build`

```elixir
@spec build(t()) :: map()
```

# `default`

```elixir
@spec default(t(), String.t() | nil) :: t()
```

# `description`

```elixir
@spec description(t(), String.t() | nil) :: t()
```

# `options`

```elixir
@spec options(t(), [OzMcp.Structs.EnumOptions.option()]) :: t()
```

# `title`

```elixir
@spec title(t(), String.t() | nil) :: t()
```

---

*Consult [api-reference.md](api-reference.md) for complete listing*
