Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-19698

camel-yaml-dsl: Express "simple" and "expression.simple" are mutually exclusive if possible

    XMLWordPrintableJSON

Details

    • Task
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 4.1.0
    • camel-yaml-dsl
    • None
    • Unknown

    Description

      For example currently YAML DSL allows specifying both "simple" and "expression" under "when"

      - from: 
          uri: "timer:test"
          parameters: 
            period: 3000
          steps: 
          - when: 
              simple: "${header.baz} != null"
              expression: 
                simple: "${header.baz} == null"
              steps: 
                - log: "test"
      

      But at runtime only latter wins in this case. It would be nice if this exclusiveness could be expressed in the schema.

      Similarly, this "anyOf" seems to allow specifying multiple expressions
      https://github.com/apache/camel/blob/36bcd6277854b8e69ca91a8d51845a306b1c2136/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camel-yaml-dsl.json#L3567-L3569

      for example

      - from: 
          uri: "timer:test"
          parameters: 
            period: 3000
          steps: 
          - when: 
              simple: ${header.baz} != null
              jq: ".foo"
              steps: 
                - log: "test"
      

      Although this ends up with a runtime error

      2023-08-02 14:27:29.445  INFO 1579388 --- [           main] org.apache.camel.main.MainSupport   : Using Java 20.0.1 with PID 1579388. Started by tomo in /home/tomo/workspace/Kaoto/datamapper-research/examples
      Field: jq has already been configured as an expression
       in file:test.yaml, line 8, column 13:
                  jq: ".foo"
                      ^
      
      	at org.apache.camel.dsl.yaml.deserializers.ModelDeserializers$WhenDefinitionDeserializer.setProperty(ModelDeserializers.java:18445)
      	at org.apache.camel.dsl.yaml.deserializers.ModelDeserializers$WhenDefinitionDeserializer.setProperty(ModelDeserializers.java:18385)
      	at org.apache.camel.dsl.yaml.common.YamlDeserializerBase.setProperties(YamlDeserializerBase.java:125)
      	at org.apache.camel.dsl.yaml.common.YamlDeserializerBase.construct(YamlDeserializerBase.java:65)
      

      Attachments

        Issue Links

          Activity

            People

              igarashitm Tomohisa Igarashi
              igarashitm Tomohisa Igarashi
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: