Skip to content

Conversation

evandongen
Copy link
Contributor

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.

@evandongen evandongen requested review from tnleeuw and nielsm5 June 20, 2025 10:08
@evandongen evandongen requested a review from a team as a code owner June 20, 2025 10:08
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/"),
Copy link
Contributor Author

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);
Copy link
Contributor

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?

Copy link
Member

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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<>();
Copy link
Contributor

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());
Copy link
Contributor

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

Copy link

@nielsm5 nielsm5 enabled auto-merge (squash) June 23, 2025 12:22
@nielsm5 nielsm5 changed the title Update the json validator Update the JsonValidator to allow validation using newer json schemas Jun 23, 2025
@nielsm5 nielsm5 merged commit 0363d1a into master Jun 23, 2025
33 checks passed
@nielsm5 nielsm5 deleted the issue/8922-upgrade-jsonschema-validator branch June 23, 2025 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JsonValidator uses legacy default value for subSchemaPrefix instead of '/$defs/'
3 participants