Skip to content

Commit

Permalink
improved error message
Browse files Browse the repository at this point in the history
  • Loading branch information
Guy Davenport committed Jul 30, 2024
1 parent 295388e commit 57c3127
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ private Response<List<BrAPIClass>> validate(List<BrAPIClass> brAPIClasses) {
}

private Response<BrAPIType> validateClass(final Map<String, BrAPIClass> classesMap, BrAPIClass brAPIClass) {
return validateBrAPIMetadata(brAPIClass.getMetadata()).map(() -> {
return validateBrAPIMetadata(brAPIClass).map(() -> {
if (brAPIClass instanceof BrAPIAllOfType brAPIAllOfType) {
return fail(Response.ErrorType.VALIDATION, String.format("BrAPIAllOfType '%s' was not de-referenced", brAPIAllOfType.getName())) ;
}
Expand All @@ -169,7 +169,8 @@ private Response<BrAPIType> validateType(final Map<String, BrAPIClass> classesMa
}
}

private Response<BrAPIMetadata> validateBrAPIMetadata(BrAPIMetadata metadata) {
private Response<BrAPIMetadata> validateBrAPIMetadata(BrAPIClass brAPIClass) {
BrAPIMetadata metadata = brAPIClass.getMetadata();

if (metadata != null) {
int i = 0 ;
Expand All @@ -186,7 +187,7 @@ private Response<BrAPIMetadata> validateBrAPIMetadata(BrAPIMetadata metadata) {
++i;
}
if (i > 1) {
return fail(Response.ErrorType.VALIDATION, "'primaryModel', 'request', 'parameters', 'interface' are mutually exclusive, only one can be set to to true") ;
return fail(Response.ErrorType.VALIDATION, String.format("In class '%s', 'primaryModel', 'request', 'parameters', 'interface' are mutually exclusive, only one can be set to to true", brAPIClass.getName())) ;
}
}

Expand Down Expand Up @@ -462,7 +463,7 @@ private Response<BrAPIObjectProperty> validateRequiredProperty(String requiredPr
return properties.stream().filter(property -> property.getName().equals(requiredPropertyName))
.findAny().map(Response::success)
.orElse(fail(Response.ErrorType.VALIDATION,
String.format("The required property '%s' is not found in the list of properties of '%s', expecting one of '%s", requiredPropertyName, objectName,
String.format("The required property '%s' is not found in the list of properties of '%s', expecting one of '%s'", requiredPropertyName, objectName,
properties.stream().map(BrAPIObjectProperty::getName).collect(Collectors.joining(", "))))) ;
}

Expand Down

0 comments on commit 57c3127

Please sign in to comment.