Skip to content

[BUG][PYTHON] JSON serialization fails for UUID fields in generated Python #22063

@ridi121983

Description

@ridi121983

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

There is an example to reproduce the issue

components:
  schemas:
    MyObject:
      type: object
      properties:
        id:
          type: string
          format: uuid
from my_api.model.my_object import MyObject
import uuid

obj = MyObject(id=uuid.uuid4())
json_str = obj.to_json()

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions