mapstruct / mapstruct/mapstruct

Automatically detect camelCase and snake_case propreties.

Open
#3,512 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
7.7k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

Use case

Currently when mapping between 2 objects where field name only differ in their case styles like:

public class CamelCase {
Long id;
String someString;
}

public class SnakeCase {
Long id;
String some_string;
}

The mapper needs to be manually configured to associate someString and some_string.

Generated Code

No response

Possible workarounds

For now I'm manually defining @Mapping annotations for the fields:

    @Mapping(target = "preparationTime", source = "preparation_time")
    @Mapping(target = "menuCategoryId", source = "menu_category_id")
MapStruct Version

1.6.0.Beta1

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

No source file or test is named in the issue. Start by locating MapStruct's mapping-resolution logic and existing tests for differently named properties; define the expected camelCase-to-snake_case behavior and add coverage showing that manual @Mapping annotations are no longer required.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.