-
-
Notifications
You must be signed in to change notification settings - Fork 524
@JsonUnwrapped
is still broken since 2.5
#2879
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
Comments
I did some research and figured out that while this does not work: data class ContactCreateRequest(
@JsonUnwrapped
val person: Person,
) this does: data class ContactCreateRequest(
@field:JsonUnwrapped // Apply @JsonUnwrapped to field
val person: Person,
) The decompiled byte code for those look like that: public final class ContactCreateRequest {
@NotNull
private final Person person;
public ContactCreateRequest(@JsonUnwrapped @NotNull Person person) {
Intrinsics.checkNotNullParameter(person, "person");
super();
this.person = person;
}
@NotNull
public final Person getPerson() {
return this.person;
}
// ....
} vs public final class ContactCreateRequest {
@JsonUnwrapped
@NotNull
private final Person person;
public ContactCreateRequest(@NotNull Person person) {
Intrinsics.checkNotNullParameter(person, "person");
super();
this.person = person;
}
@NotNull
public final Person getPerson() {
return this.person;
}
// ....
} Funny thing is that if I try to replicate the first approach with pure Java, public class Book {
private final Author author;
private final String title;
public Book(@JsonUnwrapped(prefix = "author_") Author author, @JsonProperty("title") String title) {
this.author = author;
this.title = title;
}
}
This must be the Kotlin plugin doing some magic on top of default Jackson. This however is expected to change in the next Jackson minor release with FasterXML/jackson-databind#1467 merge. Given that in this example |
@JsonUnwrapped
is not still broken since 2.5@JsonUnwrapped
behaves differently in Kotlin since 2.6
@JsonUnwrapped
behaves differently in Kotlin since 2.6@JsonUnwrapped
is not still broken since 2.5
@JsonUnwrapped
is not still broken since 2.5@JsonUnwrapped
is still broken since 2.5
There is no code in Springdoc responsible for |
@bnasslahsen there is though. I am afraid this is a bug in I've just replicated the issue on 2.8.4. This condiiton: Lines 123 to 126 in 28c66e1
Is not going through because the annotation is on the getter, which is valid placement of this annotation too. Once I force this via debugger: Line 126 in 28c66e1
The type is properly unwrapped. Please re-open the ticket. |
I am merging your PR now. |
Hi, If you have a class like the next one, then the public final class ContactCreateRequest {
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
@JsonUnwrapped
private final Person person;
public ContactCreateRequest(Person person) {
this.person = person;
}
public final Person getPerson() {
return this.person;
}
} I am talking about this line: Lines 123 to 124 in 6b7c7eb
Now, isUnwrapped is false: Lines 125 to 128 in 165f0eb
Wouldn't there be an other way to get the annotation ? |
Describe the bug
Since
@JsonUnwrapped
has been broken in 2.6.0 I still not able to make@JsonUnwrapped
work with my Kotlin data classes despite numerous fixes:To Reproduce
This example in a sample Spring Boot project:
Dependencies
org.springdoc:springdoc-openapi-starter-webmvc-api:2.8.4
org.springdoc:springdoc-openapi-starter-webmvc-ui:2.8.4
org.springframework.boot:spring-boot-....:3.4.2
Expected Behavior (v2.5.0)

Actual Behavior (v2.8.4)

The text was updated successfully, but these errors were encountered: