Skip to main content

Object

Object is a basic input for JSON data.

💡 Common object usage

The object input type can be used to store any key/value based data, for example:

  • Configurations
  • Tags
  • HTTP responses
  • Dictionaries/Hash maps

In the live demo self-service hub page, we can see the Open terraform PR to add S3 bucket action whose policy input is an object input. 🎬

API definition

{
"myObjectInput": {
"title": "My object input",
"icon": "My icon",
"description": "My object input",
"type": "object",
"default": {
"myKey": "myValue"
}
}
}

Check out Port's API reference to learn more.

Terraform definition

resource "port_action" "myAction" {
# ...action properties
user_properties = {
object_props = {
"myObjectInput" = {
title = "My object input"
description = "My object input"
default = jsonencode({ "myKey" = "myValue" })
}
}
}
}

Validate object

Object validations support the following operators:

  • properties - which keys must appear and what their type should be;
  • additionalProperties - are keys not defined in properties allowed and what their type should be;
  • patternProperties - which regex pattern should properties follow
tip

Object validations follow the JSON schema model, refer to the JSON schema docs to learn about all of the available validations

{
"myObjectInput": {
"title": "My object input",
"icon": "My icon",
"description": "My object input",
"type": "object",
"properties": {
"myRequiredProp": { "type": "number" }
},
"patternProperties": {
"^S_": { "type": "string" },
"^I_": { "type": "number" }
},
"additionalProperties": true
}
}