Python Integration

The Python TypeSchema integration uses the well known Pydantic library. To use the generated DTO classes you need to add this library to your project:
pydantic~=2.9.2

DTO

from pydantic import BaseModel, Field, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from typing import Any, Dict, Generic, List, Optional, TypeVar


# A simple student struct
class Student(BaseModel):
    first_name: Optional[str] = Field(default=None, alias="firstName")
    last_name: Optional[str] = Field(default=None, alias="lastName")
    age: Optional[int] = Field(default=None, alias="age")
    pass

Integration

input = Path('input.json').read_text()

student = Student.model_validate_json(input)

output = student.model_dump_json()

Path('output.json').write_text(output)