You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG][PYTHON] JSON serialization fails for UUID fields in generated Python #22063
I am using the maven plugin openapi-generator-maven-plugin (python generator), to generate Python code that includes UUID fields. Since 7.15 version of this plugin, the to_json method of the generated python object containing an UUID field leads to this error: Object of type UUID is not JSON serializable error
I was able to reproduce this issue. I found a workaround by using this instead: obj.model_dump_json(by_alias=True, exclude_unset=True), based on this TODO in the current template:
This should be fixed since #23210 — to_json no longer goes through plain json.dumps. Just verified a uuid field on master and it serializes fine now. Please retest with the latest version.
Activity
EspenHa commentedon Oct 12, 2025
I was able to reproduce this issue. I found a workaround by using this instead:
obj.model_dump_json(by_alias=True, exclude_unset=True), based on this TODO in the current template:openapi-generator/modules/openapi-generator/src/main/resources/python/model_generic.mustache
Line 130 in 81a3488
It seems this TODO was planned for pydantic v2, so maybe it is time for a switch over to this method instead of the old method?
fa0311 commentedon Jul 20, 2026
This should be fixed since #23210 — to_json no longer goes through plain json.dumps. Just verified a uuid field on master and it serializes fine now. Please retest with the latest version.