Skip to content

Commit e4978a7

Browse files
committed
Include JSON Schema input core schema in function schemas
1 parent 4c02cbd commit e4978a7

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

python/pydantic_core/core_schema.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2021,6 +2021,7 @@ def with_info_before_validator_function(
20212021
*,
20222022
field_name: str | None = None,
20232023
ref: str | None = None,
2024+
json_schema_input_schema: CoreSchema | None = None,
20242025
metadata: Dict[str, Any] | None = None,
20252026
serialization: SerSchema | None = None,
20262027
) -> BeforeValidatorFunctionSchema:
@@ -2050,6 +2051,7 @@ def fn(v: bytes, info: core_schema.ValidationInfo) -> str:
20502051
field_name: The name of the field
20512052
schema: The schema to validate the output of the validator function
20522053
ref: optional unique identifier of the schema, used to reference the schema in other places
2054+
json_schema_input_schema: The core schema to be used to generate the corresponding JSON Schema input type
20532055
metadata: Any other information you want to include with the schema, not used by pydantic-core
20542056
serialization: Custom serialization schema
20552057
"""
@@ -2058,6 +2060,7 @@ def fn(v: bytes, info: core_schema.ValidationInfo) -> str:
20582060
function=_dict_not_none(type='with-info', function=function, field_name=field_name),
20592061
schema=schema,
20602062
ref=ref,
2063+
json_schema_input_schema=json_schema_input_schema,
20612064
metadata=metadata,
20622065
serialization=serialization,
20632066
)
@@ -2072,6 +2075,7 @@ def no_info_after_validator_function(
20722075
schema: CoreSchema,
20732076
*,
20742077
ref: str | None = None,
2078+
json_schema_input_schema: CoreSchema | None = None,
20752079
metadata: Dict[str, Any] | None = None,
20762080
serialization: SerSchema | None = None,
20772081
) -> AfterValidatorFunctionSchema:
@@ -2095,6 +2099,7 @@ def fn(v: str) -> str:
20952099
function: The validator function to call after the schema is validated
20962100
schema: The schema to validate before the validator function
20972101
ref: optional unique identifier of the schema, used to reference the schema in other places
2102+
json_schema_input_schema: The core schema to be used to generate the corresponding JSON Schema input type
20982103
metadata: Any other information you want to include with the schema, not used by pydantic-core
20992104
serialization: Custom serialization schema
21002105
"""
@@ -2103,6 +2108,7 @@ def fn(v: str) -> str:
21032108
function={'type': 'no-info', 'function': function},
21042109
schema=schema,
21052110
ref=ref,
2111+
json_schema_input_schema=json_schema_input_schema,
21062112
metadata=metadata,
21072113
serialization=serialization,
21082114
)
@@ -2197,6 +2203,7 @@ def no_info_wrap_validator_function(
21972203
schema: CoreSchema,
21982204
*,
21992205
ref: str | None = None,
2206+
json_schema_input_schema: CoreSchema | None = None,
22002207
metadata: Dict[str, Any] | None = None,
22012208
serialization: SerSchema | None = None,
22022209
) -> WrapValidatorFunctionSchema:
@@ -2225,13 +2232,15 @@ def fn(
22252232
function: The validator function to call
22262233
schema: The schema to validate the output of the validator function
22272234
ref: optional unique identifier of the schema, used to reference the schema in other places
2235+
json_schema_input_schema: The core schema to be used to generate the corresponding JSON Schema input type
22282236
metadata: Any other information you want to include with the schema, not used by pydantic-core
22292237
serialization: Custom serialization schema
22302238
"""
22312239
return _dict_not_none(
22322240
type='function-wrap',
22332241
function={'type': 'no-info', 'function': function},
22342242
schema=schema,
2243+
json_schema_input_schema=json_schema_input_schema,
22352244
ref=ref,
22362245
metadata=metadata,
22372246
serialization=serialization,
@@ -2243,6 +2252,7 @@ def with_info_wrap_validator_function(
22432252
schema: CoreSchema,
22442253
*,
22452254
field_name: str | None = None,
2255+
json_schema_input_schema: CoreSchema | None = None,
22462256
ref: str | None = None,
22472257
metadata: Dict[str, Any] | None = None,
22482258
serialization: SerSchema | None = None,
@@ -2273,6 +2283,7 @@ def fn(
22732283
function: The validator function to call
22742284
schema: The schema to validate the output of the validator function
22752285
field_name: The name of the field this validators is applied to, if any
2286+
json_schema_input_schema: The core schema to be used to generate the corresponding JSON Schema input type
22762287
ref: optional unique identifier of the schema, used to reference the schema in other places
22772288
metadata: Any other information you want to include with the schema, not used by pydantic-core
22782289
serialization: Custom serialization schema
@@ -2281,6 +2292,7 @@ def fn(
22812292
type='function-wrap',
22822293
function=_dict_not_none(type='with-info', function=function, field_name=field_name),
22832294
schema=schema,
2295+
json_schema_input_schema=json_schema_input_schema,
22842296
ref=ref,
22852297
metadata=metadata,
22862298
serialization=serialization,
@@ -2299,6 +2311,7 @@ def no_info_plain_validator_function(
22992311
function: NoInfoValidatorFunction,
23002312
*,
23012313
ref: str | None = None,
2314+
json_schema_input_schema: CoreSchema | None = None,
23022315
metadata: Dict[str, Any] | None = None,
23032316
serialization: SerSchema | None = None,
23042317
) -> PlainValidatorFunctionSchema:
@@ -2320,6 +2333,7 @@ def fn(v: str) -> str:
23202333
Args:
23212334
function: The validator function to call
23222335
ref: optional unique identifier of the schema, used to reference the schema in other places
2336+
json_schema_input_schema: The core schema to be used to generate the corresponding JSON Schema input type
23232337
metadata: Any other information you want to include with the schema, not used by pydantic-core
23242338
serialization: Custom serialization schema
23252339
"""
@@ -2337,6 +2351,7 @@ def with_info_plain_validator_function(
23372351
*,
23382352
field_name: str | None = None,
23392353
ref: str | None = None,
2354+
json_schema_input_schema: CoreSchema | None = None,
23402355
metadata: Dict[str, Any] | None = None,
23412356
serialization: SerSchema | None = None,
23422357
) -> PlainValidatorFunctionSchema:
@@ -2359,13 +2374,15 @@ def fn(v: str, info: core_schema.ValidationInfo) -> str:
23592374
function: The validator function to call
23602375
field_name: The name of the field this validators is applied to, if any
23612376
ref: optional unique identifier of the schema, used to reference the schema in other places
2377+
json_schema_input_schema: The core schema to be used to generate the corresponding JSON Schema input type
23622378
metadata: Any other information you want to include with the schema, not used by pydantic-core
23632379
serialization: Custom serialization schema
23642380
"""
23652381
return _dict_not_none(
23662382
type='function-plain',
23672383
function=_dict_not_none(type='with-info', function=function, field_name=field_name),
23682384
ref=ref,
2385+
json_schema_input_schema=json_schema_input_schema,
23692386
metadata=metadata,
23702387
serialization=serialization,
23712388
)

0 commit comments

Comments
 (0)