We are trying to upgrade this library from 1.1.0 to 1.5.7. Earlier we used to get the fully qualified json path in the error. However this behaviour seems to be changed now.
Existing error formats:
"$.data.personal.firstName": "First name is required",
"$.data.personal.lastName": "Last name is required",
"$.data.personal.email": "Email is required"
With the latest version, the error format has been changed.
"$.data.personal": "required property 'firstName' is missing",
"$.data.personal": "required property 'lastName' is missing",
"$.data.personal": "required property 'email' is missing"
Logic to build the validation:
private static final JsonMetaSchema META_SCHEMA =
JsonMetaSchema.builder(JsonMetaSchema.getV6())
.addKeyword(new NonValidationKeyword("components"))
.build();
private static final JsonSchemaFactory JSON_SCHEMA_FACTORY =
JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V6, builder -> builder.metaSchema(META_SCHEMA));
JsonNode content = // json node object
String schema = "valid openapi specification";
JsonNode rawNode = objectMapper.readTree(schema);
JsonNode componentNode = rawNode.get("components");
JsonNode schemaNode = componentNode.get("schemas").get("Event");
((ObjectNode) schemaNode).set(COMPONENTS, componentNode);
SchemaValidatorsConfig config = new SchemaValidatorsConfig();
config.setTypeLoose(false);
config.setHandleNullableField(true);
JsonSchema jsonschema = JSON_SCHEMA_FACTORY.getSchema(schemaNode, config);
jsonschema.initializeValidators();
Set<ValidationMessage> errors = schema.validate(content);
What are the changes required to get the errors with fully qualified names?
We are trying to upgrade this library from
1.1.0to1.5.7. Earlier we used to get the fully qualified json path in the error. However this behaviour seems to be changed now.Existing error formats:
With the latest version, the error format has been changed.
Logic to build the validation:
What are the changes required to get the errors with fully qualified names?