We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Bug: ResponseHeaders results in invalid OpenAPI schema
### Description

Use of `response_headers` on the Litestar object seems to result in invalid OpenAPI 3.1 schema generation.

The Header object on the response is invalid aiui according to the spec (see https://spec.openapis.org/oas/v3.1.0#header-object) and fails validation when using `redocly lint`, as it includes the `name` and `in` fields.

The schema is as follows,

```json
{
    "info": {
        "title": "Litestar API",
        "version": "1.0.0"
    },
    "openapi": "3.1.0",
    "servers": [
        {
            "url": "/"
        }
    ],
    "paths": {
        "/": {
            "get": {
                "summary": "HelloWorld1",
                "operationId": "HelloWorld1",
                "responses": {
                    "200": {
                        "description": "Request fulfilled, document follows",
                        "headers": {
                            "X-Version": {
                                "schema": {
                                    "type": "string"
                                },
                                "name": "X-Version",
                                "in": "header",
                                "description": "Test",
                                "required": false,
                                "deprecated": false,
                                "allowEmptyValue": false,
                                "allowReserved": false
                            }
                        }
                    }
                },
                "deprecated": false
            }
        }
    },
    "components": {
        "schemas": {}
    }
}
```


### URL to code causing the issue

_No response_

### MCVE

```python
from litestar import Litestar, Request, get
from litestar.datastructures import ResponseHeader

@get("/")
async def hello_world1(request: Request) -> None:
    request.logger.info("inside request")
    return None

app1 = Litestar(
    route_handlers=[hello_world1],
    response_headers=[ResponseHeader(name="X-Version", value="ABCD", description="Test")],
)
```

This endpoint works, but the resulting schema fails validation.

```bash
$ litestar schema openapi --output openapi_schema.json
$ npx @redocly/cli lint openapi_schema.json

...
[1] openapi_schema.json:25:33 at #/paths/~1/get/responses/200/headers/X-Version/name

Property `name` is not expected here.

23 |     "type": "string"
24 | },
25 | "name": "X-Version",
26 | "in": "header",
27 | "description": "Test",

Error was generated by the spec rule.


[2] openapi_schema.json:26:33 at #/paths/~1/get/responses/200/headers/X-Version/in

Property `in` is not expected here.

24 | },
25 | "name": "X-Version",
26 | "in": "header",
27 | "description": "Test",
28 | "required": false,
...

```


### Steps to reproduce

_No response_

### Screenshots

_No response_

### Logs

_No response_

### Litestar Version

2.8.2, using Python 3.12.2

### Platform

- [ ] Linux
- [X] 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/3416">
<picture>
  <source media="(prefers-color-scheme: dark)" srcset="https://polar.sh/api/github/litestar-org/litestar/issues/3416/pledge.svg?darkmode=1">
  <img alt="Fund with Polar" src="https://polar.sh/api/github/litestar-org/litestar/issues/3416/pledge.svg">
</picture>
</a>
<!-- POLAR PLEDGE BADGE END -->


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `litestar/openapi/spec/header.py`
Content:
```
1 from __future__ import annotations
2 
3 from dataclasses import dataclass
4 from typing import TYPE_CHECKING, Any, Literal
5 
6 from litestar.openapi.spec.base import BaseSchemaObject
7 
8 if TYPE_CHECKING:
9     from litestar.openapi.spec.example import Example
10     from litestar.openapi.spec.media_type import OpenAPIMediaType
11     from litestar.openapi.spec.reference import Reference
12     from litestar.openapi.spec.schema import Schema
13 
14 __all__ = ("OpenAPIHeader",)
15 
16 
17 @dataclass
18 class OpenAPIHeader(BaseSchemaObject):
19     """The Header Object follows the structure of the [Parameter
20     Object](https://spec.openapis.org/oas/v3.1.0#parameterObject) with the
21     following changes:
22 
23     1. ``name`` MUST NOT be specified, it is given in the corresponding ``headers`` map.
24     2. ``in`` MUST NOT be specified, it is implicitly in ``header``.
25     3. All traits that are affected by the location MUST be applicable to a location of ``header``
26        (for example, `style <https://spec.openapis.org/oas/v3.1.0#parameterStyle>`__).
27     """
28 
29     schema: Schema | Reference | None = None
30     """The schema defining the type used for the parameter."""
31 
32     name: Literal[""] = ""
33     """MUST NOT be specified, it is given in the corresponding ``headers`` map."""
34 
35     param_in: Literal["header"] = "header"
36     """MUST NOT be specified, it is implicitly in ``header``."""
37 
38     description: str | None = None
39     """A brief description of the parameter. This could contain examples of
40     use.
41 
42     `CommonMark syntax <https://spec.commonmark.org/>`_ MAY be used for rich text representation.
43     """
44 
45     required: bool = False
46     """Determines whether this parameter is mandatory.
47 
48     If the `parameter location <https://spec.openapis.org/oas/v3.1.0#parameterIn>`_ is ``"path"``, this property is
49     **REQUIRED** and its value MUST be ``True``. Otherwise, the property MAY be included and its default value is
50     ``False``.
51     """
52 
53     deprecated: bool = False
54     """Specifies that a parameter is deprecated and SHOULD be transitioned out of usage. Default value is ``False``."""
55 
56     allow_empty_value: bool = False
57     """Sets the ability to pass empty-valued parameters. This is valid only for ``query`` parameters and allows sending
58     a parameter with an empty value. Default value is ``False``. If
59     `style <https://spec.openapis.org/oas/v3.1.0#parameterStyle>`__ is used, and if behavior is ``n/a`` (cannot be
60     serialized), the value of ``allowEmptyValue`` SHALL be ignored. Use of this property is NOT RECOMMENDED, as it is
61     likely to be removed in a later revision.
62 
63     The rules for serialization of the parameter are specified in one of two ways.For simpler scenarios, a
64     `schema <https://spec.openapis.org/oas/v3.1.0#parameterSchema>`_ and
65     `style <https://spec.openapis.org/oas/v3.1.0#parameterStyle>`__ can describe the structure and syntax of the
66     parameter.
67     """
68 
69     style: str | None = None
70     """Describes how the parameter value will be serialized depending on the
71     type of the parameter value. Default values (based on value of ``in``):
72 
73     - for ``query`` - ``form``;
74     - for ``path`` - ``simple``;
75     - for ``header`` - ``simple``;
76     - for ``cookie`` - ``form``.
77     """
78 
79     explode: bool | None = None
80     """When this is true, parameter values of type ``array`` or ``object`` generate separate parameters for each value
81     of the array or key-value pair of the map.
82 
83     For other types of parameters this property has no effect.When
84     `style <https://spec.openapis.org/oas/v3.1.0#parameterStyle>`__ is ``form``, the default value is ``True``. For all
85     other styles, the default value is ``False``.
86     """
87 
88     allow_reserved: bool = False
89     """Determines whether the parameter value SHOULD allow reserved characters, as defined by. :rfc:`3986`
90     (``:/?#[]@!$&'()*+,;=``) to be included without percent-encoding.
91 
92     This property only applies to parameters with an ``in`` value of ``query``. The default value is ``False``.
93     """
94 
95     example: Any | None = None
96     """Example of the parameter's potential value.
97 
98     The example SHOULD match the specified schema and encoding properties if present. The ``example`` field is mutually
99     exclusive of the ``examples`` field. Furthermore, if referencing a ``schema`` that contains an example, the
100     ``example`` value SHALL _override_ the example provided by the schema. To represent examples of media types that
101     cannot naturally be represented in JSON or YAML, a string value can contain the example with escaping where
102     necessary.
103     """
104 
105     examples: dict[str, Example | Reference] | None = None
106     """Examples of the parameter's potential value. Each example SHOULD contain a value in the correct format as
107     specified in the parameter encoding. The ``examples`` field is mutually exclusive of the ``example`` field.
108     Furthermore, if referencing a ``schema`` that contains an example, the ``examples`` value SHALL _override_ the
109     example provided by the schema.
110 
111     For more complex scenarios, the `content <https://spec.openapis.org/oas/v3.1.0#parameterContent>`_ property can
112     define the media type and schema of the parameter. A parameter MUST contain either a ``schema`` property, or a
113     ``content`` property, but not both. When ``example`` or ``examples`` are provided in conjunction with the ``schema``
114     object, the example MUST follow the prescribed serialization strategy for the parameter.
115     """
116 
117     content: dict[str, OpenAPIMediaType] | None = None
118     """A map containing the representations for the parameter.
119 
120     The key is the media type and the value describes it. The map MUST only contain one entry.
121     """
122
```

Path: `litestar/openapi/spec/base.py`
Content:
```
1 from __future__ import annotations
2 
3 from dataclasses import asdict, dataclass, fields, is_dataclass
4 from enum import Enum
5 from typing import Any
6 
7 __all__ = ("BaseSchemaObject",)
8 
9 
10 def _normalize_key(key: str) -> str:
11     if key.endswith("_in"):
12         return "in"
13     if key.startswith("schema_"):
14         return key.split("_")[1]
15     if "_" in key:
16         components = key.split("_")
17         return components[0] + "".join(component.title() for component in components[1:])
18     return "$ref" if key == "ref" else key
19 
20 
21 def _normalize_value(value: Any) -> Any:
22     if isinstance(value, BaseSchemaObject):
23         return value.to_schema()
24     if is_dataclass(value):
25         return {_normalize_value(k): _normalize_value(v) for k, v in asdict(value).items() if v is not None}
26     if isinstance(value, dict):
27         return {_normalize_value(k): _normalize_value(v) for k, v in value.items() if v is not None}
28     if isinstance(value, list):
29         return [_normalize_value(v) for v in value]
30     return value.value if isinstance(value, Enum) else value
31 
32 
33 @dataclass
34 class BaseSchemaObject:
35     """Base class for schema spec objects"""
36 
37     def to_schema(self) -> dict[str, Any]:
38         """Transform the spec dataclass object into a string keyed dictionary. This method traverses all nested values
39         recursively.
40         """
41         result: dict[str, Any] = {}
42 
43         for field in fields(self):
44             value = _normalize_value(getattr(self, field.name, None))
45 
46             if value is not None:
47                 if "alias" in field.metadata:
48                     if not isinstance(field.metadata["alias"], str):
49                         raise TypeError('metadata["alias"] must be a str')
50                     key = field.metadata["alias"]
51                 else:
52                     key = _normalize_key(field.name)
53 
54                 result[key] = value
55 
56         return result
57
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/litestar/openapi/spec/base.py b/litestar/openapi/spec/base.py
--- a/litestar/openapi/spec/base.py
+++ b/litestar/openapi/spec/base.py
@@ -2,7 +2,11 @@
 
 from dataclasses import asdict, dataclass, fields, is_dataclass
 from enum import Enum
-from typing import Any
+from typing import TYPE_CHECKING, Any
+
+if TYPE_CHECKING:
+    from collections.abc import Iterator
+    from dataclasses import Field
 
 __all__ = ("BaseSchemaObject",)
 
@@ -34,13 +38,16 @@
 class BaseSchemaObject:
     """Base class for schema spec objects"""
 
+    def _iter_fields(self) -> Iterator[Field[Any]]:
+        yield from fields(self)
+
     def to_schema(self) -> dict[str, Any]:
         """Transform the spec dataclass object into a string keyed dictionary. This method traverses all nested values
         recursively.
         """
         result: dict[str, Any] = {}
 
-        for field in fields(self):
+        for field in self._iter_fields():
             value = _normalize_value(getattr(self, field.name, None))
 
             if value is not None:
diff --git a/litestar/openapi/spec/header.py b/litestar/openapi/spec/header.py
--- a/litestar/openapi/spec/header.py
+++ b/litestar/openapi/spec/header.py
@@ -1,7 +1,9 @@
 from __future__ import annotations
 
-from dataclasses import dataclass
-from typing import TYPE_CHECKING, Any, Literal
+from dataclasses import Field, dataclass
+from typing import TYPE_CHECKING, Any, Iterator, Literal
+
+from typing_extensions import override
 
 from litestar.openapi.spec.base import BaseSchemaObject
 
@@ -119,3 +121,7 @@
 
     The key is the media type and the value describes it. The map MUST only contain one entry.
     """
+
+    @override
+    def _iter_fields(self) -> Iterator[Field[Any]]:
+        yield from (f for f in super()._iter_fields() if f.name not in {"name", "param_in"})

{"golden_diff": "diff --git a/litestar/openapi/spec/base.py b/litestar/openapi/spec/base.py\n--- a/litestar/openapi/spec/base.py\n+++ b/litestar/openapi/spec/base.py\n@@ -2,7 +2,11 @@\n \n from dataclasses import asdict, dataclass, fields, is_dataclass\n from enum import Enum\n-from typing import Any\n+from typing import TYPE_CHECKING, Any\n+\n+if TYPE_CHECKING:\n+    from collections.abc import Iterator\n+    from dataclasses import Field\n \n __all__ = (\"BaseSchemaObject\",)\n \n@@ -34,13 +38,16 @@\n class BaseSchemaObject:\n     \"\"\"Base class for schema spec objects\"\"\"\n \n+    def _iter_fields(self) -> Iterator[Field[Any]]:\n+        yield from fields(self)\n+\n     def to_schema(self) -> dict[str, Any]:\n         \"\"\"Transform the spec dataclass object into a string keyed dictionary. This method traverses all nested values\n         recursively.\n         \"\"\"\n         result: dict[str, Any] = {}\n \n-        for field in fields(self):\n+        for field in self._iter_fields():\n             value = _normalize_value(getattr(self, field.name, None))\n \n             if value is not None:\ndiff --git a/litestar/openapi/spec/header.py b/litestar/openapi/spec/header.py\n--- a/litestar/openapi/spec/header.py\n+++ b/litestar/openapi/spec/header.py\n@@ -1,7 +1,9 @@\n from __future__ import annotations\n \n-from dataclasses import dataclass\n-from typing import TYPE_CHECKING, Any, Literal\n+from dataclasses import Field, dataclass\n+from typing import TYPE_CHECKING, Any, Iterator, Literal\n+\n+from typing_extensions import override\n \n from litestar.openapi.spec.base import BaseSchemaObject\n \n@@ -119,3 +121,7 @@\n \n     The key is the media type and the value describes it. The map MUST only contain one entry.\n     \"\"\"\n+\n+    @override\n+    def _iter_fields(self) -> Iterator[Field[Any]]:\n+        yield from (f for f in super()._iter_fields() if f.name not in {\"name\", \"param_in\"})\n", "issue": "Bug: ResponseHeaders results in invalid OpenAPI schema\n### Description\r\n\r\nUse of `response_headers` on the Litestar object seems to result in invalid OpenAPI 3.1 schema generation.\r\n\r\nThe Header object on the response is invalid aiui according to the spec (see https://spec.openapis.org/oas/v3.1.0#header-object) and fails validation when using `redocly lint`, as it includes the `name` and `in` fields.\r\n\r\nThe schema is as follows,\r\n\r\n```json\r\n{\r\n    \"info\": {\r\n        \"title\": \"Litestar API\",\r\n        \"version\": \"1.0.0\"\r\n    },\r\n    \"openapi\": \"3.1.0\",\r\n    \"servers\": [\r\n        {\r\n            \"url\": \"/\"\r\n        }\r\n    ],\r\n    \"paths\": {\r\n        \"/\": {\r\n            \"get\": {\r\n                \"summary\": \"HelloWorld1\",\r\n                \"operationId\": \"HelloWorld1\",\r\n                \"responses\": {\r\n                    \"200\": {\r\n                        \"description\": \"Request fulfilled, document follows\",\r\n                        \"headers\": {\r\n                            \"X-Version\": {\r\n                                \"schema\": {\r\n                                    \"type\": \"string\"\r\n                                },\r\n                                \"name\": \"X-Version\",\r\n                                \"in\": \"header\",\r\n                                \"description\": \"Test\",\r\n                                \"required\": false,\r\n                                \"deprecated\": false,\r\n                                \"allowEmptyValue\": false,\r\n                                \"allowReserved\": false\r\n                            }\r\n                        }\r\n                    }\r\n                },\r\n                \"deprecated\": false\r\n            }\r\n        }\r\n    },\r\n    \"components\": {\r\n        \"schemas\": {}\r\n    }\r\n}\r\n```\r\n\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\nfrom litestar import Litestar, Request, get\r\nfrom litestar.datastructures import ResponseHeader\r\n\r\n@get(\"/\")\r\nasync def hello_world1(request: Request) -> None:\r\n    request.logger.info(\"inside request\")\r\n    return None\r\n\r\napp1 = Litestar(\r\n    route_handlers=[hello_world1],\r\n    response_headers=[ResponseHeader(name=\"X-Version\", value=\"ABCD\", description=\"Test\")],\r\n)\r\n```\r\n\r\nThis endpoint works, but the resulting schema fails validation.\r\n\r\n```bash\r\n$ litestar schema openapi --output openapi_schema.json\r\n$ npx @redocly/cli lint openapi_schema.json\r\n\r\n...\r\n[1] openapi_schema.json:25:33 at #/paths/~1/get/responses/200/headers/X-Version/name\r\n\r\nProperty `name` is not expected here.\r\n\r\n23 |     \"type\": \"string\"\r\n24 | },\r\n25 | \"name\": \"X-Version\",\r\n26 | \"in\": \"header\",\r\n27 | \"description\": \"Test\",\r\n\r\nError was generated by the spec rule.\r\n\r\n\r\n[2] openapi_schema.json:26:33 at #/paths/~1/get/responses/200/headers/X-Version/in\r\n\r\nProperty `in` is not expected here.\r\n\r\n24 | },\r\n25 | \"name\": \"X-Version\",\r\n26 | \"in\": \"header\",\r\n27 | \"description\": \"Test\",\r\n28 | \"required\": false,\r\n...\r\n\r\n```\r\n\r\n\r\n### Steps to reproduce\r\n\r\n_No response_\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.8.2, using Python 3.12.2\r\n\r\n### Platform\r\n\r\n- [ ] Linux\r\n- [X] 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/3416\">\r\n<picture>\r\n  <source media=\"(prefers-color-scheme: dark)\" srcset=\"https://polar.sh/api/github/litestar-org/litestar/issues/3416/pledge.svg?darkmode=1\">\r\n  <img alt=\"Fund with Polar\" src=\"https://polar.sh/api/github/litestar-org/litestar/issues/3416/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 dataclasses import dataclass\nfrom typing import TYPE_CHECKING, Any, Literal\n\nfrom litestar.openapi.spec.base import BaseSchemaObject\n\nif TYPE_CHECKING:\n    from litestar.openapi.spec.example import Example\n    from litestar.openapi.spec.media_type import OpenAPIMediaType\n    from litestar.openapi.spec.reference import Reference\n    from litestar.openapi.spec.schema import Schema\n\n__all__ = (\"OpenAPIHeader\",)\n\n\n@dataclass\nclass OpenAPIHeader(BaseSchemaObject):\n    \"\"\"The Header Object follows the structure of the [Parameter\n    Object](https://spec.openapis.org/oas/v3.1.0#parameterObject) with the\n    following changes:\n\n    1. ``name`` MUST NOT be specified, it is given in the corresponding ``headers`` map.\n    2. ``in`` MUST NOT be specified, it is implicitly in ``header``.\n    3. All traits that are affected by the location MUST be applicable to a location of ``header``\n       (for example, `style <https://spec.openapis.org/oas/v3.1.0#parameterStyle>`__).\n    \"\"\"\n\n    schema: Schema | Reference | None = None\n    \"\"\"The schema defining the type used for the parameter.\"\"\"\n\n    name: Literal[\"\"] = \"\"\n    \"\"\"MUST NOT be specified, it is given in the corresponding ``headers`` map.\"\"\"\n\n    param_in: Literal[\"header\"] = \"header\"\n    \"\"\"MUST NOT be specified, it is implicitly in ``header``.\"\"\"\n\n    description: str | None = None\n    \"\"\"A brief description of the parameter. This could contain examples of\n    use.\n\n    `CommonMark syntax <https://spec.commonmark.org/>`_ MAY be used for rich text representation.\n    \"\"\"\n\n    required: bool = False\n    \"\"\"Determines whether this parameter is mandatory.\n\n    If the `parameter location <https://spec.openapis.org/oas/v3.1.0#parameterIn>`_ is ``\"path\"``, this property is\n    **REQUIRED** and its value MUST be ``True``. Otherwise, the property MAY be included and its default value is\n    ``False``.\n    \"\"\"\n\n    deprecated: bool = False\n    \"\"\"Specifies that a parameter is deprecated and SHOULD be transitioned out of usage. Default value is ``False``.\"\"\"\n\n    allow_empty_value: bool = False\n    \"\"\"Sets the ability to pass empty-valued parameters. This is valid only for ``query`` parameters and allows sending\n    a parameter with an empty value. Default value is ``False``. If\n    `style <https://spec.openapis.org/oas/v3.1.0#parameterStyle>`__ is used, and if behavior is ``n/a`` (cannot be\n    serialized), the value of ``allowEmptyValue`` SHALL be ignored. Use of this property is NOT RECOMMENDED, as it is\n    likely to be removed in a later revision.\n\n    The rules for serialization of the parameter are specified in one of two ways.For simpler scenarios, a\n    `schema <https://spec.openapis.org/oas/v3.1.0#parameterSchema>`_ and\n    `style <https://spec.openapis.org/oas/v3.1.0#parameterStyle>`__ can describe the structure and syntax of the\n    parameter.\n    \"\"\"\n\n    style: str | None = None\n    \"\"\"Describes how the parameter value will be serialized depending on the\n    type of the parameter value. Default values (based on value of ``in``):\n\n    - for ``query`` - ``form``;\n    - for ``path`` - ``simple``;\n    - for ``header`` - ``simple``;\n    - for ``cookie`` - ``form``.\n    \"\"\"\n\n    explode: bool | None = None\n    \"\"\"When this is true, parameter values of type ``array`` or ``object`` generate separate parameters for each value\n    of the array or key-value pair of the map.\n\n    For other types of parameters this property has no effect.When\n    `style <https://spec.openapis.org/oas/v3.1.0#parameterStyle>`__ is ``form``, the default value is ``True``. For all\n    other styles, the default value is ``False``.\n    \"\"\"\n\n    allow_reserved: bool = False\n    \"\"\"Determines whether the parameter value SHOULD allow reserved characters, as defined by. :rfc:`3986`\n    (``:/?#[]@!$&'()*+,;=``) to be included without percent-encoding.\n\n    This property only applies to parameters with an ``in`` value of ``query``. The default value is ``False``.\n    \"\"\"\n\n    example: Any | None = None\n    \"\"\"Example of the parameter's potential value.\n\n    The example SHOULD match the specified schema and encoding properties if present. The ``example`` field is mutually\n    exclusive of the ``examples`` field. Furthermore, if referencing a ``schema`` that contains an example, the\n    ``example`` value SHALL _override_ the example provided by the schema. To represent examples of media types that\n    cannot naturally be represented in JSON or YAML, a string value can contain the example with escaping where\n    necessary.\n    \"\"\"\n\n    examples: dict[str, Example | Reference] | None = None\n    \"\"\"Examples of the parameter's potential value. Each example SHOULD contain a value in the correct format as\n    specified in the parameter encoding. The ``examples`` field is mutually exclusive of the ``example`` field.\n    Furthermore, if referencing a ``schema`` that contains an example, the ``examples`` value SHALL _override_ the\n    example provided by the schema.\n\n    For more complex scenarios, the `content <https://spec.openapis.org/oas/v3.1.0#parameterContent>`_ property can\n    define the media type and schema of the parameter. A parameter MUST contain either a ``schema`` property, or a\n    ``content`` property, but not both. When ``example`` or ``examples`` are provided in conjunction with the ``schema``\n    object, the example MUST follow the prescribed serialization strategy for the parameter.\n    \"\"\"\n\n    content: dict[str, OpenAPIMediaType] | None = None\n    \"\"\"A map containing the representations for the parameter.\n\n    The key is the media type and the value describes it. The map MUST only contain one entry.\n    \"\"\"\n", "path": "litestar/openapi/spec/header.py"}, {"content": "from __future__ import annotations\n\nfrom dataclasses import asdict, dataclass, fields, is_dataclass\nfrom enum import Enum\nfrom typing import Any\n\n__all__ = (\"BaseSchemaObject\",)\n\n\ndef _normalize_key(key: str) -> str:\n    if key.endswith(\"_in\"):\n        return \"in\"\n    if key.startswith(\"schema_\"):\n        return key.split(\"_\")[1]\n    if \"_\" in key:\n        components = key.split(\"_\")\n        return components[0] + \"\".join(component.title() for component in components[1:])\n    return \"$ref\" if key == \"ref\" else key\n\n\ndef _normalize_value(value: Any) -> Any:\n    if isinstance(value, BaseSchemaObject):\n        return value.to_schema()\n    if is_dataclass(value):\n        return {_normalize_value(k): _normalize_value(v) for k, v in asdict(value).items() if v is not None}\n    if isinstance(value, dict):\n        return {_normalize_value(k): _normalize_value(v) for k, v in value.items() if v is not None}\n    if isinstance(value, list):\n        return [_normalize_value(v) for v in value]\n    return value.value if isinstance(value, Enum) else value\n\n\n@dataclass\nclass BaseSchemaObject:\n    \"\"\"Base class for schema spec objects\"\"\"\n\n    def to_schema(self) -> dict[str, Any]:\n        \"\"\"Transform the spec dataclass object into a string keyed dictionary. This method traverses all nested values\n        recursively.\n        \"\"\"\n        result: dict[str, Any] = {}\n\n        for field in fields(self):\n            value = _normalize_value(getattr(self, field.name, None))\n\n            if value is not None:\n                if \"alias\" in field.metadata:\n                    if not isinstance(field.metadata[\"alias\"], str):\n                        raise TypeError('metadata[\"alias\"] must be a str')\n                    key = field.metadata[\"alias\"]\n                else:\n                    key = _normalize_key(field.name)\n\n                result[key] = value\n\n        return result\n", "path": "litestar/openapi/spec/base.py"}], "after_files": [{"content": "from __future__ import annotations\n\nfrom dataclasses import Field, dataclass\nfrom typing import TYPE_CHECKING, Any, Iterator, Literal\n\nfrom typing_extensions import override\n\nfrom litestar.openapi.spec.base import BaseSchemaObject\n\nif TYPE_CHECKING:\n    from litestar.openapi.spec.example import Example\n    from litestar.openapi.spec.media_type import OpenAPIMediaType\n    from litestar.openapi.spec.reference import Reference\n    from litestar.openapi.spec.schema import Schema\n\n__all__ = (\"OpenAPIHeader\",)\n\n\n@dataclass\nclass OpenAPIHeader(BaseSchemaObject):\n    \"\"\"The Header Object follows the structure of the [Parameter\n    Object](https://spec.openapis.org/oas/v3.1.0#parameterObject) with the\n    following changes:\n\n    1. ``name`` MUST NOT be specified, it is given in the corresponding ``headers`` map.\n    2. ``in`` MUST NOT be specified, it is implicitly in ``header``.\n    3. All traits that are affected by the location MUST be applicable to a location of ``header``\n       (for example, `style <https://spec.openapis.org/oas/v3.1.0#parameterStyle>`__).\n    \"\"\"\n\n    schema: Schema | Reference | None = None\n    \"\"\"The schema defining the type used for the parameter.\"\"\"\n\n    name: Literal[\"\"] = \"\"\n    \"\"\"MUST NOT be specified, it is given in the corresponding ``headers`` map.\"\"\"\n\n    param_in: Literal[\"header\"] = \"header\"\n    \"\"\"MUST NOT be specified, it is implicitly in ``header``.\"\"\"\n\n    description: str | None = None\n    \"\"\"A brief description of the parameter. This could contain examples of\n    use.\n\n    `CommonMark syntax <https://spec.commonmark.org/>`_ MAY be used for rich text representation.\n    \"\"\"\n\n    required: bool = False\n    \"\"\"Determines whether this parameter is mandatory.\n\n    If the `parameter location <https://spec.openapis.org/oas/v3.1.0#parameterIn>`_ is ``\"path\"``, this property is\n    **REQUIRED** and its value MUST be ``True``. Otherwise, the property MAY be included and its default value is\n    ``False``.\n    \"\"\"\n\n    deprecated: bool = False\n    \"\"\"Specifies that a parameter is deprecated and SHOULD be transitioned out of usage. Default value is ``False``.\"\"\"\n\n    allow_empty_value: bool = False\n    \"\"\"Sets the ability to pass empty-valued parameters. This is valid only for ``query`` parameters and allows sending\n    a parameter with an empty value. Default value is ``False``. If\n    `style <https://spec.openapis.org/oas/v3.1.0#parameterStyle>`__ is used, and if behavior is ``n/a`` (cannot be\n    serialized), the value of ``allowEmptyValue`` SHALL be ignored. Use of this property is NOT RECOMMENDED, as it is\n    likely to be removed in a later revision.\n\n    The rules for serialization of the parameter are specified in one of two ways.For simpler scenarios, a\n    `schema <https://spec.openapis.org/oas/v3.1.0#parameterSchema>`_ and\n    `style <https://spec.openapis.org/oas/v3.1.0#parameterStyle>`__ can describe the structure and syntax of the\n    parameter.\n    \"\"\"\n\n    style: str | None = None\n    \"\"\"Describes how the parameter value will be serialized depending on the\n    type of the parameter value. Default values (based on value of ``in``):\n\n    - for ``query`` - ``form``;\n    - for ``path`` - ``simple``;\n    - for ``header`` - ``simple``;\n    - for ``cookie`` - ``form``.\n    \"\"\"\n\n    explode: bool | None = None\n    \"\"\"When this is true, parameter values of type ``array`` or ``object`` generate separate parameters for each value\n    of the array or key-value pair of the map.\n\n    For other types of parameters this property has no effect.When\n    `style <https://spec.openapis.org/oas/v3.1.0#parameterStyle>`__ is ``form``, the default value is ``True``. For all\n    other styles, the default value is ``False``.\n    \"\"\"\n\n    allow_reserved: bool = False\n    \"\"\"Determines whether the parameter value SHOULD allow reserved characters, as defined by. :rfc:`3986`\n    (``:/?#[]@!$&'()*+,;=``) to be included without percent-encoding.\n\n    This property only applies to parameters with an ``in`` value of ``query``. The default value is ``False``.\n    \"\"\"\n\n    example: Any | None = None\n    \"\"\"Example of the parameter's potential value.\n\n    The example SHOULD match the specified schema and encoding properties if present. The ``example`` field is mutually\n    exclusive of the ``examples`` field. Furthermore, if referencing a ``schema`` that contains an example, the\n    ``example`` value SHALL _override_ the example provided by the schema. To represent examples of media types that\n    cannot naturally be represented in JSON or YAML, a string value can contain the example with escaping where\n    necessary.\n    \"\"\"\n\n    examples: dict[str, Example | Reference] | None = None\n    \"\"\"Examples of the parameter's potential value. Each example SHOULD contain a value in the correct format as\n    specified in the parameter encoding. The ``examples`` field is mutually exclusive of the ``example`` field.\n    Furthermore, if referencing a ``schema`` that contains an example, the ``examples`` value SHALL _override_ the\n    example provided by the schema.\n\n    For more complex scenarios, the `content <https://spec.openapis.org/oas/v3.1.0#parameterContent>`_ property can\n    define the media type and schema of the parameter. A parameter MUST contain either a ``schema`` property, or a\n    ``content`` property, but not both. When ``example`` or ``examples`` are provided in conjunction with the ``schema``\n    object, the example MUST follow the prescribed serialization strategy for the parameter.\n    \"\"\"\n\n    content: dict[str, OpenAPIMediaType] | None = None\n    \"\"\"A map containing the representations for the parameter.\n\n    The key is the media type and the value describes it. The map MUST only contain one entry.\n    \"\"\"\n\n    @override\n    def _iter_fields(self) -> Iterator[Field[Any]]:\n        yield from (f for f in super()._iter_fields() if f.name not in {\"name\", \"param_in\"})\n", "path": "litestar/openapi/spec/header.py"}, {"content": "from __future__ import annotations\n\nfrom dataclasses import asdict, dataclass, fields, is_dataclass\nfrom enum import Enum\nfrom typing import TYPE_CHECKING, Any\n\nif TYPE_CHECKING:\n    from collections.abc import Iterator\n    from dataclasses import Field\n\n__all__ = (\"BaseSchemaObject\",)\n\n\ndef _normalize_key(key: str) -> str:\n    if key.endswith(\"_in\"):\n        return \"in\"\n    if key.startswith(\"schema_\"):\n        return key.split(\"_\")[1]\n    if \"_\" in key:\n        components = key.split(\"_\")\n        return components[0] + \"\".join(component.title() for component in components[1:])\n    return \"$ref\" if key == \"ref\" else key\n\n\ndef _normalize_value(value: Any) -> Any:\n    if isinstance(value, BaseSchemaObject):\n        return value.to_schema()\n    if is_dataclass(value):\n        return {_normalize_value(k): _normalize_value(v) for k, v in asdict(value).items() if v is not None}\n    if isinstance(value, dict):\n        return {_normalize_value(k): _normalize_value(v) for k, v in value.items() if v is not None}\n    if isinstance(value, list):\n        return [_normalize_value(v) for v in value]\n    return value.value if isinstance(value, Enum) else value\n\n\n@dataclass\nclass BaseSchemaObject:\n    \"\"\"Base class for schema spec objects\"\"\"\n\n    def _iter_fields(self) -> Iterator[Field[Any]]:\n        yield from fields(self)\n\n    def to_schema(self) -> dict[str, Any]:\n        \"\"\"Transform the spec dataclass object into a string keyed dictionary. This method traverses all nested values\n        recursively.\n        \"\"\"\n        result: dict[str, Any] = {}\n\n        for field in self._iter_fields():\n            value = _normalize_value(getattr(self, field.name, None))\n\n            if value is not None:\n                if \"alias\" in field.metadata:\n                    if not isinstance(field.metadata[\"alias\"], str):\n                        raise TypeError('metadata[\"alias\"] must be a str')\n                    key = field.metadata[\"alias\"]\n                else:\n                    key = _normalize_key(field.name)\n\n                result[key] = value\n\n        return result\n", "path": "litestar/openapi/spec/base.py"}]}