Skip to content

Commit bd1adf2

Browse files
joshwanfJustin-MacIntosh
authored andcommitted
added validation/serialization to Create Screener Endpoint
1 parent 5f365de commit bd1adf2

File tree

6 files changed

+467
-422
lines changed

6 files changed

+467
-422
lines changed

builder-api/pom.xml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
35
<modelVersion>4.0.0</modelVersion>
46
<groupId>org.acme</groupId>
57
<artifactId>builder-api</artifactId>
@@ -50,6 +52,10 @@
5052
<groupId>io.quarkus</groupId>
5153
<artifactId>quarkus-arc</artifactId>
5254
</dependency>
55+
<dependency>
56+
<groupId>io.quarkus</groupId>
57+
<artifactId>quarkus-hibernate-validator</artifactId>
58+
</dependency>
5359
<dependency>
5460
<groupId>io.quarkiverse.googlecloudservices</groupId>
5561
<artifactId>quarkus-google-cloud-firebase-admin</artifactId>
@@ -168,7 +174,8 @@
168174
</executions>
169175
<configuration>
170176
<systemPropertyVariables>
171-
<native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
177+
<native.image.path>
178+
${project.build.directory}/${project.build.finalName}-runner</native.image.path>
172179
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
173180
<maven.home>${maven.home}</maven.home>
174181
</systemPropertyVariables>
@@ -191,4 +198,4 @@
191198
</properties>
192199
</profile>
193200
</profiles>
194-
</project>
201+
</project>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package org.acme.api.error;
2+
3+
import com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException;
4+
import jakarta.ws.rs.core.MediaType;
5+
import jakarta.ws.rs.core.Response;
6+
import jakarta.ws.rs.ext.ExceptionMapper;
7+
import jakarta.ws.rs.ext.Provider;
8+
9+
import java.util.Map;
10+
11+
// Global error handler for providing extra fields in the request body
12+
13+
@Provider
14+
public class UnknownFieldExceptionMapper implements ExceptionMapper<UnrecognizedPropertyException> {
15+
16+
@Override
17+
public Response toResponse(UnrecognizedPropertyException e) {
18+
return Response.status(Response.Status.BAD_REQUEST)
19+
.type(MediaType.APPLICATION_JSON)
20+
.entity(Map.of(
21+
"error", true,
22+
"message", "Unknown field " + e.getPropertyName()))
23+
.build();
24+
}
25+
}

0 commit comments

Comments
 (0)