diff --git a/java/core/src/main/java/org/brapi/schematools/core/brapischema/BrAPISchemaReader.java b/java/core/src/main/java/org/brapi/schematools/core/brapischema/BrAPISchemaReader.java index ce5feff..7c1a391 100644 --- a/java/core/src/main/java/org/brapi/schematools/core/brapischema/BrAPISchemaReader.java +++ b/java/core/src/main/java/org/brapi/schematools/core/brapischema/BrAPISchemaReader.java @@ -144,7 +144,7 @@ private Response> validate(List brAPIClasses) { } private Response validateClass(final Map 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())) ; } @@ -169,7 +169,8 @@ private Response validateType(final Map classesMa } } - private Response validateBrAPIMetadata(BrAPIMetadata metadata) { + private Response validateBrAPIMetadata(BrAPIClass brAPIClass) { + BrAPIMetadata metadata = brAPIClass.getMetadata(); if (metadata != null) { int i = 0 ; @@ -186,7 +187,7 @@ private Response 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())) ; } } @@ -462,7 +463,7 @@ private Response 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(", "))))) ; }