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

[3.14] Fix Boolean serializer #43085

Merged
merged 1 commit into from
Sep 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,7 @@ String writtenType() {
case "java.lang.Long" -> "long";
case "java.lang.Double" -> "double";
case "java.lang.Float" -> "float";
case "java.lang.Boolean" -> "boolean";
default -> fieldType.name().toString();
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,22 @@ public class Dog extends AbstractNamedPet {
@JsonProperty("age")
private int publicAge;

@JsonProperty("vaccinated")
private Boolean publicVaccinated;

public int getPublicAge() {
return publicAge;
}

public void setPublicAge(int publicAge) {
this.publicAge = publicAge;
}

public Boolean getPublicVaccinated() {
return publicVaccinated;
}

public void setPublicVaccinated(Boolean publicVaccinated) {
this.publicVaccinated = publicVaccinated;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,13 @@ public Dog getDog() {
return createDog();
}

@POST
@Path("/dog-echo")
@Consumes(MediaType.APPLICATION_JSON)
public Dog echoDog(Dog dog) {
return dog;
}

@EnableSecureSerialization
@GET
@Path("/abstract-cat")
Expand Down Expand Up @@ -164,6 +171,7 @@ private static Dog createDog() {
dog.setPrivateName("Jack");
dog.setPublicName("Leo");
dog.setVeterinarian(createVeterinarian());
dog.setPublicVaccinated(true);
return dog;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -656,4 +656,21 @@ private static void testSecuredFieldOnAbstractClass(String catPath, String dogPa
.body("veterinarian.name", Matchers.is("Dolittle"))
.body("veterinarian.title", Matchers.is("VMD"));
}

@Test
public void testEcho() {
RestAssured
.with()
.body("{\"publicName\":\"Leo\",\"veterinarian\":{\"name\":\"Dolittle\"},\"age\":5,\"vaccinated\":true}")
.contentType("application/json; charset=utf-8")
.post("/simple/dog-echo")
.then()
.statusCode(200)
.contentType("application/json")
.body("publicName", Matchers.is("Leo"))
.body("privateName", Matchers.nullValue())
.body("age", Matchers.is(5))
.body("veterinarian.name", Matchers.is("Dolittle"))
.body("veterinarian.title", Matchers.nullValue());
}
}
Loading