Skip to content

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

Merged
phipag merged 1 commit into
mainfrom
fix/validation-schema-version
Oct 11, 2026
Merged

phipag merged 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

@phipag
phipag requested a review from svozza October 10, 2026 16:15
@phipag
phipag merged commit 681b8f2 into main Oct 11, 2026
18 checks passed
@phipag
phipag deleted the fix/validation-schema-version branch October 11, 2026 12:58
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