from dataclasses import dataclass
from mashumaro.config import BaseConfig
from mashumaro.jsonschema import build_json_schema
def as_str(value) -> str:
return str(value)
class Bar:
pass
@dataclass
class Foo:
bar: Bar = Bar()
class Config(BaseConfig):
serialization_strategy = {
Bar: {
"serialize": as_str,
"deserialize": Bar,
}
}
print(build_json_schema(Foo).to_json())
will raise an exception: mashumaro.exceptions.UnserializableField: Field "x" of type Bar in _default.<locals>.CC is not serializable
Description
will raise an exception:
mashumaro.exceptions.UnserializableField: Field "x" of type Bar in _default.<locals>.CC is not serializable
Expected: