     type_list = fs
     |> Enum.map(fn f -> {f.name, f.type} end)
     |> Enum.map(fn {n, t} -> quote do unquote(n) :: unquote(t) end end)
-    mod_name = Atom.to_string(parent_mod) <>
-      "." <> (t.name |> String.capitalize)
-    |> String.to_atom
+    mod_name = struct_name(t.name, parent_mod)
     quote do
       defmodule unquote(mod_name) do
         defstruct unquote(field_list)

    |> Enum.reject(fn entry -> entry == [] end)
    |> Enum.map(fn {name, type} ->
      t = Macro.escape(type)
      quote do
        AmqpOne.TypeManager.add_type(unquote(name), unquote(t))
        AmqpOne.TypeManager.add_type(unquote(t))
      end
    end)
  end

  def generate_struct(%Type{} = t, _parent_mod) do
    IO.puts "Ignore simple type #{t.name}"
    []
  end

  def struct_name(name, parent_mod) do
    Atom.to_string(parent_mod) <>
      "." <> (name |> String.capitalize)
    |> String.to_atom
  end

  def extract_field(%Field{name: n, type: t} = f) do
