Skip to content

fix(validation): respect schema version set in ValidationConfig - #2677

Open
phipag wants to merge 1 commit into
mainfrom
fix/validation-schema-version
Open

phipag wants to merge 1 commit into
mainfrom
fix/validation-schema-version

Conversation

@phipag

@phipag phipag commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Stacked on the json-schema-validator 2.x upgrade. Merge that PR first.

Changes

ValidationAspect compared the annotation schema version against DRAFT_2019_09. The annotation default is DRAFT_7. As a result:

  • Every @Validation call without schemaVersion reset the version set with ValidationConfig.get().setSchemaVersion(...) to draft 7.
  • An explicit @Validation(schemaVersion = DRAFT_2019_09) had no effect.

This PR compares against DRAFT_7. The aspect now overrides the global version only when the annotation sets a non-default version.

  • ValidationAspect: compare against DRAFT_7 instead of DRAFT_2019_09.
  • ValidationAspectTest: add two tests. The first checks that a version set in ValidationConfig survives a @Validation call without schemaVersion. The second checks that an explicit DRAFT_2019_09 applies. Both tests fail without the fix. An @AfterEach resets the global schema version.
  • docs/utilities/validation.md: add one sentence on precedence.

Issue number: closes #2676


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

@phipag phipag added bug Something isn't working validation labels Oct 8, 2026
@phipag
phipag marked this pull request as ready for review October 8, 2026 13:24
@phipag
phipag requested a review from a team as a code owner October 8, 2026 13:24
@mergify

mergify Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again.

@phipag
phipag added this pull request to stack #2678 October 8, 2026 13:25
svozza
svozza previously approved these changes Oct 8, 2026
Base automatically changed from feat/json-schema-validator-2 to main October 8, 2026 16:52
ValidationAspect compared the annotation schema version against DRAFT_2019_09 instead of the annotation default DRAFT_7. Every @Validation call without schemaVersion reset the version set in ValidationConfig, and an explicit DRAFT_2019_09 had no effect. The aspect now overrides the global version only when the annotation sets a non-default version.
@phipag
phipag force-pushed the fix/validation-schema-version branch from 8f0099f to 6f15efd Compare October 8, 2026 16:52
@sonarqubecloud

sonarqubecloud Bot commented Oct 8, 2026

Copy link
Copy Markdown

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size/M validation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: @Validation overrides the schema version set in ValidationConfig

2 participants