Repository: litestar-org/litestar

Issue:
Bug: default not generated for query parameter in openapi spec.
### Description

Hi,

The default of a query parameter is not properly generated when creating the openapi specification. See MVCE down below.

The generated specification looks like this:

```json
...
"paths": {
    "/query_default": {
      "get": {
        "summary": "QueryDefault",
        "operationId": "QueryDefaultQueryDefault",
        "parameters": [
          {
            "name": "foo",
            "in": "query",
            "schema": {
              "type": "integer"
            },
            "required": false,
            "deprecated": false,
            "allowEmptyValue": false,
            "allowReserved": false
          }
        ],
...
```
where the default is missing in the schema property.

### URL to code causing the issue

_No response_

### MCVE

```python
@get(path="query_default")
def query_default(foo: int = 12) -> None:
    return

app = Litestar(route_handlers=[query_default])
```


### Steps to reproduce

_No response_

### Screenshots

_No response_

### Logs

_No response_

### Litestar Version

Version 2.7.1

### 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/3278">
<picture>
  <source media="(prefers-color-scheme: dark)" srcset="https://polar.sh/api/github/litestar-org/litestar/issues/3278/pledge.svg?darkmode=1">
  <img alt="Fund with Polar" src="https://polar.sh/api/github/litestar-org/litestar/issues/3278/pledge.svg">
</picture>
</a>
<!-- POLAR PLEDGE BADGE END -->



Discussion:
Could you confirm that this is also true in 2.7.0?
Same result with fixed version 2.7.0
```toml
dependencies = [
    "litestar[standard]==2.7.0"
]
```
Thanks!
I don't think this is a bug. The [specification](https://spec.openapis.org/oas/latest.html#parameter-object) doesn't have a field to indicate a default value for parameters.
Sorry about that. I was completely wrong. While it's correct that the parameter object as per the spec doesn't allow for defaults, it does allow for a `schema` which *can* have a default value. 

Us not parsing the default properly is a bug. 
Just leaving this here in case you need a workaround. You can use `Annotated[int, Parameter(default=12)]` to get the behavior you expect.

```py
from typing_extensions import Annotated
from litestar import Litestar, get
from litestar.params import Parameter

@get(path="query_default")
async def query_default(foo: Annotated[int, Parameter(default=12)]) -> None:
    return

app = Litestar(route_handlers=[query_default])
```

Resolving patch:
diff --git a/litestar/_openapi/schema_generation/schema.py b/litestar/_openapi/schema_generation/schema.py
--- a/litestar/_openapi/schema_generation/schema.py
+++ b/litestar/_openapi/schema_generation/schema.py
@@ -569,6 +569,9 @@ def process_schema_result(self, field: FieldDefinition, schema: Schema) -> Schem
                     if getattr(schema, schema_key, None) is None:
                         setattr(schema, schema_key, value)
 
+        if schema.default is None and field.default is not Empty:
+            schema.default = field.default
+
         if not schema.examples and self.generate_examples:
             from litestar._openapi.schema_generation.examples import create_examples_for_field
 


Test patch:
diff --git a/tests/unit/test_openapi/test_schema.py b/tests/unit/test_openapi/test_schema.py
--- a/tests/unit/test_openapi/test_schema.py
+++ b/tests/unit/test_openapi/test_schema.py
@@ -37,7 +37,7 @@
 from litestar.openapi.spec.example import Example
 from litestar.openapi.spec.schema import Schema
 from litestar.pagination import ClassicPagination, CursorPagination, OffsetPagination
-from litestar.params import Parameter, ParameterKwarg
+from litestar.params import KwargDefinition, Parameter, ParameterKwarg
 from litestar.testing import create_test_client
 from litestar.types.builtin_types import NoneType
 from litestar.typing import FieldDefinition
@@ -555,3 +555,18 @@ class ModelB(base_type):  # type: ignore[no-redef, misc]
         Reference(ref="#/components/schemas/tests_unit_test_openapi_test_schema_test_type_union_with_none.ModelA"),
         Reference("#/components/schemas/tests_unit_test_openapi_test_schema_test_type_union_with_none.ModelB"),
     ]
+
+
+def test_default_only_on_field_definition() -> None:
+    field_definition = FieldDefinition.from_annotation(int, default=10)
+    assert field_definition.kwarg_definition is None
+
+    schema = get_schema_for_field_definition(field_definition)
+    assert schema.default == 10
+
+
+def test_default_not_provided_for_kwarg_but_for_field() -> None:
+    field_definition = FieldDefinition.from_annotation(int, default=10, kwarg_definition=KwargDefinition())
+    schema = get_schema_for_field_definition(field_definition)
+
+    assert schema.default == 10