forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure that RESTEasy Reactive violation report doesn't break Hibernat…
…e Validator in native Fixes: quarkusio#21516 (cherry picked from commit 34648ed)
- Loading branch information
Showing
3 changed files
with
104 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
...r/runtime/src/main/java/io/quarkus/hibernate/validator/runtime/jaxrs/ViolationReport.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
package io.quarkus.hibernate.validator.runtime.jaxrs; | ||
|
||
import java.util.List; | ||
|
||
import javax.ws.rs.core.Response; | ||
|
||
/** | ||
* As spec doesn't say anything about the report format, | ||
* we just use https://opensource.zalando.com/problem/constraint-violation | ||
* This also what Reactive Routes uses | ||
*/ | ||
public class ViolationReport { | ||
private String title; | ||
private int status; | ||
private List<Violation> violations; | ||
|
||
/** | ||
* Requires no-args constructor for some serializers. | ||
*/ | ||
public ViolationReport() { | ||
} | ||
|
||
public ViolationReport(String title, Response.Status status, List<Violation> violations) { | ||
this.title = title; | ||
this.status = status.getStatusCode(); | ||
this.violations = violations; | ||
} | ||
|
||
public String getTitle() { | ||
return title; | ||
} | ||
|
||
public void setTitle(String title) { | ||
this.title = title; | ||
} | ||
|
||
public int getStatus() { | ||
return status; | ||
} | ||
|
||
public void setStatus(int status) { | ||
this.status = status; | ||
} | ||
|
||
public List<Violation> getViolations() { | ||
return violations; | ||
} | ||
|
||
public void setViolations(List<Violation> violations) { | ||
this.violations = violations; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "ViolationReport{" + | ||
"title='" + title + '\'' + | ||
", status=" + status + | ||
", violations=" + violations + | ||
'}'; | ||
} | ||
|
||
public static class Violation { | ||
private String field; | ||
private String message; | ||
|
||
/** | ||
* Requires no-args constructor for some serializers. | ||
*/ | ||
public Violation() { | ||
} | ||
|
||
public Violation(String field, String message) { | ||
this.field = field; | ||
this.message = message; | ||
} | ||
|
||
public String getField() { | ||
return field; | ||
} | ||
|
||
public void setField(String field) { | ||
this.field = field; | ||
} | ||
|
||
public String getMessage() { | ||
return message; | ||
} | ||
|
||
public void setMessage(String message) { | ||
this.message = message; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Violation{" + | ||
"field='" + field + '\'' + | ||
", message='" + message + '\'' + | ||
'}'; | ||
} | ||
} | ||
} |