# `Exdantic.JsonSchema.ReferenceStore`
[🔗](https://github.com/nshkrdotcom/exdantic/blob/v0.1.0/lib/exdantic/json_schema/reference_store.ex#L1)

Manages schema references and definitions for JSON Schema generation.

This module provides a stateful store for tracking schema references
and their corresponding JSON Schema definitions during conversion.

# `state`

```elixir
@type state() :: %{
  refs: MapSet.t(module()),
  definitions: %{required(String.t()) =&gt; map()}
}
```

# `add_definition`

```elixir
@spec add_definition(pid(), module(), map()) :: :ok
```

Adds a JSON Schema definition for a module.

## Parameters
  * `agent` - The reference store process PID
  * `module` - The module for which to store the schema definition
  * `schema` - The JSON Schema map representation

## Examples

    iex> schema = %{"type" => "object", "properties" => %{}}
    iex> Exdantic.JsonSchema.ReferenceStore.add_definition(store, MySchema, schema)
    :ok

# `add_reference`

```elixir
@spec add_reference(pid(), module()) :: :ok
```

Adds a schema module reference to track for processing.

## Parameters
  * `agent` - The reference store process PID
  * `module` - The schema module to add as a reference

## Examples

    iex> Exdantic.JsonSchema.ReferenceStore.add_reference(store, MySchema)
    :ok

# `get_definitions`

```elixir
@spec get_definitions(pid()) :: %{required(String.t()) =&gt; map()}
```

Gets all schema definitions currently stored.

## Parameters
  * `agent` - The reference store process PID

## Returns
  * Map of module names to their JSON Schema definitions

## Examples

    iex> Exdantic.JsonSchema.ReferenceStore.get_definitions(store)
    %{"MySchema" => %{"type" => "object"}}

# `get_references`

```elixir
@spec get_references(pid()) :: [module()]
```

Gets all module references currently tracked in the store.

## Parameters
  * `agent` - The reference store process PID

## Returns
  * List of module atoms

## Examples

    iex> Exdantic.JsonSchema.ReferenceStore.get_references(store)
    [MySchema, AnotherSchema]

# `has_definition?`

```elixir
@spec has_definition?(pid(), module()) :: boolean()
```

Checks if a schema definition exists for a module.

## Parameters
  * `agent` - The reference store process PID
  * `module` - The module to check for a definition

## Returns
  * `true` if a definition exists, `false` otherwise

## Examples

    iex> Exdantic.JsonSchema.ReferenceStore.has_definition?(store, MySchema)
    false

# `has_reference?`

```elixir
@spec has_reference?(pid(), module()) :: boolean()
```

Checks if a module reference is already tracked in the store.

## Parameters
  * `agent` - The reference store process PID
  * `module` - The module to check for

## Returns
  * `true` if the module is tracked, `false` otherwise

## Examples

    iex> Exdantic.JsonSchema.ReferenceStore.has_reference?(store, MySchema)
    true

# `ref_path`

```elixir
@spec ref_path(module()) :: String.t()
```

Generates a JSON Schema reference path for a module.

## Parameters
  * `module` - The module to generate a reference path for

## Returns
  * JSON Schema reference string in the format "#/definitions/ModuleName"

## Examples

    iex> Exdantic.JsonSchema.ReferenceStore.ref_path(MySchema)
    "#/definitions/MySchema"

# `start_link`

```elixir
@spec start_link() :: {:ok, pid()}
```

Starts a new reference store process.

## Returns
  * `{:ok, pid}` on success

## Examples

    iex> {:ok, store} = Exdantic.JsonSchema.ReferenceStore.start_link()
    {:ok, #PID<...>}

# `stop`

```elixir
@spec stop(pid()) :: :ok
```

Stops the reference store process.

## Parameters
  * `agent` - The reference store process PID

## Examples

    iex> {:ok, store} = Exdantic.JsonSchema.ReferenceStore.start_link()
    iex> Exdantic.JsonSchema.ReferenceStore.stop(store)
    :ok

---

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