fix: register CycloneDX annotation keywords to silence schema validator warnings#850
Open
patbaumgartner wants to merge 1 commit into
Open
Conversation
…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>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
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.
Contributor
|
should fix #280 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 keywordsmeta:enumanddeprecated, which are not part of draft-07. When a consumer has an SLF4J backend on the classpath, the networknt json-schema-validator logs: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:enumanddeprecatedasNonValidationKeywords and wire it in via a delegatingDialectRegistryon theSchemaRegistryused for CycloneDX schemas. The keywords are pure annotations, so validation behaviour is unchanged — only the spurious warnings are removed.Tests
CycloneDxJsonDialectTestverifying the keywords are registered as non-validating, that stock draft-07 does not know them, and that a valid 1.6 BOM still validates.