OpenAPITools / OpenAPITools/openapi-generator

[REQ] [JAVA] Possibility to customize equals hashCode and toString

Open
#24,319 15 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: Feature
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Describe the solution you'd like

Create two new vendor config named x-exclude-equals-hash-code and x-exclude-to-string to mark class fields who will be excluded from methods equals and hashCode and toString method, this issue is very helpful, main equals and hashCode, because this methods control class equality and if this class and In Set collections this methods is used to remove duplicates, instead of check all fields

Describe alternatives you've considered

another alternative is create config named x-include-equals-hash-code and x-include-to-string, if class have this props include only fields inside in methods ( both props receive a list os fields names)

Additional context

When class use lombok annotations to exclude field from methods:

mark field with follow annotations:

@EqualsAndHashCode.Exclude
@ToString.Exclude

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by examining how Java generator vendor extensions are represented and how generated models currently define equals, hashCode, and toString; the issue names no files or tests. Compare the proposed x-exclude-equals-hash-code and x-exclude-to-string options with the alternative include options and Lombok's @EqualsAndHashCode.Exclude and @ToString.Exclude annotations. Done means one clear configuration approach is implemented for the relevant generated models.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.