json scheme

This commit is contained in:
2025-03-20 21:34:29 -03:00
parent 1f19380f5c
commit 76277d17b9
2 changed files with 15 additions and 2 deletions

View File

@@ -148,6 +148,17 @@ class CpfCnpj:
return cpfcnpj_
@classmethod
def __get_pydantic_json_schema__(
cls, core_schema: core_schema.CoreSchema, handler: GetJsonSchemaHandler
) -> JsonSchemaValue:
field_schema = handler(core_schema)
field_schema.update(
type='string',
format=cls.__name__.lower().removesuffix('str'),
)
return field_schema
if TYPE_CHECKING:
CpfStr = Annotated[str, ...]