Skip to content

[REQ][JAVA]: Add @com.fasterxml.jackson.annotation.JsonProperty when @lombok.Data is used #18794

@nokhod

Description

@nokhod
Description

When using @lombok.Data in additionalModelTypeAnnotations, the getters for fields are not generated. While @com.fasterxml.jackson.annotation.JsonProperty is only placed on getter methods, this causes a problem when the property name is in kebab-case rather than the default camel-case.

openapi-generator version

7.6.0

OpenAPI declaration file content or URL

pojo.mustache

Command line used for generation

Regular maven build.

Steps to reproduce

Configuring the maven plugin using the following configOptions:

<configOptions>
    <library>spring-cloud</library>
    <useSpringBoot3>true</useSpringBoot3>
    <useResponseEntity>false</useResponseEntity>
    <bigDeciamlAsString>true</bigDeciamlAsString>
    <dateLibrary>java8-localdatetime</dateLibrary>
    <useEnumCaseInsensitive>true</useEnumCaseInsensitive>
    <configPackage>com.kbakhtiari</configPackage>
    <generatedConstructorWithRequiredArgs>false</generatedConstructorWithRequiredArgs>
    <additionalModelTypeAnnotations>
        @lombok.Data
        @lombok.NoArgsConstructor
        @lombok.AllArgsConstructor
        @lombok.Builder(toBuilder = true)    
    </additionalModelTypeAnnotations>
</configOptions>
Related issues/PRs

N/A

Suggest a fix/enhancement

Adding the following code snippet to pojo.mustache:

{{#lombok.Data}}
@JsonProperty("{{baseName}}")
{{/lombok.Data}}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions