Upgrading from 1.0.8x to current (1.5.9): How to migrate "String at" to JsonNodePath and "String schemaPath" to SchemaLocation in custom ValidationMessages? #1194
Unanswered
AndreasALoew
asked this question in
Q&A
Replies: 1 comment 2 replies
-
You can actually just look at how some of the validators are currently implemented and would typically just call This calls the following to set up most of the default values The value of |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello Experts,
many thanks for having created such a great and fast validation library! 👍
I am in the process of migrating our app to Spring Boot 3.5 and Jakarta EE 11, and as part of this, from json-schema-validator 1.0.87 to the latest and greatest 1.5.9. The Upgrading to new versions document was a big help, but one topic remains, and even after asking several AIs (which started "hallucinating" and proposing to call methods that never existed 😠), I have two questions left that I seem unable to resolve on my own and hope for your kind help:
At several places in our codebase, with 1.0.8x, we have constructed custom ValidationMessages using
ValidationMessage.of()
, passing information from ancom.networknt.openapi.OpenApiOperation
(from the networknt "openapi-parser" library), making use of theopenApiOperation
in theString at
and theString schemaPath
parameters of the previous "static constructor" methodValidationMessage.of()
.Example:
In this case,
String at
is the fourth parameter ofValidationMessage.of()
, where we used to passopenApiOperation.getMethod()
.In addition, it looks like a similar issue exists with the fifth (= last) parameter (used to be
String schemaPath
- where we used to passopenApiOperation.getPathString().original()
- , now needs to becomeschemaLocation(SchemaLocation schemaLocation)
...I am perfectly aware that I need to migrate this to the new approach using
ValidationMessage.builder()
, and also think thatinstanceLocation(JsonNodePath instanceLocation)
andschemaLocation(SchemaLocation schemaLocation)
would be the right builder methods to add the location info as before, but I simply cannot figure out the answer to the following two questions:How exactly (code sample/fragment preferred) do I migrate/transform the JSON path-like
String at
from version 1.0.8x inside the Validation message to the new Builder approach based oncom.jayway.jsonpath.JsonPath
(I think I have to start usingJsonPath.compile(at)
, right?) andJsonNodePath
(and possibly Jackson'scom.fasterxml.jackson.databind.JsonNode
), such that theValidationMessage
instance that I create with 1.5.9 still transports the same information as with 1.0.8x?Again/very similar: How exactly (code sample/fragment preferred) do I migrate/transform the JSON path-like
String schemaPath
from version 1.0.8x inside the Validation message to the new Builder approach based onSchemaLocation
, such that theValidationMessage
instance that I create with 1.5.9 still transports the same information as with 1.0.8x?Any pointers and/or code fragments highly appreciated! 😃
Thanks a million & kind regards,
Andreas
Beta Was this translation helpful? Give feedback.
All reactions