def test_json_encoders_on_model() -> None:
    """Make sure that applying json_encoders to a BaseModel
    does not edit its schema in place.
    """

    class Model(BaseModel):
        x: int

    class Outer1(BaseModel):
        m: Model
        model_config = ConfigDict(json_encoders={Model: lambda x: 'encoded!'})

    class Outer2(BaseModel):
        m: Model

    class Outermost(BaseModel):
        inner: Union[Outer1, Outer2]

    m = Outermost(inner=Outer1(m=Model(x=1)))
    # insert_assert(m.model_dump())
    assert json.loads(m.model_dump_json()) == {'inner': {'m': 'encoded!'}}

    m = Outermost(inner=Outer2(m=Model(x=1)))
    # insert_assert(m.model_dump())
    assert json.loads(m.model_dump_json()) == {'inner': {'m': {'x': 1}}}
Make sure that applying json_encoders to a BaseModel
    does not edit its schema in place.
    
tests/test_json.py