OpenAPITools / OpenAPITools/openapi-generator

[REQ] Spring: Add option to disable creating toString()-Method

Open
#14,156 2 comments 4 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

Currently, the POJO always contains a toString()-Method containing all fields.
This can be a problem if the POJO is logged and contains sensitive data.

I suggest a configuration-parameter "excludeToString" so that the toString method is not generated anymore.

As Lombok is widely used it's often the preferred way to generate this method:

  1. Setting configuration additionalModelTypeAnnotations = @lombok.ToString
  2. Setting x-field-extra-annotation: ""@lombok.ToString.Include"/ "@lombok.ToString.Exclude" in API.yaml

Of course I can customize the mustache template and use this but I think this feature might be useful for quite a lot of people.

I'd happily contribute this feature as PR.

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

The issue names the Spring generator and the excludeToString configuration parameter, but no files or tests. Start by tracing Spring model generation and configuration handling; done means the option suppresses toString generation while existing default behavior remains.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
backend, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.