# `Lather.Types.Generator`
[🔗](https://github.com/awksedgreep/lather/blob/v1.0.49/lib/lather/types/generator.ex#L1)

Runtime struct generation for SOAP types.

This module provides utilities to dynamically generate Elixir structs
from WSDL type definitions at runtime, enabling type-safe interactions
with SOAP services.

# `create_struct_instance`

```elixir
@spec create_struct_instance(map(), String.t(), map()) ::
  {:ok, struct()} | {:error, term()}
```

Creates a struct instance from XML data using generated types.

## Parameters

  * `xml_data` - Parsed XML data
  * `type_name` - The struct type to create
  * `generated_modules` - Map of generated modules

## Examples

    {:ok, user_struct} = Lather.Types.Generator.create_struct_instance(
      %{"name" => "John", "age" => "30"},
      "User",
      generated_modules
    )
    # %DynamicTypes.User{name: "John", age: 30}

# `generate_structs`

```elixir
@spec generate_structs(
  map(),
  keyword()
) :: {:ok, [module()]} | {:error, term()}
```

Generates Elixir structs at runtime for WSDL types.

## Parameters

  * `service_info` - Service information from WSDL analysis
  * `options` - Generation options

## Options

  * `:module_prefix` - Module prefix for generated structs (default: DynamicTypes)
  * `:exclude_types` - List of type names to exclude from generation
  * `:include_only` - List of type names to include (excludes all others)
  * `:field_naming` - How to handle field names (:snake_case, :camel_case, :preserve)

## Examples

    {:ok, generated_modules} = Lather.Types.Generator.generate_structs(service_info)

    {:ok, modules} = Lather.Types.Generator.generate_structs(
      service_info,
      module_prefix: MyApp.SoapTypes,
      field_naming: :snake_case
    )

# `get_struct_module`

```elixir
@spec get_struct_module(String.t(), module()) :: module()
```

Gets the module name for a generated struct type.

## Examples

    module_name = Lather.Types.Generator.get_struct_module("User", DynamicTypes)
    # DynamicTypes.User

# `struct_exists?`

```elixir
@spec struct_exists?(String.t(), map()) :: boolean()
```

Validates if a module was generated for a type.

## Examples

    true = Lather.Types.Generator.struct_exists?("User", generated_modules)
    false = Lather.Types.Generator.struct_exists?("NonExistent", generated_modules)

# `struct_to_xml`

```elixir
@spec struct_to_xml(
  struct(),
  map()
) :: map()
```

Converts a struct instance to XML data.

## Parameters

  * `struct_instance` - The struct to convert
  * `type_context` - Type mapping context

## Examples

    xml_data = Lather.Types.Generator.struct_to_xml(user_struct, type_context)
    # %{"name" => "John", "age" => "30"}

---

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