You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi together,
i have a constellation which does not work as expected with JsonIgnoreProperties.
I have a REST API. One endpoint is for creating a car like POST /api/cars
Assume i have the following domain object
@Data
@SuperBuilder
@NoArgsConstructor
public class Car {
private String id;
private int tireCount;
...
}
and an api creation dto looking like
@JsonIgnoreProperties({"id"})
@Data
@SuperBuilder
@NoArgsConstructor
public class CreateCarRequest extends Car {
... potentially empty or carrying additional fields for car creation
}
I basically want to prevent mapping fields arround. In the dto i basically prevent Jackson from parsing not relevant fields by setting @JsonIgnoreProperties({"id"}). This works by Jackson not parsing the id field if is send it in the CreateCarRequest.
The Problem
The api doc gets generated. The description of the entity CreateCarRequest contains the field id.
It will disappear in the api doc when i add / overload the field or add it's getter + setter explicitly in CreateCarRequest. It seems like JsonIgnoreProperties does not respect parent classes and only checks for fields / getters and setters inside the current class.
Expected behaviour @JsonIgnoreProperties({"id"}) also checks parent object fields and, if they exist, ignores them.
The text was updated successfully, but these errors were encountered:
Hi together,
i have a constellation which does not work as expected with
JsonIgnoreProperties
.I have a REST API. One endpoint is for creating a car like POST /api/cars
Assume i have the following domain object
and an api creation dto looking like
I basically want to prevent mapping fields arround. In the dto i basically prevent Jackson from parsing not relevant fields by setting
@JsonIgnoreProperties({"id"})
. This works by Jackson not parsing the id field if is send it in theCreateCarRequest
.The Problem
The api doc gets generated. The description of the entity
CreateCarRequest
contains the fieldid
.It will disappear in the api doc when i add / overload the field or add it's getter + setter explicitly in
CreateCarRequest
. It seems likeJsonIgnoreProperties
does not respect parent classes and only checks for fields / getters and setters inside the current class.Expected behaviour
@JsonIgnoreProperties({"id"})
also checks parent object fields and, if they exist, ignores them.The text was updated successfully, but these errors were encountered: