Skip to content

CAMEL-22987: Add strict YAML DSL JSON Schema variant#22059

Open
gnodet wants to merge 2 commits intomainfrom
CAMEL-22987-strict-yaml-schema
Open

CAMEL-22987: Add strict YAML DSL JSON Schema variant#22059
gnodet wants to merge 2 commits intomainfrom
CAMEL-22987-strict-yaml-schema

Conversation

@gnodet
Copy link
Contributor

@gnodet gnodet commented Mar 17, 2026

Summary

  • Add a strict JSON Schema variant (camelYamlDsl-strict.json) that removes all implicit patterns from the YAML DSL schema: no string shorthands, no inline expressions, no oneOf/anyOf/not constructs
  • The strict schema is ~25% smaller and significantly easier for tooling (IDEs, code generators, AI assistants) to process
  • The classic schema (camelYamlDsl.json) is unchanged and continues to support all existing shorthands

Changes

  • GenerateYamlSchemaMojo: new strict parameter that skips inline string shorthands, __extends expression merging, and oneOf grouping
  • camel-yaml-dsl/pom.xml: second execution to generate the strict schema
  • YamlValidator: new boolean strict constructor parameter to validate against either schema
  • 7 new tests covering strict vs classic validation behavior
  • Documentation in yaml-dsl.adoc explaining both schema variants with examples
  • Upgrade guide entry in camel-4x-upgrade-guide-4_19.adoc

Test plan

  • All 17 validator tests pass (10 existing + 7 new)
  • Strict schema validates explicit forms correctly
  • Strict schema rejects string shorthands (e.g. log: "${body}")
  • Strict schema rejects inline expressions (e.g. setBody: { simple: "..." })
  • Classic schema continues to accept both implicit and explicit forms
  • CI build passes

@github-actions
Copy link
Contributor

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run
  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot although they are normally detected and executed by CI.
  • You can label PRs using build-all, build-dependents, skip-tests and test-dependents to fine-tune the checks executed by this PR.
  • Build and test logs are available in the summary page. Only Apache Camel committers have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

@github-actions
Copy link
Contributor

🧪 CI tested the following changed modules:

  • docs
  • dsl/camel-yaml-dsl/camel-yaml-dsl
  • dsl/camel-yaml-dsl/camel-yaml-dsl-maven-plugin
  • dsl/camel-yaml-dsl/camel-yaml-dsl-validator
  • dsl/camel-yaml-dsl/camel-yaml-dsl
Full reactor (40 modules)
  • Camel :: Coverage
  • Camel :: Coverage [pom]
  • Camel :: Docs
  • Camel :: Docs [pom]
  • Camel :: JBang :: Core
  • Camel :: JBang :: Core [jar]
  • Camel :: JBang :: Integration tests
  • Camel :: JBang :: Integration tests [jar]
  • Camel :: JBang :: MCP
  • Camel :: JBang :: MCP [jar]
  • Camel :: JBang :: Main
  • Camel :: JBang :: Main [jar]
  • Camel :: JBang :: Plugin :: Edit
  • Camel :: JBang :: Plugin :: Edit [jar]
  • Camel :: JBang :: Plugin :: Generate
  • Camel :: JBang :: Plugin :: Generate [jar]
  • Camel :: JBang :: Plugin :: Kubernetes
  • Camel :: JBang :: Plugin :: Kubernetes [jar]
  • Camel :: JBang :: Plugin :: Route Parser
  • Camel :: JBang :: Plugin :: Route Parser [jar]
  • Camel :: JBang :: Plugin :: Testing
  • Camel :: JBang :: Plugin :: Testing [jar]
  • Camel :: JBang :: Plugin :: Validate
  • Camel :: JBang :: Plugin :: Validate [jar]
  • Camel :: Kamelet Main
  • Camel :: Kamelet Main [jar]
  • Camel :: Launcher
  • Camel :: Launcher [jar]
  • Camel :: Launcher :: Container
  • Camel :: Launcher :: Container [pom]
  • Camel :: YAML DSL
  • Camel :: YAML DSL [jar]
  • Camel :: YAML DSL :: Deserializers
  • Camel :: YAML DSL :: Deserializers [jar]
  • Camel :: YAML DSL :: Maven Plugins
  • Camel :: YAML DSL :: Maven Plugins [maven-plugin]
  • Camel :: YAML DSL :: Validator
  • Camel :: YAML DSL :: Validator [jar]
  • Camel :: YAML DSL :: Validator Maven Plugin
  • Camel :: YAML DSL :: Validator Maven Plugin [maven-plugin]

@github-actions
Copy link
Contributor

Parent POM dependency changes: targeted tests passed

Changed properties: smallrye-fault-tolerance-version

Affected modules (1)
  • :camel-microprofile-fault-tolerance

Add a strict JSON Schema variant (camelYamlDsl-strict.json) that removes
all implicit patterns from the YAML DSL schema:
- No string shorthands (e.g. log: "${body}" must be log: { message: ... })
- No inline expressions (e.g. setBody: { simple: ... } must use expression wrapper)
- No oneOf/anyOf/not constructs

This results in a ~25% smaller schema that is significantly easier for
tooling (IDEs, code generators, AI assistants) to process.

Changes:
- GenerateYamlSchemaMojo: add strict parameter to skip inline, __extends, oneOf
- pom.xml: add second execution to generate strict schema
- YamlValidator: add strict constructor to validate against strict schema
- 7 new tests validating strict vs classic schema behavior
- Documentation in yaml-dsl.adoc and upgrade guide

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gnodet gnodet force-pushed the CAMEL-22987-strict-yaml-schema branch from 2ea6aa0 to 81903c5 Compare March 18, 2026 06:51
@gnodet
Copy link
Contributor Author

gnodet commented Mar 18, 2026

The CI failure here is caused by flaky camel-smb integration tests (unrelated to this PR). The SMB module was pulled into the incremental build by CI dependency detection and failed first in the reactor, causing all YAML DSL modules to be skipped.

This should be fixed by #22081 which addresses the SMB test issues. Once that's merged, re-running CI here should go green.

@gnodet gnodet marked this pull request as ready for review March 19, 2026 07:29
Copy link
Contributor

@apupier apupier left a comment

Choose a reason for hiding this comment

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

I think it will be worthy that some people from Kaoto review also this PR to see if the strict way is matching what is supported currently, or at least if there is no blocker to support it easily.

//cc @lordrip

Note that we will need to change the default when exporting from Camel JBang, updating most examples and publish it along the other one in Json schemastore

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants