You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add support for selectors in SchemaUpdater. A complex response can be narrowed by the selector to produce the object structure as desired by the SchemaUpdater.
Copy file name to clipboardExpand all lines: workspaces/orchestrator/docs/orchestratorFormWidgets.md
+69-5Lines changed: 69 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -39,7 +39,7 @@ A headless widget used for fetching snippets of JSON schema and dynamically upda
39
39
40
40
Thanks to this component, complex subparts of the form can be changed based on data entered in other fields by the user.
41
41
42
-
Example of use in workflow's input data schema:
42
+
### Example of the SchemaUpdater use in workflow's input data schema
43
43
44
44
```json
45
45
{
@@ -67,6 +67,8 @@ Example of use in workflow's input data schema:
67
67
}
68
68
```
69
69
70
+
### Expected response for the SchemaUpdater
71
+
70
72
The response of `fetch:url` endpoint is expected to be a JSON document conforming structure defined by the `SchemaChunksResponse` type.
71
73
72
74
Considering the data-input schema structure above, the response can look like:
@@ -86,10 +88,15 @@ Considering the data-input schema structure above, the response can look like:
86
88
}
87
89
```
88
90
89
-
Please note: The response must be a single JSON object whose property names correspond to the identifiers defined in the data-input JSON Schema.
91
+
Please note: The response must be
92
+
93
+
- a single JSON object
94
+
- whose property names correspond to the identifiers defined in the data-input JSON Schema
95
+
- and values are valid replacements for the UI schema.
90
96
91
-
A provided snipped can be of `"type": "object"` and so inject/replace fields for a complex data structure.
92
-
Additional `SchemaUpdater` widgets can be instantiated this way as well.
97
+
A provided snipped can be of `"type": "object"` and so inject/replace fields for a complex data structure, so the use is not limited to just a single string or numeric properties.
98
+
99
+
**Additional `SchemaUpdater` widgets can be instantiated this way as well.**
93
100
94
101
The `SchemaUpdater` widget scans for the identifiers, the top-level property names in the response, and replaces any matching ones with the corresponding values from the response.
95
102
Identifiers that do not exist in the current schema are ignored.
@@ -100,14 +107,71 @@ You can instantiate multiple `SchemaUpdater` widgets simultaneously. It is up to
100
107
101
108
It is highly recommended that endpoints are implemented as stateless and free from side effects, consistently returning the same response for identical input sets.
102
109
103
-
### SchmeaUpdater widget ui:props
110
+
### Using selector to narrow complex response in SchemaUpdater
111
+
112
+
As stated above, the `SchemaUpdater` expects a single object of the desired structure as its input.
113
+
114
+
If the response does not meet that condition, meaning it contains additional data or the structure is malformed, the `fetch:response:value` selector can be used to pick-up a single object in the desired format.
115
+
116
+
Example complex HTTP response:
117
+
118
+
```json
119
+
{
120
+
"foo": "bar",
121
+
"prop1": {
122
+
"subprop": "a lot of complex but useless stuff"
123
+
},
124
+
"mydataroot": {
125
+
"mydata": {
126
+
"sendCertificatesAs": {
127
+
"type": "string",
128
+
"title": "Send certificates via",
129
+
"ui:widget": "ActiveText",
130
+
"ui:props": {
131
+
"ui:variant": "caption",
132
+
"ui:text": "This course does not provide certificate"
133
+
}
134
+
}
135
+
}
136
+
}
137
+
}
138
+
```
139
+
140
+
For the schema:
141
+
142
+
```json
143
+
{
144
+
"properties": {
145
+
...
146
+
"sendCertificatesAs": {
147
+
"type": "object",
148
+
"title": "This title will never be displayed. Will be managed by the 'mySchemaUpdaterForCertificates'.",
0 commit comments