Skip to content

Update com.networknt:json-schema-validator to 2.0.1#3344

Merged
tomakehurst merged 4 commits into
wiremock:masterfrom
pedroboado:bump-json-schema-validator-2.x
Mar 26, 2026
Merged

Update com.networknt:json-schema-validator to 2.0.1#3344
tomakehurst merged 4 commits into
wiremock:masterfrom
pedroboado:bump-json-schema-validator-2.x

Conversation

@pedroboado

@pedroboado pedroboado commented Feb 26, 2026

Copy link
Copy Markdown
Contributor

The dependency json-schema-validator has seen a major API rework after 1.5.6 , making keeping it up-to-date a tad more challenging. This PR addresses the required code changes to unblock the dependency update from the now discontinued branch 1.5.x . json-schema-validator:2.0.1 retains Java 8 and Jackson 2 requirements.

Migrate from the removed 1.x API to the 2.x equivalents:

  • Updated JsonParseTest to reflect that Error.getMessage() no longer prefixes the instance location (e.g. "$: ") to the message text.

References

Submitter checklist

  • Recommended: Join WireMock Slack to get any help in #help-contributing or a project-specific channel like #wiremock-java
  • The PR request is well described and justified, including the body and the references
  • The PR title represents the desired changelog entry
  • The repository's code style is followed (see the contributing guide)
  • Test coverage that demonstrates that the change works as expected
  • For new features, there's necessary documentation in this pull request or in a subsequent PR to wiremock.org

@pedroboado pedroboado requested a review from a team as a code owner February 26, 2026 08:14
@tomakehurst

Copy link
Copy Markdown
Member

Seems this is the reason we didn't upgrade right away:
#3192 (comment)

…r 2.x

Signed-off-by: Pedro Boado <pedro.boado@datadoghq.com>
Comment on lines +56 to +57
Dialect.builder(dialectFor(schemaVersion.toVersionFlag()))
.keyword(new NonValidationKeyword("nullable"))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the .keyword method call doing exactly? the tests seem to pass without it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I'm following the migration notes here

`The `com.networknt.schema.SchemaValidatorsConfig` file has been replaced by either `com.networknt.schema.SchemaRegistryConfig` or `com.networknt.schema.walk.WalkConfig` or moved to `com.networknt.schema.ExecutionConfig` and can no longer be configured on a per schema basis.

Concretely, the migration action for this is

| Name                                  | Migration                                                                               |
| ------------------------------------- | --------------------------------------------------------------------------------------- |
| `nullableKeywordEnabled`              | Removed. Dialect must contain a `nullable` keyword.                                     

nullableKeywordEnabled is the new definition of config.setHandleNullableField(true); introduced with version 1.4.1 , never applied to wiremock.

In version 2.0.x it seems nullable keyword is only supported in OpenAPI 3.0 . What we are doing is adding that keyword nullable to the draft dialects in order to keep the same behaviour .

This is tested in MatchesJsonSchemaPatternTest.nullValueMatchesWhenSchemaDeclaresNullable() :

  • The test passes on master branch , running with version 1.5.6 of json-schema-validator .
  • The test fails after migrating to 2.0.1 right after the first commit in this PR.
  • Adding the nullable keyword to the draft dialects allows it to pass again.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there a legitimate question as to whether we actually want the nullable keyword in here, since it's technically more correct not to support it (we're doing pure JSON Schema here, not OpenAPI), and 4.x is still in beta and thus breaking changes are possible.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pedroboado sorry, you're right, the tests do fail without it. i was just looking at the wrong tests 🤦

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having done a bit of data analysis I think this would be pretty nasty break, so I think we should keep this. Will merge.

…JsonSchemaVersion

Signed-off-by: Pedro Boado <pedro.boado@datadoghq.com>
@pedroboado pedroboado requested a review from RafeArnold March 2, 2026 22:04
@tomakehurst

Copy link
Copy Markdown
Member

@pedroboado please could you run ./gradlew spotlessApply and push the results?

@pedroboado

Copy link
Copy Markdown
Contributor Author

@pedroboado please could you run ./gradlew spotlessApply and push the results?

Done, apologies I missed running it with the last commit.

@tomakehurst

Copy link
Copy Markdown
Member

There's an architecture test failing now. Could you take a quick look at that and push a fix?

@pedroboado pedroboado force-pushed the bump-json-schema-validator-2.x branch from ae9ad2b to e00e5b2 Compare March 24, 2026 09:19
…s and arch tests were not detecting their use. Replacing with chained if sequence.

Signed-off-by: Pedro Boado <pedro.boado@datadoghq.com>
@pedroboado pedroboado force-pushed the bump-json-schema-validator-2.x branch from e00e5b2 to 1616139 Compare March 24, 2026 09:22
@pedroboado pedroboado requested a review from tomakehurst March 26, 2026 08:18
@tomakehurst tomakehurst merged commit b4b2fbe into wiremock:master Mar 26, 2026
5 checks passed
@tomakehurst

Copy link
Copy Markdown
Member

Thanks @pedroboado !

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.

3 participants