cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

How to create an action output schema for array of array or string

fsantaana
Deputy Chef II
Deputy Chef II

I have a custom connector which I am creating a output field schema for.

The HTTP response is JSON in the following format:

{
  Key: [
    [
      "string",
      "string2",
      "..."
     ]
    ],
  Key2: "String",
  Key3: "integer",
}


Here is a sample:

{... 
"user_usage": [
      [
        "user-agent",
        "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.5112.81 Safari/537.36 Edg/104.0.1293.54"
      ],
      [
        "user-agent",
        "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36"
      ],
  ],
"server_name": "THIS IS A SERVER",
...
}

 How do I create the field definition schema for this Nested Array of a Nested Array? I've tried the below schema but it doesn't seem to work correctly. Looking through the docs, it seems to only accept a nested object for array "of" and not a nested array. 

          {
            name:"user_usage",
            type: "array",
            of: "object",
            properties:[
              {
                type:"array",
                of: "string"
              }
            ]  
          },

 

1 ACCEPTED SOLUTION

gary1
Star Chef I
Star Chef I

I got this to work for me in a recipe (not in the SDK):

[
  {
    "name": "outer_array",
    "type": "array",
    "optional": false,
    "properties": [
      {
        "name": "array",
        "type": "array",
        "of": "string",
        "control_type": "text",
        "label": "Array"
      }
    ],
    "of": "object",
    "label": "Outer array"
  }
]

It's weird that the outer array is "of object", but it seems to be correct.

View solution in original post

8 REPLIES 8

syepes
Deputy Chef II
Deputy Chef II

The example is that I would like to have a JSON schema for a Recipe function, that for a specific parameter it only accepts a predefined list of values (Enum):
https://json-schema.org/understanding-json-schema/reference/enum

Ignore my last response. I re-read your request. This is what you need:

[
  {
    "control_type": "select", // manual update
    "label": "Enum",
    "name": "enum",
    "type": "string",
    "optional": false,
    "pick_list": [ // add this manually
      [
        "label", // the label the user sees in the UI when calling the function
        "Value" // the actual value of the pick list opton
      ],
      [
        "one",
        "1"
      ],
      [
        "two",
        "2"
      ],
      [
        "three",
        "3"
      ]
    ]
  }
]

syepes
Deputy Chef II
Deputy Chef II

Thanks for the response, it works!.
Do you know if this is documented somewhere. It looks very similar to JSON Schema but it has some custom operators

This is documented as part of the custom connector SDK object definitions schema, but the documentation doesn't clearly state it can also be used in input fields in recipes (on triggers, in variables, etc.). However, the SDK and recipe actions both rely on the same object definition schemas, so it makes sense they would work in both places.