Skip to content

[FEATURE] Map string with format uuid to java.util.UUID in Java generator #2305

@sberube-jive

Description

@sberube-jive

Why do we need this improvement?

Currently, when using the Java generator in Modelina, properties defined as type: string with format: uuid in the schema are mapped to plain String fields in the generated Java classes. However, for better type safety and semantic correctness, it would be preferable to map such fields to the java.util.UUID type.

Given this schema:

type: object
properties:
  id:
    type: string
    format: uuid

Currently, Modelina generates:

public class MyModel {
  private String id;
}

Expected:

public class MyModel {
  private java.util.UUID id;
}

Thank you for considering this enhancement!

How will this change help?

java.util.UUID provides stronger type-safety and utility methods compared to raw String.

This would align better with Java conventions for representing UUIDs.

Screenshots

No response

How could it be implemented/designed?

I think the implementation should go there:

https://github.com/asyncapi/modelina/blob/master/src/generators/java/JavaConstrainer.ts#L171

🚧 Breaking changes

No

👀 Have you checked for similar open issues?

  • I checked and didn't find a similar issue

🏢 Have you read the Contributing Guidelines?

Are you willing to work on this issue?

No, someone else can work on it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions