Angular schema form access Object with Arrays from Form - angularjs

I have a scenario where i need to display arrays in side a named object like this:
"actions": {
"singleSelection": [
{
"chartable": false,
"label": ""
}
]
}
I have accomplished it with the following schema:
"schema": {
"type": "object",
"title": "smart_report",
"properties": {
"actions": {
"title": "Actions",
"type": "object",
"properties": {
"singleSelection": {
"title": "Action: Single selection",
"type": "array",
"maxItems": 10,
"items": {
"type": "object",
"properties": {
"field": {
"title": "Field name",
"type": "string"
},
"label": {
"title": "Label",
"type": "string",
"description": "Label will be used for column name."
},
"chartable": {
"title": "Chartable",
"type": "boolean"
}
}
}
}
}
}
}
Now am trying to set the 'notitle' flag on 'actions' in from and trying to access the properties of 'actions', but its not working as expected:
{
"key": "actions",
"notitle": true,
"properties": {
"key": "singleSelection",
"notitle": true,
"startEmpty": true
}
},
I still see title for actions as well for 'singleSelection' and 'stratEmpty' is also not set.

If you remove the titles from the schema, as well as using the notitle attribute it should work.
(In case you remove the title, but do not use the notitle attribute, the title will be displayed with the same name as the key).

Related

Know how much deep we have come in an rjsf form

So Rjsf is composed of schema, the schema I have is deeply nested and I want to break break the view once I reach 3 level deep child.
How can I know that I am at which level of nesting?
e.g.:
{
"title": "Application", // root level child
"type": "object",
"properties": {
"replicas": {
"type": "integer"
},
"containers": { //1st level
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"image": {
"type": "string"
},
"commands": {
"type": "array",
"items": {
"type": "string"
}
},
"ports": { //2nd level
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string",
"default": "http"
},
"containerPort": { //3rd level deep
"type": "integer"
}
},
"minItems": 1,
"required": [
"containerPort"
]
}
},
"envs": { //2nd level
"type": "array",
"items": {
"type": "object",
"properties": {
"name": { // 3rd level
"type": "string"
},
"value": { //3rd level
"type": "string"
}
}
}
}
},
"required": [
"name",
"image",
"ports"
],
"minItems": 1
}
}
},
"required": [
"replicas",
"containers"
]
}
I want to break the UI into some other form based on the level of children. e.g., I want to make an other form when I want to get input of 3rd level deep childrens? How can I get the level of nested children?

Power automate - Custom connector - Webhook trigger with dynamic schema properties

I'm trying to create a webhook trigger in Power Automate via the OpenApi spec.
The webhook url must be in the body and it's required, but I also want to have dynamic properties in the body aswell. So far I have this:
"/webhook/triggers/{entityType}": {
"x-ms-notification-content": {
"description": "When a operation is performed on a entity",
"x-ms-summary": "When a operation is performed on a entity",
"schema": {
"type": "object",
"properties": {
"data": {
"type": "object",
"x-ms-dynamic-schema": {
"operationId": "GetDynamicSchema",
"parameters": {
"entityType": {
"parameter": "entityType"
}
}
}
},
"id": {
"type": "string"
},
"source": {
"type": "string"
},
"type": {
"type": "string"
},
"time": {
"format": "date-time",
"type": "string"
},
"dataSchema": {
"type": "string"
},
"dataContentType": {
"type": "string"
},
"extensionAttributes": {
"type": "object",
"additionalProperties": {
"type": "object"
}
}
}
}
},
"post": {
"description": "When a operation is performed on a entity",
"x-ms-trigger": "single",
"x-ms-visibility": "important",
"summary": "When a operation is performed on a entity",
"operationId": "RegisterTriggerWithEntity",
"consumes": ["application/json"],
"produces": ["application/json"],
"parameters": [
{
"name": "entityType",
"x-ms-summary": "Entity",
"description": "The entity",
"x-ms-url-encoding": "single",
"in": "path",
"required": true,
"type": "string",
"x-ms-dynamic-values": {
"operationId": "GetEntityTypes",
"value-path": "name",
"value-title": "description"
}
},
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"type": "object",
"properties": {
"webhookUrl": {
"type": "string",
"x-ms-notification-url": true,
"x-ms-visibility": "internal"
},
"data": {
"type": "object",
"x-ms-dynamic-schema": {
"operationId": "GetSchema",
"parameters": {
"entityType": {
"parameter": "entityType"
}
}
},
"x-ms-dynamic-properties": {
"operationId": "GetSchema",
"parameters": {
"entityType": {
"parameterReference": "entityType"
}
}
}
}
},
"required": [
"webhookUrl"
],
"x-ms-visibility": "important"
}
}
],
"responses": {
"201": {
"description": "Created"
},
"401": {
"description": "Unauthorized"
},
"403": {
"description": "Forbidden"
}
}
}
}
Which passes validation, I also have the schema properties prompted in the UI ready to be provided by the user, but on saving the flow, I get the following OpenApiOperationParameterValidationFailed:
Flow save failed with code 'OpenApiOperationParameterValidationFailed' and message 'Input parameter 'body' validation failed in workflow operation 'When_a_operation_is_performed_on_a_entity': The API operation 'RegisterTriggerWithEntity' requires the property 'body/data' to be set to one of its defined enum values '[]' but is set to '{ "firstProperty": "testValue" }'.'.
What might be the problem with this flow? What is the suggested way of having a webhook trigger with dynamic schema properties?

Azure Logic App Partition key [X] is invalid with COsmos Db

I need to save JSON parsed data to Cosmos Db, HTTP trigger works as it should as well as parsing but getting Partition key [my_dynamic_key_value] is invalid.
Did anyone have a similar issue?
I have found this article link but still getting the same error.
Thanks
EDIT 1
This is the flow for adding item to DB
Schema:
{
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"Groups": {
"type": "array",
"items": {
"type": "string"
}
},
"JobName": {
"type": "string"
},
"Link": {
"type": "string"
},
"MinSalary": {
"type": "string"
},
"MaxSalary": {
"type": "string"
},
"Hours": {
"type": "string"
},
"WorkPattern": {
"type": "string"
},
"Details": {
"type": "array",
"items": {
"type": "object",
"properties": {
"Name": {
"type": "string"
},
"Detail": {
"type": "string"
}
},
"required": [
"Name",
"Detail"
]
}
}
},
"required": [
"id",
"Groups",
"JobName",
"Link",
"MinSalary",
"MaxSalary",
"Hours",
"WorkPattern",
"Details"
]
}
}
Here is a response:
{
"code": "BadRequest",
"message": "Partition key [1bb2d44f-a066-4fa8-8a78-0cdcea1a756c] is invalid.\r\nActivityId: 345f9a99-534b-40cb-9dc0-9863dc8c90f5, \r\nRequestStartTime: 2020-04-28T08:04:46.8249255Z, RequestEndTime: 2020-04-28T08:04:46.8249255Z, Number of regions attempted:1\r\n, Microsoft.Azure.Documents.Common/2.10.0"
}
You need to set the partition key in the double quotes. Refer to sample screen shot below

SchemaForm array conditional

Background
I am making a form using http://schemaform.io/
Setup
I am trying to make an array of objects that a user can make using a form. So, the user can add as many items into the array as they want.
The array of items contains a type, then another field depending on what the type was.
If the user clicks REST, I want it to offer a field called method.
If the user clicks SSH, I want it to offer a field called path.
Code so far
SCHEMA
{
"type": "object",
"title": "Command Asset",
"properties": {
"name": {
"title": "Name",
"type": "string"
},
"commands": {
"type": "array",
"title": "Actions",
"items": {
"type": "object",
"properties": {
"commandType": {
"title": "Command Type",
"type": "string",
"enum": [
"REST",
"SSH"
]
},
"path": {
"title": "Path",
"type": "string"
},
"method": {
"title": "Method",
"type": "string"
}
}
}
}
}
}
FORM
[
{
"type": "help",
"helpvalue": "<h5>Command</h5>"
},
"name",
{
"title":"Command",
"key": "commands",
"items": [
"commands[].commandType",
{
"type": "conditional",
"condition": "modelData.commands[0].commandType=='SSH'",
"items": [
{
"key": "commands[].path"
}
]
},
{
"type": "conditional",
"condition": "modelData.commands[0].commandType=='REST'",
"items": [
{
"key": "commands[].method"
}
]
}
]
}
]
One can test this code here: http://schemaform.io/examples/bootstrap-example.html
Question
As one can see, the code I have now makes all the items' secondary properties (path or method) dependent on the first item in the array's commandType (at [0]), but I want it to depend on the commandType of the corresponding item. So, if item one has commandType of REST, it offers a method field and if item two has a command type of SSH it offers a field of path and so on.
I found an answer.
Replace the [0] with [arrayIndex].
I found it from here: https://github.com/json-schema-form/angular-schema-form/commit/21f6d3ab64435b032456dfe19e03f96b29366320

Using an array inside array

I'm trying to generate a form which will have multiple vehicles and each vehicle should have multiple people inside it.
I tried to do it by using an array inside another array. But for some obscure reasons it's not working.
This is what I want:
http://i.imgur.com/ZB2kCa1.png
This is what I have (so far):
Form:
[
{
"key": "vehicles",
"items": [
"['vehicles'][]['plate-number']",
"['vehicles'][]['color']",
{
"key": "people",
"items": [
"['vehicles'][]['people'][]['name']"
]
}
]
}
]
Schema:
{
"type": "object",
"properties": {
"vehicles": {
"type": "array",
"items": {
"type": "object",
"properties": {
"plate-number": {
"title": "Plate number",
"type": "string"
},
"color": {
"title": "Color",
"type": "string"
},
"people": {
"type": "array",
"items": {
"type": "object",
"properties": {
"title": {
"type": "string",
"enum": ["dr","jr","sir","mrs","mr","NaN","dj"]
},
"name": {
"title": "Name",
"type": "string"
}
}
}
}
}
}
}
}
}
Edit:
stefankmitph's answer solvers my problem. Thank you!
But something weird is happening: a new object person is added at the same level of vehicles. Also, when I fill a person's information and then delete this person the models is not updated.
The schema you provide does not add a property 'gender' (as shown in your picture link). So I took 'title' instead of 'gender':
[
{
"key": "vehicles",
"items": [
"vehicles[].plate-number",
"vehicles[].color", {
"key": "people",
"type": "array",
"title": "People",
"items": [
"vehicles[].people[].name",
"vehicles[].people[].title"
]
}
]
}
]
I hope this is what you're looking for!
Note: Tested with Schema Form Example Page

Resources