Skip to content

fix: register CycloneDX annotation keywords to silence schema validator warnings#850

Open
patbaumgartner wants to merge 1 commit into
CycloneDX:masterfrom
patbaumgartner:fix/silence-unknown-keyword-warnings
Open

fix: register CycloneDX annotation keywords to silence schema validator warnings#850
patbaumgartner wants to merge 1 commit into
CycloneDX:masterfrom
patbaumgartner:fix/silence-unknown-keyword-warnings

Conversation

@patbaumgartner

Copy link
Copy Markdown

Reference

Addresses the long-standing warning reported in CycloneDX/cyclonedx-maven-plugin#564.

Problem

The CycloneDX JSON schemas (e.g. bom-1.6.schema.json) declare the JSON-Schema draft-07 dialect but use the CycloneDX-proprietary annotation keywords meta:enum and deprecated, which are not part of draft-07. When a consumer has an SLF4J backend on the classpath, the networknt json-schema-validator logs:

Unknown keyword meta:enum - you should define your own Meta Schema...
Unknown keyword deprecated - you should define your own Meta Schema...

once per keyword during BOM validation. This is noise for every downstream tool (e.g. the Maven plugin).

Fix

Derive a draft-07 dialect that registers meta:enum and deprecated as NonValidationKeywords and wire it in via a delegating DialectRegistry on the SchemaRegistry used for CycloneDX schemas. The keywords are pure annotations, so validation behaviour is unchanged — only the spurious warnings are removed.

Tests

  • New CycloneDxJsonDialectTest verifying the keywords are registered as non-validating, that stock draft-07 does not know them, and that a valid 1.6 BOM still validates.
  • Full suite green: 1182 tests, 0 failures, 0 errors.
  • End-to-end check with an SLF4J backend present: 0 "Unknown keyword" warnings on this branch.

…ings

The CycloneDX JSON schemas (e.g. bom-1.6.schema.json) declare the draft-07 dialect but use the CycloneDX-specific 'meta:enum' and 'deprecated' annotation keywords, which are not part of draft-07. The networknt json-schema-validator therefore logs an "Unknown keyword <name>" warning for each one during BOM validation.

Register both keywords as NonValidationKeyword on a draft-07-based dialect used for the CycloneDX schemas. They carry no validation semantics, so validation results are unchanged; only the spurious warnings are removed.

Signed-off-by: Patrick Baumgartner <contact@patbaumgartner.com>
@patbaumgartner patbaumgartner requested a review from a team as a code owner June 20, 2026 21:08
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity

Metric Results
Complexity 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@hboutemy

Copy link
Copy Markdown
Contributor

should fix #280

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.

2 participants