File tree Expand file tree Collapse file tree 3 files changed +21
-1
lines changed
Expand file tree Collapse file tree 3 files changed +21
-1
lines changed Original file line number Diff line number Diff line change 11"""Django Schema - Builds Pydantic Schemas from Django Models with default field type validations"""
22
3- __version__ = "0.14.0 "
3+ __version__ = "0.14.1 "
44
55from .orm .factory import SchemaFactory
66from .orm .model_schema import ModelSchema
Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ def create_schema(
3939 exclude : Optional [List [str ]] = None ,
4040 skip_registry : bool = False ,
4141 optional_fields : Optional [Union [str , List [str ]]] = None ,
42+ ** model_config_options : DictStrAny ,
4243 ) -> Union [Type ["ModelSchema" ], Type ["Schema" ], None ]:
4344 from .model_schema import ModelSchema
4445
@@ -59,6 +60,7 @@ def create_schema(
5960 "depth" : depth ,
6061 "registry" : registry ,
6162 "optional" : optional_fields ,
63+ ** model_config_options ,
6264 }
6365 cls .get_model_config (** model_config_kwargs ) # type: ignore
6466 new_schema = (
Original file line number Diff line number Diff line change 1+ import pytest
2+
3+ from ninja_schema .orm .factory import SchemaFactory
4+ from ninja_schema .pydanticutils import IS_PYDANTIC_V1
5+ from tests .models import Event
6+
7+
8+ @pytest .mark .skipif (IS_PYDANTIC_V1 , reason = "requires pydantic == 2.1.x" )
9+ def test_create_schema_with_model_config_options ():
10+ schema = SchemaFactory .create_schema (
11+ Event ,
12+ skip_registry = True ,
13+ from_attributes = True , # model_config_option
14+ title = "Custom Title" , # model_config_option
15+ )
16+
17+ assert schema .model_config ["from_attributes" ] is True
18+ assert schema .model_config ["title" ] == "Custom Title"
You can’t perform that action at this time.
0 commit comments