-
Notifications
You must be signed in to change notification settings - Fork 81
Update the JsonValidator to allow validation using newer json schemas #9179
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
Conversation
public static List<Arguments> testSchemas() { | ||
return Arrays.asList(new Arguments[]{ | ||
Arguments.of("/Align/FamilyTree/family-compact-family.jsd", "/definitions/"), | ||
Arguments.of("/Align/FamilyTree/family-compact-family-2020.jsd" , "/$defs/"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extended the tests with a new schema, using the latest JsonSchema spec combined with the requested '$defs' reference from the ticket.
@@ -54,7 +56,8 @@ public class JsonValidator extends AbstractValidator { | |||
private @Getter String subSchemaPrefix="/definitions/"; | |||
private @Getter String reasonSessionKey = "failureReason"; | |||
|
|||
private final JsonValidationService service = JsonValidationService.newInstance(); | |||
private final JsonSchemaFactory service = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V202012); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Willen we dit ooit configureerbaar maken?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Behalve als het backwards compatible is? Als dit puur om te valideren is heb ik liever dat je minder hoeft in te stellen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ik zie dat dit in ieder geval de meest recente versie is van de JSON Schema spec. Als we ooit een integratie moeten maken met een systeem dat een oudere versie gebruikt, en er zijn compatibility problemen, dan kunnen we dan kijken of het nodig is om dit configureerbaar te maken.
Als 2020-12 werkt voor alle huidige gebruikers, dan moet dit in ieder geval de default blijven.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Het werkt met versie kruik en de nieuwe versie (daarom beiden in de unit test gezet)
|
||
private SchemaValidationResult validateJson(JsonSchema jsonSchema, Message message) throws IOException { | ||
// Parses the JSON instance by JsonParser | ||
Set<ValidationMessage> validationMessages = new HashSet<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Volgens mij is deze assignment niet nodig en kan de validationMessage
naar binnen het try
-blok verhuisd worden?
validationMessages | ||
); | ||
} catch (IllegalArgumentException e) { | ||
validationMessages.add(ValidationMessage.builder().message(e.getMessage()).build()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IPV validationMessage.add
kan je de variabele hier inlinen en List.of()
gebruiken voor de error-message
core/src/test/java/org/frankframework/align/TestXmlSchema2JsonSchema.java
Show resolved
Hide resolved
|
closes #8922
In trying to fix the issue, I found out that the validator library has been abandoned. I've introduced networknt/json-schema to replace it.