We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
JSON Schema `const` value and type ignored when setting defaults for Pydantic V2
**Describe the bug**
Use of `--force-optional` clobbers `--use-one-literal-as-default`. In my opinion `--force-optional` should use defaults where they exist and only fall back to assigning to `None` where they don't exist.

### Input

```json
{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "type": "object",
    "title": "Force optional demo",
    "properties": {
        "foo": {
            "const": "foo"
        }
    }
}
```

### Used command
```
datamodel-codegen --input force-optional-demo.json --output-model-type pydantic_v2.BaseModel --force-optional --use-one-literal-as-default
```

### Actual output

```python
# generated by datamodel-codegen:
#   filename:  force-optional-demo.json
#   timestamp: 2023-12-05T15:06:01+00:00

from __future__ import annotations

from pydantic import BaseModel
from typing_extensions import Literal


class ForceOptionalDemo(BaseModel):
    foo: Literal['foo'] = None
```

### Expected output

```python
# generated by datamodel-codegen:
#   filename:  force-optional-demo.json
#   timestamp: 2023-12-05T15:06:01+00:00

from __future__ import annotations

from pydantic import BaseModel
from typing_extensions import Literal


class ForceOptionalDemo(BaseModel):
    foo: Literal['foo'] = 'foo'
```

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `datamodel_code_generator/model/pydantic_v2/base_model.py`
Content:
```
1 from pathlib import Path
2 from typing import (
3     TYPE_CHECKING,
4     Any,
5     ClassVar,
6     DefaultDict,
7     Dict,
8     List,
9     NamedTuple,
10     Optional,
11     Set,
12 )
13 
14 from pydantic import Field
15 
16 from datamodel_code_generator.model.base import UNDEFINED, DataModelFieldBase
17 from datamodel_code_generator.model.pydantic.base_model import (
18     BaseModelBase,
19 )
20 from datamodel_code_generator.model.pydantic.base_model import (
21     Constraints as _Constraints,
22 )
23 from datamodel_code_generator.model.pydantic.base_model import (
24     DataModelField as DataModelFieldV1,
25 )
26 from datamodel_code_generator.model.pydantic_v2.imports import IMPORT_CONFIG_DICT
27 from datamodel_code_generator.reference import Reference
28 from datamodel_code_generator.util import field_validator, model_validator
29 
30 if TYPE_CHECKING:
31     from typing_extensions import Literal
32 else:
33     try:
34         from typing import Literal
35     except ImportError:
36         from typing_extensions import Literal
37 
38 
39 class Constraints(_Constraints):
40     # To override existing pattern alias
41     regex: Optional[str] = Field(None, alias='regex')
42     pattern: Optional[str] = Field(None, alias='pattern')
43 
44     @model_validator(mode='before')
45     def validate_min_max_items(cls, values: Any) -> Dict[str, Any]:
46         if not isinstance(values, dict):  # pragma: no cover
47             return values
48         min_items = values.pop('minItems', None)
49         if min_items is not None:
50             values['minLength'] = min_items
51         max_items = values.pop('maxItems', None)
52         if max_items is not None:
53             values['maxLength'] = max_items
54         return values
55 
56 
57 class DataModelField(DataModelFieldV1):
58     _EXCLUDE_FIELD_KEYS: ClassVar[Set[str]] = {
59         'alias',
60         'default',
61         'gt',
62         'ge',
63         'lt',
64         'le',
65         'multiple_of',
66         'min_length',
67         'max_length',
68         'pattern',
69     }
70     constraints: Optional[Constraints] = None
71     _PARSE_METHOD: ClassVar[str] = 'model_validate'
72 
73     @field_validator('extras')
74     def validate_extras(cls, values: Any) -> Dict[str, Any]:
75         if not isinstance(values, dict):
76             return values
77         if 'examples' in values:
78             return values
79 
80         if 'example' in values:
81             values['examples'] = [values.pop('example')]
82         return values
83 
84     def process_const(self) -> None:
85         if 'const' not in self.extras:
86             return None
87         self.const = True
88         self.nullable = False
89         const = self.extras['const']
90         if self.data_type.type == 'str' and isinstance(
91             const, str
92         ):  # pragma: no cover # Literal supports only str
93             self.data_type = self.data_type.__class__(literals=[const])
94 
95     def _process_data_in_str(self, data: Dict[str, Any]) -> None:
96         if self.const:
97             # const is removed in pydantic 2.0
98             data.pop('const')
99 
100         # unique_items is not supported in pydantic 2.0
101         data.pop('unique_items', None)
102 
103     def _process_annotated_field_arguments(
104         self, field_arguments: List[str]
105     ) -> List[str]:
106         if not self.required:
107             if self.use_default_kwarg:
108                 return [
109                     f'default={repr(self.default)}',
110                     *field_arguments,
111                 ]
112             else:
113                 # TODO: Allow '=' style default for v1?
114                 return [f'{repr(self.default)}', *field_arguments]
115         return field_arguments
116 
117 
118 class ConfigAttribute(NamedTuple):
119     from_: str
120     to: str
121     invert: bool
122 
123 
124 class BaseModel(BaseModelBase):
125     TEMPLATE_FILE_PATH: ClassVar[str] = 'pydantic_v2/BaseModel.jinja2'
126     BASE_CLASS: ClassVar[str] = 'pydantic.BaseModel'
127     CONFIG_ATTRIBUTES: ClassVar[List[ConfigAttribute]] = [
128         ConfigAttribute('allow_population_by_field_name', 'populate_by_name', False),
129         ConfigAttribute('populate_by_name', 'populate_by_name', False),
130         ConfigAttribute('allow_mutation', 'frozen', True),
131         ConfigAttribute('frozen', 'frozen', False),
132     ]
133 
134     def __init__(
135         self,
136         *,
137         reference: Reference,
138         fields: List[DataModelFieldBase],
139         decorators: Optional[List[str]] = None,
140         base_classes: Optional[List[Reference]] = None,
141         custom_base_class: Optional[str] = None,
142         custom_template_dir: Optional[Path] = None,
143         extra_template_data: Optional[DefaultDict[str, Any]] = None,
144         path: Optional[Path] = None,
145         description: Optional[str] = None,
146         default: Any = UNDEFINED,
147         nullable: bool = False,
148     ) -> None:
149         super().__init__(
150             reference=reference,
151             fields=fields,
152             decorators=decorators,
153             base_classes=base_classes,
154             custom_base_class=custom_base_class,
155             custom_template_dir=custom_template_dir,
156             extra_template_data=extra_template_data,
157             path=path,
158             description=description,
159             default=default,
160             nullable=nullable,
161         )
162         config_parameters: Dict[str, Any] = {}
163 
164         extra = self._get_config_extra()
165         if extra:
166             config_parameters['extra'] = extra
167 
168         for from_, to, invert in self.CONFIG_ATTRIBUTES:
169             if from_ in self.extra_template_data:
170                 config_parameters[to] = (
171                     not self.extra_template_data[from_]
172                     if invert
173                     else self.extra_template_data[from_]
174                 )
175         for data_type in self.all_data_types:
176             if data_type.is_custom_type:
177                 config_parameters['arbitrary_types_allowed'] = True
178                 break
179 
180         if isinstance(self.extra_template_data.get('config'), dict):
181             for key, value in self.extra_template_data['config'].items():
182                 config_parameters[key] = value
183 
184         if config_parameters:
185             from datamodel_code_generator.model.pydantic_v2 import ConfigDict
186 
187             self.extra_template_data['config'] = ConfigDict.parse_obj(config_parameters)
188             self._additional_imports.append(IMPORT_CONFIG_DICT)
189 
190     def _get_config_extra(self) -> Optional[Literal["'allow'", "'forbid'"]]:
191         additionalProperties = self.extra_template_data.get('additionalProperties')
192         allow_extra_fields = self.extra_template_data.get('allow_extra_fields')
193         if additionalProperties is not None or allow_extra_fields:
194             return (
195                 "'allow'" if additionalProperties or allow_extra_fields else "'forbid'"
196             )
197         return None
198
```
--- 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/datamodel_code_generator/model/pydantic_v2/base_model.py b/datamodel_code_generator/model/pydantic_v2/base_model.py
--- a/datamodel_code_generator/model/pydantic_v2/base_model.py
+++ b/datamodel_code_generator/model/pydantic_v2/base_model.py
@@ -87,10 +87,9 @@
         self.const = True
         self.nullable = False
         const = self.extras['const']
-        if self.data_type.type == 'str' and isinstance(
-            const, str
-        ):  # pragma: no cover # Literal supports only str
-            self.data_type = self.data_type.__class__(literals=[const])
+        self.data_type = self.data_type.__class__(literals=[const])
+        if not self.default:
+            self.default = const
 
     def _process_data_in_str(self, data: Dict[str, Any]) -> None:
         if self.const:
@@ -103,7 +102,7 @@
     def _process_annotated_field_arguments(
         self, field_arguments: List[str]
     ) -> List[str]:
-        if not self.required:
+        if not self.required or self.const:
             if self.use_default_kwarg:
                 return [
                     f'default={repr(self.default)}',

{"golden_diff": "diff --git a/datamodel_code_generator/model/pydantic_v2/base_model.py b/datamodel_code_generator/model/pydantic_v2/base_model.py\n--- a/datamodel_code_generator/model/pydantic_v2/base_model.py\n+++ b/datamodel_code_generator/model/pydantic_v2/base_model.py\n@@ -87,10 +87,9 @@\n         self.const = True\n         self.nullable = False\n         const = self.extras['const']\n-        if self.data_type.type == 'str' and isinstance(\n-            const, str\n-        ):  # pragma: no cover # Literal supports only str\n-            self.data_type = self.data_type.__class__(literals=[const])\n+        self.data_type = self.data_type.__class__(literals=[const])\n+        if not self.default:\n+            self.default = const\n \n     def _process_data_in_str(self, data: Dict[str, Any]) -> None:\n         if self.const:\n@@ -103,7 +102,7 @@\n     def _process_annotated_field_arguments(\n         self, field_arguments: List[str]\n     ) -> List[str]:\n-        if not self.required:\n+        if not self.required or self.const:\n             if self.use_default_kwarg:\n                 return [\n                     f'default={repr(self.default)}',\n", "issue": "JSON Schema `const` value and type ignored when setting defaults for Pydantic V2\n**Describe the bug**\r\nUse of `--force-optional` clobbers `--use-one-literal-as-default`. In my opinion `--force-optional` should use defaults where they exist and only fall back to assigning to `None` where they don't exist.\r\n\r\n### Input\r\n\r\n```json\r\n{\r\n    \"$schema\": \"http://json-schema.org/draft-07/schema#\",\r\n    \"type\": \"object\",\r\n    \"title\": \"Force optional demo\",\r\n    \"properties\": {\r\n        \"foo\": {\r\n            \"const\": \"foo\"\r\n        }\r\n    }\r\n}\r\n```\r\n\r\n### Used command\r\n```\r\ndatamodel-codegen --input force-optional-demo.json --output-model-type pydantic_v2.BaseModel --force-optional --use-one-literal-as-default\r\n```\r\n\r\n### Actual output\r\n\r\n```python\r\n# generated by datamodel-codegen:\r\n#   filename:  force-optional-demo.json\r\n#   timestamp: 2023-12-05T15:06:01+00:00\r\n\r\nfrom __future__ import annotations\r\n\r\nfrom pydantic import BaseModel\r\nfrom typing_extensions import Literal\r\n\r\n\r\nclass ForceOptionalDemo(BaseModel):\r\n    foo: Literal['foo'] = None\r\n```\r\n\r\n### Expected output\r\n\r\n```python\r\n# generated by datamodel-codegen:\r\n#   filename:  force-optional-demo.json\r\n#   timestamp: 2023-12-05T15:06:01+00:00\r\n\r\nfrom __future__ import annotations\r\n\r\nfrom pydantic import BaseModel\r\nfrom typing_extensions import Literal\r\n\r\n\r\nclass ForceOptionalDemo(BaseModel):\r\n    foo: Literal['foo'] = 'foo'\r\n```\n", "before_files": [{"content": "from pathlib import Path\nfrom typing import (\n    TYPE_CHECKING,\n    Any,\n    ClassVar,\n    DefaultDict,\n    Dict,\n    List,\n    NamedTuple,\n    Optional,\n    Set,\n)\n\nfrom pydantic import Field\n\nfrom datamodel_code_generator.model.base import UNDEFINED, DataModelFieldBase\nfrom datamodel_code_generator.model.pydantic.base_model import (\n    BaseModelBase,\n)\nfrom datamodel_code_generator.model.pydantic.base_model import (\n    Constraints as _Constraints,\n)\nfrom datamodel_code_generator.model.pydantic.base_model import (\n    DataModelField as DataModelFieldV1,\n)\nfrom datamodel_code_generator.model.pydantic_v2.imports import IMPORT_CONFIG_DICT\nfrom datamodel_code_generator.reference import Reference\nfrom datamodel_code_generator.util import field_validator, model_validator\n\nif TYPE_CHECKING:\n    from typing_extensions import Literal\nelse:\n    try:\n        from typing import Literal\n    except ImportError:\n        from typing_extensions import Literal\n\n\nclass Constraints(_Constraints):\n    # To override existing pattern alias\n    regex: Optional[str] = Field(None, alias='regex')\n    pattern: Optional[str] = Field(None, alias='pattern')\n\n    @model_validator(mode='before')\n    def validate_min_max_items(cls, values: Any) -> Dict[str, Any]:\n        if not isinstance(values, dict):  # pragma: no cover\n            return values\n        min_items = values.pop('minItems', None)\n        if min_items is not None:\n            values['minLength'] = min_items\n        max_items = values.pop('maxItems', None)\n        if max_items is not None:\n            values['maxLength'] = max_items\n        return values\n\n\nclass DataModelField(DataModelFieldV1):\n    _EXCLUDE_FIELD_KEYS: ClassVar[Set[str]] = {\n        'alias',\n        'default',\n        'gt',\n        'ge',\n        'lt',\n        'le',\n        'multiple_of',\n        'min_length',\n        'max_length',\n        'pattern',\n    }\n    constraints: Optional[Constraints] = None\n    _PARSE_METHOD: ClassVar[str] = 'model_validate'\n\n    @field_validator('extras')\n    def validate_extras(cls, values: Any) -> Dict[str, Any]:\n        if not isinstance(values, dict):\n            return values\n        if 'examples' in values:\n            return values\n\n        if 'example' in values:\n            values['examples'] = [values.pop('example')]\n        return values\n\n    def process_const(self) -> None:\n        if 'const' not in self.extras:\n            return None\n        self.const = True\n        self.nullable = False\n        const = self.extras['const']\n        if self.data_type.type == 'str' and isinstance(\n            const, str\n        ):  # pragma: no cover # Literal supports only str\n            self.data_type = self.data_type.__class__(literals=[const])\n\n    def _process_data_in_str(self, data: Dict[str, Any]) -> None:\n        if self.const:\n            # const is removed in pydantic 2.0\n            data.pop('const')\n\n        # unique_items is not supported in pydantic 2.0\n        data.pop('unique_items', None)\n\n    def _process_annotated_field_arguments(\n        self, field_arguments: List[str]\n    ) -> List[str]:\n        if not self.required:\n            if self.use_default_kwarg:\n                return [\n                    f'default={repr(self.default)}',\n                    *field_arguments,\n                ]\n            else:\n                # TODO: Allow '=' style default for v1?\n                return [f'{repr(self.default)}', *field_arguments]\n        return field_arguments\n\n\nclass ConfigAttribute(NamedTuple):\n    from_: str\n    to: str\n    invert: bool\n\n\nclass BaseModel(BaseModelBase):\n    TEMPLATE_FILE_PATH: ClassVar[str] = 'pydantic_v2/BaseModel.jinja2'\n    BASE_CLASS: ClassVar[str] = 'pydantic.BaseModel'\n    CONFIG_ATTRIBUTES: ClassVar[List[ConfigAttribute]] = [\n        ConfigAttribute('allow_population_by_field_name', 'populate_by_name', False),\n        ConfigAttribute('populate_by_name', 'populate_by_name', False),\n        ConfigAttribute('allow_mutation', 'frozen', True),\n        ConfigAttribute('frozen', 'frozen', False),\n    ]\n\n    def __init__(\n        self,\n        *,\n        reference: Reference,\n        fields: List[DataModelFieldBase],\n        decorators: Optional[List[str]] = None,\n        base_classes: Optional[List[Reference]] = None,\n        custom_base_class: Optional[str] = None,\n        custom_template_dir: Optional[Path] = None,\n        extra_template_data: Optional[DefaultDict[str, Any]] = None,\n        path: Optional[Path] = None,\n        description: Optional[str] = None,\n        default: Any = UNDEFINED,\n        nullable: bool = False,\n    ) -> None:\n        super().__init__(\n            reference=reference,\n            fields=fields,\n            decorators=decorators,\n            base_classes=base_classes,\n            custom_base_class=custom_base_class,\n            custom_template_dir=custom_template_dir,\n            extra_template_data=extra_template_data,\n            path=path,\n            description=description,\n            default=default,\n            nullable=nullable,\n        )\n        config_parameters: Dict[str, Any] = {}\n\n        extra = self._get_config_extra()\n        if extra:\n            config_parameters['extra'] = extra\n\n        for from_, to, invert in self.CONFIG_ATTRIBUTES:\n            if from_ in self.extra_template_data:\n                config_parameters[to] = (\n                    not self.extra_template_data[from_]\n                    if invert\n                    else self.extra_template_data[from_]\n                )\n        for data_type in self.all_data_types:\n            if data_type.is_custom_type:\n                config_parameters['arbitrary_types_allowed'] = True\n                break\n\n        if isinstance(self.extra_template_data.get('config'), dict):\n            for key, value in self.extra_template_data['config'].items():\n                config_parameters[key] = value\n\n        if config_parameters:\n            from datamodel_code_generator.model.pydantic_v2 import ConfigDict\n\n            self.extra_template_data['config'] = ConfigDict.parse_obj(config_parameters)\n            self._additional_imports.append(IMPORT_CONFIG_DICT)\n\n    def _get_config_extra(self) -> Optional[Literal[\"'allow'\", \"'forbid'\"]]:\n        additionalProperties = self.extra_template_data.get('additionalProperties')\n        allow_extra_fields = self.extra_template_data.get('allow_extra_fields')\n        if additionalProperties is not None or allow_extra_fields:\n            return (\n                \"'allow'\" if additionalProperties or allow_extra_fields else \"'forbid'\"\n            )\n        return None\n", "path": "datamodel_code_generator/model/pydantic_v2/base_model.py"}], "after_files": [{"content": "from pathlib import Path\nfrom typing import (\n    TYPE_CHECKING,\n    Any,\n    ClassVar,\n    DefaultDict,\n    Dict,\n    List,\n    NamedTuple,\n    Optional,\n    Set,\n)\n\nfrom pydantic import Field\n\nfrom datamodel_code_generator.model.base import UNDEFINED, DataModelFieldBase\nfrom datamodel_code_generator.model.pydantic.base_model import (\n    BaseModelBase,\n)\nfrom datamodel_code_generator.model.pydantic.base_model import (\n    Constraints as _Constraints,\n)\nfrom datamodel_code_generator.model.pydantic.base_model import (\n    DataModelField as DataModelFieldV1,\n)\nfrom datamodel_code_generator.model.pydantic_v2.imports import IMPORT_CONFIG_DICT\nfrom datamodel_code_generator.reference import Reference\nfrom datamodel_code_generator.util import field_validator, model_validator\n\nif TYPE_CHECKING:\n    from typing_extensions import Literal\nelse:\n    try:\n        from typing import Literal\n    except ImportError:\n        from typing_extensions import Literal\n\n\nclass Constraints(_Constraints):\n    # To override existing pattern alias\n    regex: Optional[str] = Field(None, alias='regex')\n    pattern: Optional[str] = Field(None, alias='pattern')\n\n    @model_validator(mode='before')\n    def validate_min_max_items(cls, values: Any) -> Dict[str, Any]:\n        if not isinstance(values, dict):  # pragma: no cover\n            return values\n        min_items = values.pop('minItems', None)\n        if min_items is not None:\n            values['minLength'] = min_items\n        max_items = values.pop('maxItems', None)\n        if max_items is not None:\n            values['maxLength'] = max_items\n        return values\n\n\nclass DataModelField(DataModelFieldV1):\n    _EXCLUDE_FIELD_KEYS: ClassVar[Set[str]] = {\n        'alias',\n        'default',\n        'gt',\n        'ge',\n        'lt',\n        'le',\n        'multiple_of',\n        'min_length',\n        'max_length',\n        'pattern',\n    }\n    constraints: Optional[Constraints] = None\n    _PARSE_METHOD: ClassVar[str] = 'model_validate'\n\n    @field_validator('extras')\n    def validate_extras(cls, values: Any) -> Dict[str, Any]:\n        if not isinstance(values, dict):\n            return values\n        if 'examples' in values:\n            return values\n\n        if 'example' in values:\n            values['examples'] = [values.pop('example')]\n        return values\n\n    def process_const(self) -> None:\n        if 'const' not in self.extras:\n            return None\n        self.const = True\n        self.nullable = False\n        const = self.extras['const']\n        self.data_type = self.data_type.__class__(literals=[const])\n        if not self.default:\n            self.default = const\n\n    def _process_data_in_str(self, data: Dict[str, Any]) -> None:\n        if self.const:\n            # const is removed in pydantic 2.0\n            data.pop('const')\n\n        # unique_items is not supported in pydantic 2.0\n        data.pop('unique_items', None)\n\n    def _process_annotated_field_arguments(\n        self, field_arguments: List[str]\n    ) -> List[str]:\n        if not self.required or self.const:\n            if self.use_default_kwarg:\n                return [\n                    f'default={repr(self.default)}',\n                    *field_arguments,\n                ]\n            else:\n                # TODO: Allow '=' style default for v1?\n                return [f'{repr(self.default)}', *field_arguments]\n        return field_arguments\n\n\nclass ConfigAttribute(NamedTuple):\n    from_: str\n    to: str\n    invert: bool\n\n\nclass BaseModel(BaseModelBase):\n    TEMPLATE_FILE_PATH: ClassVar[str] = 'pydantic_v2/BaseModel.jinja2'\n    BASE_CLASS: ClassVar[str] = 'pydantic.BaseModel'\n    CONFIG_ATTRIBUTES: ClassVar[List[ConfigAttribute]] = [\n        ConfigAttribute('allow_population_by_field_name', 'populate_by_name', False),\n        ConfigAttribute('populate_by_name', 'populate_by_name', False),\n        ConfigAttribute('allow_mutation', 'frozen', True),\n        ConfigAttribute('frozen', 'frozen', False),\n    ]\n\n    def __init__(\n        self,\n        *,\n        reference: Reference,\n        fields: List[DataModelFieldBase],\n        decorators: Optional[List[str]] = None,\n        base_classes: Optional[List[Reference]] = None,\n        custom_base_class: Optional[str] = None,\n        custom_template_dir: Optional[Path] = None,\n        extra_template_data: Optional[DefaultDict[str, Any]] = None,\n        path: Optional[Path] = None,\n        description: Optional[str] = None,\n        default: Any = UNDEFINED,\n        nullable: bool = False,\n    ) -> None:\n        super().__init__(\n            reference=reference,\n            fields=fields,\n            decorators=decorators,\n            base_classes=base_classes,\n            custom_base_class=custom_base_class,\n            custom_template_dir=custom_template_dir,\n            extra_template_data=extra_template_data,\n            path=path,\n            description=description,\n            default=default,\n            nullable=nullable,\n        )\n        config_parameters: Dict[str, Any] = {}\n\n        extra = self._get_config_extra()\n        if extra:\n            config_parameters['extra'] = extra\n\n        for from_, to, invert in self.CONFIG_ATTRIBUTES:\n            if from_ in self.extra_template_data:\n                config_parameters[to] = (\n                    not self.extra_template_data[from_]\n                    if invert\n                    else self.extra_template_data[from_]\n                )\n        for data_type in self.all_data_types:\n            if data_type.is_custom_type:\n                config_parameters['arbitrary_types_allowed'] = True\n                break\n\n        if isinstance(self.extra_template_data.get('config'), dict):\n            for key, value in self.extra_template_data['config'].items():\n                config_parameters[key] = value\n\n        if config_parameters:\n            from datamodel_code_generator.model.pydantic_v2 import ConfigDict\n\n            self.extra_template_data['config'] = ConfigDict.parse_obj(config_parameters)\n            self._additional_imports.append(IMPORT_CONFIG_DICT)\n\n    def _get_config_extra(self) -> Optional[Literal[\"'allow'\", \"'forbid'\"]]:\n        additionalProperties = self.extra_template_data.get('additionalProperties')\n        allow_extra_fields = self.extra_template_data.get('allow_extra_fields')\n        if additionalProperties is not None or allow_extra_fields:\n            return (\n                \"'allow'\" if additionalProperties or allow_extra_fields else \"'forbid'\"\n            )\n        return None\n", "path": "datamodel_code_generator/model/pydantic_v2/base_model.py"}]}