springdoc-openapi
springdoc-openapi copied to clipboard
Fixed a bug that duplicate field were get for record classes
Describe the bug
When the argument of the MethodParameterPojoExtractor.extractFrom method is a record class, duplicate fields gets.
- 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
- 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.