prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Bug: openapi schema generation fails for Union of/in msgspec.Struct models
  ### Description
  
  Hello!
  
  In the latest versions(s) (I think this originates from the changes regarding nested models in openapi generation) we cannot use Unions of `msgspec.Struct`s anymore. Neither as direct return types for routes nor nested within return types. 
  
  The result is a 500 Error. The MCVE below raises `'types.UnionType' object has no attribute '__qualname__'` internally. In our production app I get `typing.Union is not a module, class, method, or function.` instead.
  
  Cheers
  
  ### URL to code causing the issue
  
  _No response_
  
  ### MCVE
  
  ```python
  import msgspec
  import uvicorn
  from litestar import Litestar, get
  
  
  class SubStructA(msgspec.Struct):
      a: int
  
  
  class SubStructB(msgspec.Struct):
      a: int
  
  
  class StructyStruct(msgspec.Struct):
      sub: SubStructA | SubStructB
  
  
  @get("/subunion")
  async def testSubUnion() -> StructyStruct:
      return StructyStruct(SubStructA(0))
  
  
  @get("/union")
  async def testUnion() -> SubStructA | SubStructB:
      return SubStructA(0)
  
  
  app = Litestar(route_handlers=[test2]) # or test
  uvicorn.run(app)
  ```
  
  
  ### Steps to reproduce
  
  ```bash
  Run the example and browse to `localhost:8000/schema`
  ```
  
  
  ### Screenshots
  
  _No response_
  
  ### Logs
  
  _No response_
  
  ### Litestar Version
  
  2.5.0
  
  ### Platform
  
  - [X] Linux
  - [ ] Mac
  - [ ] Windows
  - [ ] Other (Please specify in the description above)
  
  <!-- POLAR PLEDGE BADGE START -->
  ---
  > [!NOTE]  
  > While we are open for sponsoring on [GitHub Sponsors](https://github.com/sponsors/litestar-org/) and 
  > [OpenCollective](https://opencollective.com/litestar), we also utilize [Polar.sh](https://polar.sh/) to engage in pledge-based sponsorship.
  >
  > Check out all issues funded or available for funding [on our Polar.sh dashboard](https://polar.sh/litestar-org)
  > * If you would like to see an issue prioritized, make a pledge towards it!
  > * We receive the pledge once the issue is completed & verified
  > * This, along with engagement in the community, helps us know which features are a priority to our users.
  
  <a href="https://polar.sh/litestar-org/litestar/issues/2971">
  <picture>
    <source media="(prefers-color-scheme: dark)" srcset="https://polar.sh/api/github/litestar-org/litestar/issues/2971/pledge.svg?darkmode=1">
    <img alt="Fund with Polar" src="https://polar.sh/api/github/litestar-org/litestar/issues/2971/pledge.svg">
  </picture>
  </a>
  <!-- POLAR PLEDGE BADGE END -->
  
  
  </issue>
  <code>
  [start of litestar/_openapi/schema_generation/plugins/struct.py]
  1 from __future__ import annotations
  2 
  3 from typing import TYPE_CHECKING
  4 
  5 from msgspec import Struct
  6 from msgspec.structs import fields
  7 
  8 from litestar.plugins import OpenAPISchemaPlugin
  9 from litestar.types.empty import Empty
  10 from litestar.typing import FieldDefinition
  11 from litestar.utils.predicates import is_optional_union
  12 
  13 if TYPE_CHECKING:
  14     from msgspec.structs import FieldInfo
  15 
  16     from litestar._openapi.schema_generation import SchemaCreator
  17     from litestar.openapi.spec import Schema
  18 
  19 
  20 class StructSchemaPlugin(OpenAPISchemaPlugin):
  21     def is_plugin_supported_field(self, field_definition: FieldDefinition) -> bool:
  22         return field_definition.is_subclass_of(Struct)
  23 
  24     def to_openapi_schema(self, field_definition: FieldDefinition, schema_creator: SchemaCreator) -> Schema:
  25         def is_field_required(field: FieldInfo) -> bool:
  26             return field.required or field.default_factory is Empty
  27 
  28         type_hints = field_definition.get_type_hints(include_extras=True, resolve_generics=True)
  29         struct_fields = fields(field_definition.type_)
  30 
  31         return schema_creator.create_component_schema(
  32             field_definition,
  33             required=sorted(
  34                 [
  35                     field.encode_name
  36                     for field in struct_fields
  37                     if is_field_required(field=field) and not is_optional_union(type_hints[field.name])
  38                 ]
  39             ),
  40             property_fields={
  41                 field.encode_name: FieldDefinition.from_kwarg(type_hints[field.name], field.encode_name)
  42                 for field in struct_fields
  43             },
  44         )
  45
  [end of litestar/_openapi/schema_generation/plugins/struct.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/litestar/_openapi/schema_generation/plugins/struct.py b/litestar/_openapi/schema_generation/plugins/struct.py
  --- a/litestar/_openapi/schema_generation/plugins/struct.py
  +++ b/litestar/_openapi/schema_generation/plugins/struct.py
  @@ -19,7 +19,7 @@
   
   class StructSchemaPlugin(OpenAPISchemaPlugin):
       def is_plugin_supported_field(self, field_definition: FieldDefinition) -> bool:
  -        return field_definition.is_subclass_of(Struct)
  +        return not field_definition.is_union and field_definition.is_subclass_of(Struct)
   
       def to_openapi_schema(self, field_definition: FieldDefinition, schema_creator: SchemaCreator) -> Schema:
           def is_field_required(field: FieldInfo) -> bool:
  
verification_info: {"golden_diff": "diff --git a/litestar/_openapi/schema_generation/plugins/struct.py b/litestar/_openapi/schema_generation/plugins/struct.py\n--- a/litestar/_openapi/schema_generation/plugins/struct.py\n+++ b/litestar/_openapi/schema_generation/plugins/struct.py\n@@ -19,7 +19,7 @@\n \n class StructSchemaPlugin(OpenAPISchemaPlugin):\n     def is_plugin_supported_field(self, field_definition: FieldDefinition) -> bool:\n-        return field_definition.is_subclass_of(Struct)\n+        return not field_definition.is_union and field_definition.is_subclass_of(Struct)\n \n     def to_openapi_schema(self, field_definition: FieldDefinition, schema_creator: SchemaCreator) -> Schema:\n         def is_field_required(field: FieldInfo) -> bool:\n", "issue": "Bug: openapi schema generation fails for Union of/in msgspec.Struct models\n### Description\r\n\r\nHello!\r\n\r\nIn the latest versions(s) (I think this originates from the changes regarding nested models in openapi generation) we cannot use Unions of `msgspec.Struct`s anymore. Neither as direct return types for routes nor nested within return types. \r\n\r\nThe result is a 500 Error. The MCVE below raises `'types.UnionType' object has no attribute '__qualname__'` internally. In our production app I get `typing.Union is not a module, class, method, or function.` instead.\r\n\r\nCheers\r\n\r\n### URL to code causing the issue\r\n\r\n_No response_\r\n\r\n### MCVE\r\n\r\n```python\r\nimport msgspec\r\nimport uvicorn\r\nfrom litestar import Litestar, get\r\n\r\n\r\nclass SubStructA(msgspec.Struct):\r\n    a: int\r\n\r\n\r\nclass SubStructB(msgspec.Struct):\r\n    a: int\r\n\r\n\r\nclass StructyStruct(msgspec.Struct):\r\n    sub: SubStructA | SubStructB\r\n\r\n\r\n@get(\"/subunion\")\r\nasync def testSubUnion() -> StructyStruct:\r\n    return StructyStruct(SubStructA(0))\r\n\r\n\r\n@get(\"/union\")\r\nasync def testUnion() -> SubStructA | SubStructB:\r\n    return SubStructA(0)\r\n\r\n\r\napp = Litestar(route_handlers=[test2]) # or test\r\nuvicorn.run(app)\r\n```\r\n\r\n\r\n### Steps to reproduce\r\n\r\n```bash\r\nRun the example and browse to `localhost:8000/schema`\r\n```\r\n\r\n\r\n### Screenshots\r\n\r\n_No response_\r\n\r\n### Logs\r\n\r\n_No response_\r\n\r\n### Litestar Version\r\n\r\n2.5.0\r\n\r\n### Platform\r\n\r\n- [X] Linux\r\n- [ ] Mac\r\n- [ ] Windows\r\n- [ ] Other (Please specify in the description above)\r\n\r\n<!-- POLAR PLEDGE BADGE START -->\r\n---\r\n> [!NOTE]  \r\n> While we are open for sponsoring on [GitHub Sponsors](https://github.com/sponsors/litestar-org/) and \r\n> [OpenCollective](https://opencollective.com/litestar), we also utilize [Polar.sh](https://polar.sh/) to engage in pledge-based sponsorship.\r\n>\r\n> Check out all issues funded or available for funding [on our Polar.sh dashboard](https://polar.sh/litestar-org)\r\n> * If you would like to see an issue prioritized, make a pledge towards it!\r\n> * We receive the pledge once the issue is completed & verified\r\n> * This, along with engagement in the community, helps us know which features are a priority to our users.\r\n\r\n<a href=\"https://polar.sh/litestar-org/litestar/issues/2971\">\r\n<picture>\r\n  <source media=\"(prefers-color-scheme: dark)\" srcset=\"https://polar.sh/api/github/litestar-org/litestar/issues/2971/pledge.svg?darkmode=1\">\r\n  <img alt=\"Fund with Polar\" src=\"https://polar.sh/api/github/litestar-org/litestar/issues/2971/pledge.svg\">\r\n</picture>\r\n</a>\r\n<!-- POLAR PLEDGE BADGE END -->\r\n\n", "before_files": [{"content": "from __future__ import annotations\n\nfrom typing import TYPE_CHECKING\n\nfrom msgspec import Struct\nfrom msgspec.structs import fields\n\nfrom litestar.plugins import OpenAPISchemaPlugin\nfrom litestar.types.empty import Empty\nfrom litestar.typing import FieldDefinition\nfrom litestar.utils.predicates import is_optional_union\n\nif TYPE_CHECKING:\n    from msgspec.structs import FieldInfo\n\n    from litestar._openapi.schema_generation import SchemaCreator\n    from litestar.openapi.spec import Schema\n\n\nclass StructSchemaPlugin(OpenAPISchemaPlugin):\n    def is_plugin_supported_field(self, field_definition: FieldDefinition) -> bool:\n        return field_definition.is_subclass_of(Struct)\n\n    def to_openapi_schema(self, field_definition: FieldDefinition, schema_creator: SchemaCreator) -> Schema:\n        def is_field_required(field: FieldInfo) -> bool:\n            return field.required or field.default_factory is Empty\n\n        type_hints = field_definition.get_type_hints(include_extras=True, resolve_generics=True)\n        struct_fields = fields(field_definition.type_)\n\n        return schema_creator.create_component_schema(\n            field_definition,\n            required=sorted(\n                [\n                    field.encode_name\n                    for field in struct_fields\n                    if is_field_required(field=field) and not is_optional_union(type_hints[field.name])\n                ]\n            ),\n            property_fields={\n                field.encode_name: FieldDefinition.from_kwarg(type_hints[field.name], field.encode_name)\n                for field in struct_fields\n            },\n        )\n", "path": "litestar/_openapi/schema_generation/plugins/struct.py"}]}