project-flogo/contrib

Re-consider the varArgs for function description

Closed this issue · 2 comments

Today, the varArgs is function level field, take concat function as an example here:

{
      "name": "concat",
      "description": "concatenate a set of string",
      "example": "string.concat(\"Hello\",' ', \"World\") => Hello World",
      "varArgs": true,
      "args": [
        {
          "name": "str",
          "type": "string"
        }
      ],
      "return": {
        "type": "string"
      }
    }

But actually the varArgs should be an argument level fields. from go perspective, the varArgs can be only the last argument and there still can be more different type arguments before that.

For concat case, it makes more sense only when the arguments more than 2. so change the descript to below seems more reasonable.

{
  "name": "concat",
  "description": "concatenate a set of string",
  "example": "string.concat(\"Hello\",' ', \"World\") => Hello World",
  "args": [
    {
      "name": "str",
      "type": "string",
      "required": true
    },
    {
      "name": "str2",
      "type": "string",
      "required": true
    },
    {
      "name": "str3",
      "type": "string",
      "varArgs": true
    }
  ],
  "return": {
    "type": "string"
  }
}

@fm-tibco @mellistibco Please give your thoughts.

VarArgs indicates that the last argument is variable. This only ever applies to the last argumet and not individual arguments. Since thats the case it make more sense to put that indicator at the function level. Also makes it easier to define a schema for the json.

@fm-tibco make sense. VarArgs for last argument only.