Skip to content

OneOf choice is not rendered properly with non-object typed elements #3508

Description

@christophd

Describe the Bug

Kaoto renders oneOf Json schema with a choice field in the forms. This mechanism is not working when the oneOf schema array contains non-object items such as seen in this example:

"message": {
  "type": "object",
  "properties": {
    "body": {
      "type": "object",
      "properties": {
        "data": {
          "type": "string",
          "title": "Data",
          "description": "The message body content as inline data."
        },
        "resource": {
        },
        "script": {
        }
      },
      "additionalProperties": false,
      "anyOf": [
        {
          "oneOf": [
            {
              "required": [
                "data"
              ]
            },
            {
              "type": "object",
              "properties": {
                "resource": {
                  "type": "object",
                  "properties": {
                    "charset": {
                      "type": "string",
                      "title": "Charset",
                      "$comment": "group:advanced"
                    },
                    "file": {
                      "type": "string",
                      "title": "File"
                    }
                  },
                  "additionalProperties": false,
                  "title": "Resource",
                  "description": "The message body loaded from a file resource."
                }
              }
            },
            {
              "type": "object",
              "properties": {
                "script": {
                  "type": "object",
                  "properties": {
                    "charset": {
                      "type": "string",
                      "title": "Charset",
                      "description": "The charset used to load the file resource.",
                      "$comment": "group:advanced"
                    },
                    "content": {
                      "type": "string",
                      "title": "Content",
                      "description": "The script content as inline data."
                    },
                    "file": {
                      "type": "string",
                      "title": "File",
                      "description": "The script content loaded as a file resource."
                    },
                    "type": {
                      "type": "string",
                      "title": "Type",
                      "description": "The script type.",
                      "default": "groovy"
                    }
                  },
                  "additionalProperties": false,
                  "title": "Script",
                  "description": "The message body set via script."
                }
              }
            },
            {
              "not": {
                "anyOf": [
                  {
                    "required": [
                      "data"
                    ]
                  },
                  {
                    "required": [
                      "resource"
                    ]
                  },
                  {
                    "required": [
                      "script"
                    ]
                  }
                ]
              }
            }
          ]
        }
      ],
      "title": "Body",
      "description": "The message body."
    }
  }
}

Kaoto should render the oneOf schema with a forms field representing the choice.

Steps to Reproduce the Bug or Issue

  1. use given schema in Kaoto catalog for the Citrus send operation message element
  2. create a new test entity with a send test action
  3. add a message body in the forms

Screenshots or Videos

Given this oneOf schema the Kaoto rendered form looks like this (with error):

Image

Platform

  • OS: [macOS]
  • Browser: [Chrome]
  • Version: latest

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    Status
    New

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions