Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to process component annotations on record classes with fields with @JsonProperty annotations differing from field names #4796

Closed
richard-lindsay opened this issue Nov 22, 2024 · 1 comment

Comments

@richard-lindsay
Copy link
Contributor

richard-lindsay commented Nov 22, 2024

Problem

After upgrading to 2.2.26, record classes with fields annotated with JsonProperty with a value different to the naming of the field are unable to render component annotations, will throw a NoSuchMethodException exception, and log an error for this class.

Fix

Accessing the method object using propDef.getPrimaryMember().getName()) should prevent this. PR available here: #4795

Example

 record JavaRecordWithJsonPropertyAnnotationNotMatchingFieldName(
    @JsonProperty("listOfStrings") 
    List<@Size(min = 1, max = 5)String> stringList
) { }

Before

JavaRecordWithJsonPropertyAnnotationNotMatchingFieldName:
    type: object
    properties:
        listOfStrings:
            type: array
            items:
                type: string

After

JavaRecordWithJsonPropertyAnnotationNotMatchingFieldName:
    type: object
    properties:
        listOfStrings:
            type: array
            items:
                maxLength: 5
                minLength: 1
                type: string
@frantuma
Copy link
Member

frantuma commented Dec 9, 2024

Thanks for reporting this and for the fix, fixed in #4795

@frantuma frantuma closed this as completed Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants