Skip to content

Conversation

@uc4w6c
Copy link
Collaborator

@uc4w6c uc4w6c commented Sep 22, 2022

Describe the bug

When the argument of the MethodParameterPojoExtractor.extractFrom method is a record class, duplicate fields gets.

  1. when the argument is a class (expected)
// The ClassObject class has email, firstName, lastName fields and getters 
Stream<MethodParameter> actual = MethodParameterPojoExtractor.extractFrom(ClassObject.class);
actual.forEach(method -> System.out.println(method.getMethod().getName()));

// Below is the output result.
// getEmail
// getFirstName
// getLastName
  1. when the argument is a record (unexpected)
record RecordObject(String email, String firstName, String lastName) {}
Stream<MethodParameter> actual = MethodParameterPojoExtractor.extractFrom(RecordObject.class);
actual.forEach(method -> System.out.println(method.getMethod().getName()));

// Below is the output result.
// email
// firstName
// lastName
// email
// firstName
// lastName
// email
// firstName
// lastName

Fixes

Added filter as well as Class.

@bnasslahsen bnasslahsen merged commit ddf6738 into springdoc:2.x Sep 28, 2022
@bnasslahsen
Copy link
Collaborator

Thank you @uc4w6c for your contribution to the project.

@uc4w6c uc4w6c deleted the fix_record_field_get branch October 14, 2022 15:09
mpleine pushed a commit to mpleine/springdoc-openapi that referenced this pull request May 17, 2025
Fixed a bug that duplicate field were get for record classes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants